Improve Java serialization with APPCDS (as a fast path)
timberonce at gmail.com
Thu May 24 02:55:16 UTC 2018
APPCDS is a very interesting optimization aiming at reducing memory
footprint and class loading overhead for multiple Java processes. In my
opinion, it can also be used in other scopes such as serialization.
Currently, Java serializer is slow and induces a large footprint (compared
to application-level serializer). A major problem is that the serializer
should write the description of classes into the serialized bytes, which
increases the total memory consumption.
On the other hand, application-level (or 3rd-party) serializers like Kryo
can reduce the memory footprint by requiring users to assign IDs to certain
This assignment step should be finished very carefully to avoid
inconsistency problem among different JVMs, so application-level
serializers are not that easy to use.
However, we can actually borrow the idea from application-level serializers
with APPCDS (or even CDS) enabling. Consider we already have dumped a class
We can assign IDs directly to those classes according to the order in the
Since multiple JVMs will share the same APPCDS archive correspondence with
the class list, those JVMs can directly use IDs to serialize/deserialize
the classes stored in the archive. This avoids writing class descriptions
into serialization bytes and simplifies the serialization/deserialization
phase. Furthermore, it also saves users from manually assigning IDs to
Note that APPCDS only provides a fast path for ser/deser. If a class is not
on the class list (and the archive), the serializer falls back to class
description. However, the fast path can become more efficient with more
advanced features, such as supporting custom classloaders.
Anyway, I think APPCDS is a good fit to improve Java serialization.
I am willing to take suggestions!
Institute of Parallel and Distributed Systems
School of Software Engineering
Shanghai Jiao Tong University
More information about the hotspot-runtime-dev