Kryo registration

28 views
Skip to first unread message

BK

unread,
Feb 22, 2024, 9:33:30 AMFeb 22
to kryo-users

I have a few queries.

1. Will there be any performance advantage if all the required classes are registered
and registration required is set as true?

2. Should Kryo be reset between every serialisation/deserialisation call?

3. If Kryo is used from thread local and same instance is used for all the objects serialised/deserialised using that thread, will there be any significant increase in size of kryo instance? Currently I create new kryo instance for every serialisation/desrialisation call?

Please clarify the above things for me.

Thomas Heigl

unread,
Feb 22, 2024, 12:36:52 PMFeb 22
to kryo-...@googlegroups.com
Hi,

1. Will there be any performance advantage if all the required classes are registered and registration required is set as true?

Serialized size will be smaller and it should be slightly faster.

2. Should Kryo be reset between every serialisation/deserialisation call?

Yes, but it happens automatically by default. See Kryo.setAutoReset().

3. If Kryo is used from thread local and same instance is used for all the objects serialised/deserialised using that thread, will there be any significant increase in size of kryo instance? Currently I create new kryo instance for every serialisation/desrialisation call?

You should absolutely re-use the same Kryo instance. Either from a thread-local or from an object pool. See https://github.com/EsotericSoftware/kryo?tab=readme-ov-file#pooling.

How large a Kryo instance becomes depends on how many classes you register and if you use reference tracking or not. The size tends to stabilize after a while and is usually negligible.

Thomas

--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kryo-users/6f3def69-7d86-4997-8070-f79cb1a11e01n%40googlegroups.com.

BK

unread,
Feb 27, 2024, 6:08:44 AMFeb 27
to kryo-users
Thank you for your detailed response.

Does Kryo instance cache any data, which it has serialised or deserialised?
I assume that the data given to Input/Output instances are not cached in Kryo instance. Please clarify.

Thomas Heigl

unread,
Feb 27, 2024, 6:12:50 AMFeb 27
to kryo-...@googlegroups.com
No, Kryo does not cache anything.

If you care about memory usage, I would recommend pooling and re-using input/output instances as well. 

Reply all
Reply to author
Forward
0 new messages