Skip to content
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

Are there any microbenchmarks to check the performance impact against enabled the StrictNullChecks feature? #567

Closed
ryszardmakuch opened this issue May 23, 2022 · 3 comments
Labels

Comments

@ryszardmakuch
Copy link

ryszardmakuch commented May 23, 2022

I am considering enabling the StrictNullChecks feature in production. However, In the Javadoc I can see following statement:

Enabling it protects against this but has significant performance impact.

/**
* This feature represents whether to check deserialized collections.
*
* With this disabled, the default, collections which are typed to disallow null members (e.g. `List<String>`)
* may contain null values after deserialization.
* Enabling it protects against this but has significant performance impact.
*/
StrictNullChecks(enabledByDefault = false);

Are there any benchmarks to check the performance against the enabled and disabled feature? If not, would you like me to contribute the microbenchmark suite by creating a dedicated pull request?

I found that @k163377 used jmh to give you some numbers to prove significant improvement in deserialization speed #439 but those tests are not part of the jackson-module-kotlin project.

@k163377
Copy link
Contributor

k163377 commented Jan 18, 2023

The following benchmark was created for verification with jackson-module-kogera.
The content is to deserialize Array, List and Map into wrapper types with one argument each.
https://github.com/ProjectMapK/kogera-benchmark/blob/master/src/jmh/kotlin/org/wrongwrong/extra/deser/StrictNullChecks.kt

The results with jackson-module-kotlin are as follows(higher is better)

Benchmark                                           Mode  Cnt        Score         Error  Units
o.w.extra.deser.StrictNullChecks.array             thrpt    4   788631.252 ±   56981.231  ops/s
o.w.extra.deser.StrictNullChecks.arrayStrict       thrpt    4   665656.537 ±   33375.375  ops/s
o.w.extra.deser.StrictNullChecks.list              thrpt    4   844107.697 ±   53169.624  ops/s
o.w.extra.deser.StrictNullChecks.listStrict        thrpt    4   687755.266 ±   60128.550  ops/s
o.w.extra.deser.StrictNullChecks.map               thrpt    4   752715.970 ±   29195.905  ops/s
o.w.extra.deser.StrictNullChecks.mapStrict         thrpt    4   585182.025 ±   13587.045  ops/s

We can see a clear performance degradation even with only one argument deserialization.
Also, since the StrictNullChecks option checks all arguments regardless of type, if there is more arguments, the bigger the performance loss.


By the way, I found a way to significant improve the performance of strictNullChecks and I will share it.
ProjectMapK/jackson-module-kogera#44

@k163377
Copy link
Contributor

k163377 commented Jul 15, 2023

It is closed as a duplicate of #390.

@k163377 k163377 closed this as completed Jul 15, 2023
@k163377
Copy link
Contributor

k163377 commented Jul 17, 2023

It may be too late to confirm the impact on overall performance, but we have done so and will share it with you.
As a conclusion, the performance impact to anything other than Collection deserialization did not seem to be that significant.
https://github.com/ProjectMapK/kogera-benchmark#comparison-of-strictnullchecks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants