Skip to content

DATACMNS-1706 - Improve PreferredConstructor isConstructorParameter bottleneck #437

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

Conversation

mhyeon-lee
Copy link
Contributor

@mhyeon-lee mhyeon-lee commented Apr 20, 2020

resolves DATACMNS-1706

performance test: mhyeon-lee#1

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our JIRA.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@mhyeon-lee mhyeon-lee force-pushed the datacmns-1706-improvement-preferred-constructor-bottleneck branch from 930c28f to 2e563ca Compare April 20, 2020 05:58
@mhyeon-lee mhyeon-lee changed the title [DATA-1706] Improve PreferredConstructor isConstructorParameter bottleneck DATA-1706 - Improve PreferredConstructor isConstructorParameter bottleneck Apr 20, 2020
@mhyeon-lee mhyeon-lee changed the title DATA-1706 - Improve PreferredConstructor isConstructorParameter bottleneck DATACMNS-1706 - Improve PreferredConstructor isConstructorParameter bottleneck Apr 20, 2020
@mhyeon-lee mhyeon-lee force-pushed the datacmns-1706-improvement-preferred-constructor-bottleneck branch from 2e563ca to 5027c98 Compare May 15, 2020 08:40
@mhyeon-lee
Copy link
Contributor Author

Benchmark result (mhyeon-lee#1)

# JMH version: 1.23
# VM version: JDK 1.8.0_192, Java HotSpot(TM) 64-Bit Server VM, 25.192-b12
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre/bin/java
# VM options: -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50049:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
# Warmup: 3 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1000 threads, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMap

# Run progress: 0.00% complete, ETA 00:04:00
# Fork: 1 of 1
# Warmup Iteration   1: 5.579 ±(99.9%) 0.077 ms/op
# Warmup Iteration   2: 5.463 ±(99.9%) 0.067 ms/op
# Warmup Iteration   3: 5.516 ±(99.9%) 0.091 ms/op
Iteration   1: 5.264 ±(99.9%) 0.088 ms/op
Iteration   2: 5.164 ±(99.9%) 0.068 ms/op
Iteration   3: 5.239 ±(99.9%) 0.076 ms/op
Iteration   4: 5.221 ±(99.9%) 0.081 ms/op
Iteration   5: 5.252 ±(99.9%) 0.071 ms/op


Result "org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMap":
  5.228 ±(99.9%) 0.151 ms/op [Average]
  (min, avg, max) = (5.164, 5.228, 5.264), stdev = 0.039
  CI (99.9%): [5.077, 5.379] (assumes normal distribution)


# JMH version: 1.23
# VM version: JDK 1.8.0_192, Java HotSpot(TM) 64-Bit Server VM, 25.192-b12
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre/bin/java
# VM options: -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50049:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
# Warmup: 3 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1000 threads, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMapComputeIfAbsent

# Run progress: 33.33% complete, ETA 00:04:15
# Fork: 1 of 1
# Warmup Iteration   1: 106.450 ±(99.9%) 1.274 ms/op
# Warmup Iteration   2: 104.555 ±(99.9%) 1.336 ms/op
# Warmup Iteration   3: 99.112 ±(99.9%) 1.187 ms/op
Iteration   1: 98.715 ±(99.9%) 1.255 ms/op
Iteration   2: 98.676 ±(99.9%) 1.275 ms/op
Iteration   3: 99.171 ±(99.9%) 1.296 ms/op
Iteration   4: 100.556 ±(99.9%) 1.312 ms/op
Iteration   5: 100.264 ±(99.9%) 1.322 ms/op


Result "org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMapComputeIfAbsent":
  99.477 ±(99.9%) 3.389 ms/op [Average]
  (min, avg, max) = (98.676, 99.477, 100.556), stdev = 0.880
  CI (99.9%): [96.088, 102.866] (assumes normal distribution)


# JMH version: 1.23
# VM version: JDK 1.8.0_192, Java HotSpot(TM) 64-Bit Server VM, 25.192-b12
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre/bin/java
# VM options: -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50049:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
# Warmup: 3 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1000 threads, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterReadLock

# Run progress: 66.67% complete, ETA 00:01:46
# Fork: 1 of 1
# Warmup Iteration   1: 716.457 ±(99.9%) 5.951 ms/op
# Warmup Iteration   2: 742.832 ±(99.9%) 5.665 ms/op
# Warmup Iteration   3: 745.476 ±(99.9%) 6.553 ms/op
Iteration   1: 753.153 ±(99.9%) 8.694 ms/op
Iteration   2: 742.263 ±(99.9%) 10.983 ms/op
Iteration   3: 774.202 ±(99.9%) 11.523 ms/op
Iteration   4: 751.586 ±(99.9%) 10.356 ms/op
Iteration   5: 751.131 ±(99.9%) 10.890 ms/op


Result "org.springframework.data.mapping.PreferredConstructorPerformanceTests.isConstructorParameterReadLock":
  754.467 ±(99.9%) 45.543 ms/op [Average]
  (min, avg, max) = (742.263, 754.467, 774.202), stdev = 11.827
  CI (99.9%): [708.924, 800.010] (assumes normal distribution)


# Run complete. Total time: 00:05:33

REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
experiments, perform baseline and negative tests that provide experimental control, make sure
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
Do not assume the numbers tell you what you want them to tell.

Benchmark                                                                                    Mode  Cnt    Score    Error  Units
PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMap                 avgt    5    5.228 ±  0.151  ms/op
PreferredConstructorPerformanceTests.isConstructorParameterConcurrentHashMapComputeIfAbsent  avgt    5   99.477 ±  3.389  ms/op
PreferredConstructorPerformanceTests.isConstructorParameterReadLock                          avgt    5  754.467 ± 45.543  ms/op

mp911de pushed a commit that referenced this pull request May 26, 2020
…Parameter.

Switch property parameter cache from HashMap and external locks to ConcurrentHashMap to improve multi-threaded locking behavior during isConstructorParameter(…) initialization.

Original pull request: #437.
mp911de added a commit that referenced this pull request May 26, 2020
Improve Javadoc.

Original pull request: #437.
mp911de pushed a commit that referenced this pull request May 26, 2020
…Parameter.

Switch property parameter cache from HashMap and external locks to ConcurrentHashMap to improve multi-threaded locking behavior during isConstructorParameter(…) initialization.

Original pull request: #437.
mp911de added a commit that referenced this pull request May 26, 2020
Improve Javadoc.

Original pull request: #437.
@mp911de
Copy link
Member

mp911de commented May 26, 2020

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this May 26, 2020
mp911de pushed a commit that referenced this pull request May 26, 2020
…Parameter.

Switch property parameter cache from HashMap and external locks to ConcurrentHashMap to improve multi-threaded locking behavior during isConstructorParameter(…) initialization.

Original pull request: #437.
mp911de added a commit that referenced this pull request May 26, 2020
Improve Javadoc.

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

2 participants