gaob13 / kryo

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

Very slow automatic serialization of ArrayList #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. kryo.register(ArrayList.class);
2. serialize - deserialize

What is the expected output? What do you see instead?
Very slow serialization. SerializableSerializer works about 10 times faster.

What version of the Kryo are you using?
1.04

Please provide any additional information below.
1. ArrayList contains an elements having another ArrayList<byte[]> as a field. 
All other fields are primitives, or Strings, or another objects containing only 
primitives or Strings. All objects are registered.
2. setRegistrationOptional() is not set. All classes are registered via 
kryo.register(ClassName.class)
3. Changing kryo.register(ArrayList.class); -> 
kryo.register(ArrayList.class, new SerializableSerializer());
leads to great speedup
4. Profiling with jvisualvm on read process said that all the time is spend in 
ArraySerializer.readArray(...) method.
If I'm doing something wrong will be happy to hear corrections.

Original issue reported on code.google.com by victor.t...@gmail.com on 29 Feb 2012 at 12:38

GoogleCodeExporter commented 9 years ago
So, I found it.
kryo.register(byte[].class, new SerializableSerializer()); - and it becomes 
faster.
byte[] serializer works slow.

Original comment by victor.t...@gmail.com on 29 Feb 2012 at 1:03

GoogleCodeExporter commented 9 years ago

Original comment by nathan.s...@gmail.com on 29 Mar 2012 at 6:27

GoogleCodeExporter commented 9 years ago
Thanks for finding the cause. Fixed in Kryo v2, now in trunk. 
DefaultSerializers.ByteArraySerializer serializes byte[] efficiently.

Original comment by nathan.s...@gmail.com on 1 Apr 2012 at 7:46

GoogleCodeExporter commented 9 years ago
Thanks a lot. Kryo is great when you need to serialise a complicated object 
hierarchy without spending a lot of human resources.

Original comment by victor.t...@gmail.com on 1 Apr 2012 at 7:50