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

DATACMNS-1366 - Performance optimizations. #305

Closed
wants to merge 5 commits into from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Aug 15, 2018

Various optimizations to improve CPU and memory consumption.

Baseline

Benchmark                                                                                       Mode  Cnt        Score         Error  Units
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10  5899638,348 ±   53829,186  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10  2690653,960 ±   12988,854  ops/s
TypicalEntityReaderBenchmark.simpleEntityConstructorArgsCreation                               thrpt   10  4741691,355 ±   20735,714  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10  7749539,715 ± 1845318,977  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10  7859653,071 ±  195289,752  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10  4163905,432 ±  107432,148  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10  7437671,460 ±   96405,066  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10  6911496,323 ±   64707,708  ops/s

After optimizations

Benchmark                                                                                       Mode  Cnt        Score        Error  Units
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10  6676400,185 ±  45164,682  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10  2981338,468 ±  36943,754  ops/s
TypicalEntityReaderBenchmark.simpleEntityConstructorArgsCreation                               thrpt   10  4445213,022 ±  73618,043  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10  8814664,064 ±  70241,114  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10  7832454,991 ± 118872,563  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10  4564509,834 ±  38466,637  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10  8281840,412 ±  58915,514  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10  7326248,088 ±  33168,993  ops/s

Related tickets: DATACMNS-1366, DATACMNS-1366.

Use HashMap and Weak references to improve memory and CPU profile.

After the change:

Benchmark                                                                                       Mode  Cnt        Score        Error  Units
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10  6854944,543 ±  42529,071  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10  2793714,016 ±  98796,277  ops/s
TypicalEntityReaderBenchmark.simpleEntityConstructorArgsCreation                               thrpt   10  4439036,009 ±  30217,601  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10  8271521,172 ±  36635,054  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10  7697887,405 ± 249506,083  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10  7909853,463 ±  66718,892  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10  7183844,376 ±  98420,044  ops/s
…tentEntity.iterator().

After the change:

Benchmark                                                                                       Mode  Cnt        Score        Error  Units
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10  6825203,167 ± 164389,990  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10  2901606,524 ±  17283,276  ops/s
TypicalEntityReaderBenchmark.simpleEntityConstructorArgsCreation                               thrpt   10  4819899,390 ±  18690,841  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10  8621389,713 ±  52273,537  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10  9447210,484 ±  63331,428  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10  8533150,231 ±  56215,975  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10  6872518,604 ±  74019,461  ops/s
…d Reference.

After the change:

Benchmark                                                                                       Mode  Cnt        Score        Error  Units
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10  6676400,185 ±  45164,682  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10  2981338,468 ±  36943,754  ops/s
TypicalEntityReaderBenchmark.simpleEntityConstructorArgsCreation                               thrpt   10  4445213,022 ±  73618,043  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10  8814664,064 ±  70241,114  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10  7832454,991 ± 118872,563  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10  4564509,834 ±  38466,637  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10  8281840,412 ±  58915,514  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10  7326248,088 ±  33168,993  ops/s
…uals(…).

We now check for type variable emptiness to avoid Map iterator creation in Map.equals().
odrotbohm pushed a commit that referenced this pull request Aug 15, 2018
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…).

Original pull request: #305.
odrotbohm pushed a commit that referenced this pull request Aug 15, 2018
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…).

Original pull request: #305.
@odrotbohm odrotbohm closed this Aug 15, 2018
@odrotbohm odrotbohm deleted the issue/DATACMNS-1366 branch August 15, 2018 12:14
odrotbohm pushed a commit that referenced this pull request Aug 15, 2018
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…).

Original pull request: #305.
odrotbohm pushed a commit that referenced this pull request Aug 15, 2018
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…).

Original pull request: #305.
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

2 participants