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

Improve strictNullChecks performance #44

Merged
merged 7 commits into from
Jan 18, 2023

Conversation

k163377
Copy link
Contributor

@k163377 k163377 commented Jan 18, 2023

In the existing, KotlinValueInstantiator handles strictNullChecks, but this has the following problems

  • Need to check the strictNullChecks flag for each argument
  • If the strictNullChecks flag is enabled, each argument needs to be checked for CollectionLike type
    • Need to check if the type argument is nullish even if it is CollectionLike type

Therefore, modified the strictNullChecks to be done by Converter so that these checks are done only once at initialization.
This change will result in a significant performance improvement when the strictNullChecks option is enabled and a minor performance improvement for all deserialization.

Benchmark results

Benchmarks were added to kogera-benchmark and compared to 00c2415.

00c2415

Benchmark                                           Mode  Cnt        Score        Error  Units
o.w.extra.deser.StrictNullChecks.array             thrpt    4   969583.316 ±  21035.196  ops/s
o.w.extra.deser.StrictNullChecks.arrayStrict       thrpt    4   886239.257 ±  76693.400  ops/s
o.w.extra.deser.StrictNullChecks.list              thrpt    4   996731.254 ±  68567.260  ops/s
o.w.extra.deser.StrictNullChecks.listStrict        thrpt    4   941384.034 ±  30972.582  ops/s
o.w.extra.deser.StrictNullChecks.map               thrpt    4   885877.492 ±  31031.104  ops/s
o.w.extra.deser.StrictNullChecks.mapStrict         thrpt    4   824988.874 ±  20915.560  ops/s

This PR

Benchmark                                           Mode  Cnt        Score        Error  Units
o.w.extra.deser.StrictNullChecks.array             thrpt    4   968999.635 ±  22231.973  ops/s
o.w.extra.deser.StrictNullChecks.arrayStrict       thrpt    4   921253.654 ±  25505.923  ops/s
o.w.extra.deser.StrictNullChecks.list              thrpt    4   989496.854 ±  32741.244  ops/s
o.w.extra.deser.StrictNullChecks.listStrict        thrpt    4   987504.414 ±  48033.178  ops/s
o.w.extra.deser.StrictNullChecks.map               thrpt    4   886742.960 ±  25096.656  ops/s
o.w.extra.deser.StrictNullChecks.mapStrict         thrpt    4   871995.858 ±  25538.408  ops/s

The results show a marked performance improvement when the strictNullChecks option is enabled.
Also, this benchmark is based on a single argument, and the improvement increases as the number of arguments increases.

Performance is improved by reducing flag checking during deserialization and checking whether a class is subject to StrictNullCheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant