New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an opt-out for disabling the optimization of generics serialization #433
Conversation
AFAICS the following issues might benefit from this PR and should be checked with the changes of this PR: #377, #384 (#385), #411 Updates:
|
CachedField cachedField; | ||
|
||
if (fieldGenericType == fieldClass[0]) { | ||
if (!config.isOptimizedGenerics() || fieldGenericType == fieldClass[0]) { | ||
// This is a field without generic type parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should probably be changed now.
@magro I'm not sure about the interplay of the config field of the FieldSerializer and my patch. If someone would change the optimizedGenerics setting of the config from May be FieldSerializer should get a non-modifiable copy of the config? |
); | ||
kryo.getFieldSerializerConfig().setOptimizedGenerics(false); | ||
runTests( | ||
"standard-nonopt-generics", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new files (test/resources/*-standard-nonopt-generics.ser
) created when running this SerializationCompatTest
should be added to git (applies to other new nonopt files as well).
@romix Thanks again for your work here! Can you elaborate a bit more on the consequences of the As I understand it, with non-optimized generics we should have faster (de)serialization of generics but increased size, and generics serialization should be more robust. Assuming that generics serialization is in-fact more robust with this setting, I wonder if we should make this the default (if we'd release this then as 4.0 or 3.1 is a different question). WDYT? /cc @NathanSweet |
@romix The FieldSerializer could also "freeze" this setting in the cloned romix notifications@github.com schrieb am Mo., 13. Juni 2016, 00:18:
|
@magro Regarding the consequences of this patch on size/performance: I haven't written or executed any benchmarks due to the lack of time. But your understanding is correct. I expect exactly the same as you do: with non-optimized generics we should have faster (de)serialization of generics but increased size, and generics serialization should be more robust. Basically, the size is likely the be roughly the same as it used to be before I introduced those generics optimizations a while ago. It would be nice if you or someone else could help with the benchmarking of this non-optimized mode. As for making it a default, I'm not sure. But it could be a good idea, indeed. Though, it would be a breaking change, because it changes the default binary serialization format in case of generics. People willing to proceed with the existing format will have to change their source code and enable the setting by hand. |
@romix Sorry for the late response, this week was very busy. I'm going to submit a PR with my comments / proposed changes against your branch. If you're already working on it please ping me now so that we don't do double work. Not sure if I'll have time for the benchmark as well, perhaps I'll submit a separate PR later against master. Making the non-optimized mode the default: this is my preference, as it should improve stability and reduce submitted issues. I'll ask on the mailing list for opinions, let's see if there's feedback. |
@magro Thanks a lot for your PR! |
c83161a
to
0f05362
Compare
@magro I force-pushed the new version of the patch. It includes all of your changes and my changes to avoid any hacks related to freezing of the Please check if everything is OK and we could merge this. |
@romix Sorry for the late response... Because optimization is off by default the commit message is wrong in this regard. Can you update it? The readme probably should also mention this setting, but I could write that later as well. |
… for enabling/disabling it. The existing optimization of generics serialization aims at reducing the size of the serialized representation. This optimization is enabled by default. But sometimes it may have a negative impact on performance. And sometimes it cannot handle complex cases of generics usage. This patch changes the default behavior and disables this this optimization. To enable it, simply invoke `FieldSerializerConfig.setOptimizedGenerics(true)`.
0f05362
to
9923d05
Compare
@magro Good catch! I updated the commit message. The readme could be updated later, when we roll out a new release. |
So it's done now, great work!! |
@magro Martin, I'm not sure that closing all those related issues is the right thing to do. I agree that with #433 they are not present in the non-generic-optimized mode. But they are still present when generic optimizations are enabled. Therefore, I'd suggest tagging them with "optimize-generics" or something like this, instead of closing. WDYT? |
@romix Sounds good! |
The existing optimization of generics serialization aims at reducing the size of the serialized representation. This optimization is enabled by default. But sometimes it may have a negative impact on performance. And sometimes it cannot handle complex cases of generics usage.
This patch changes the default behavior and disables this this optimization. To enable it, simply invoke
FieldSerializerConfig.setOptimizedGenerics(true)
.