I have a Java program that prepares data into a rather complex and large data structure in memory (several GB) and serializes it to disk, and another program that reads the serialized data structure in memory. I was surprised to notice that the deserialization step is rather slow and that it is related to the CPU. (100% CPU usage in top, but only 3 to 5 MB / s, reading from iotop, which is very small for what should be sequential reading on the hard drive). The processor is quite recent (Core i7-3820), the structure fits into the memory, the swap space is not configured.
Why is this so? Is there an alternative way to serialize objects in Java that does not have a CPU as a bottleneck?
Here is the deserialization code, if that matters:
FileInputStream f = new FileInputStream(path);
ObjectInputStream of = new ObjectInputStream(f);
Object obj = of.readObject();
source
share