Hi,

I digged through the object serialization code and found some lines that could 
be optimized to reduce the number of calls to System.arraycopy() and temporary 
object allocations especially during string (de)serialization.
In short sentences the changes are:
ObjectInputStream:
- skip primitive/object reading if no primitive/objects in class 
(defaultReadFields method)
- use shared StringBuilder for string reading (prevent superfluous object 
allocations of one StingBuilder and one implicit char[] for each string being 
deserialized)
ObjectOutputStream:
- skip primitive/object writing if no primitive/objects in class 
(defaultWriteFields method)
- use unsafe access to calculate UTF-length
- use unsafe access in readBytes() and writeChars() methods to access String 
value field
- removed cbuf field
ObjectStreamClass/ObjectStreamField:
- minor improvement in getClassSignature ; share method code with 
ObjectStreamField (return constant string for primitives)

I have tested the changes in a big Java installation at a customer (backported 
the Java8 ObjectIn/OutputStream including the changes to Java6) and a long 
running real application performance test resulted in reduced CPU usage (from 
about 60% per server to 50%).
The changes I made in openjdk8 pass all tests.

Since I have no experience how to contribute code to openjdk in form of a 
push/changeset I have added the diff (hg export -g) to this email.

Robert


Reply via email to