duchien85 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Improve performance of Serializer.create() method #129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, Serializer.create(Kryo kryo, Input input, Class<T> type) method 
often calls kryo.newInstance(type).
This newInstance calls results in at least one hash table lookup, because it 
needs to map the type to a corresponding Registration object. 

When it is done during deserialization of a map or a collection, it may 
introduce some measurable overhead.

At the same time, Registration object is often available to Kryo instance even 
before the call of Serializer.read(Input input).

Proposal:
May be Registration object should be passed to Serializer.read() (and 
Serializer.write()) methods from Kryo.readXYZ() methods? In this case, this 
Registration object can be passed around down the call stack without a need to 
perform any additional Class->Registration lookups.

New Kryo.newInstance (Class<T> type, Registration registration) method could be 
introduced, which would take an additional Registration object and use it 
instead of performing a map lookup on the fast path of deserialization 
execution.

P.S. Overall, Kryo should try to minimize the number of map lookups on fast 
paths. In particular, lookups with of the same information, e.g. 
Class->Registration mappings.

Original issue reported on code.google.com by romixlev on 26 Aug 2013 at 10:21

GoogleCodeExporter commented 9 years ago

Original comment by romixlev on 26 Aug 2013 at 11:23