Performance tuning: replace AtomicInteger with AtomicIntegerFieldUpdater#4305
Conversation
|
If you're interested in the theory and benchmark, please refer to http://normanmaurer.me/blog/2013/10/28/Lesser-known-concurrent-classes-Part-1/ and the counterpart Chinese version is here: https://kezhenxu94.github.io/2020/01/30/Concurrent-classes-AtomicFieldUpdater/ I've also checked other classes using |
Motivation: Reduce unnecessary memory allocation in frequently used class. Modifications: Replace the `AtomicInteger` with `AtomicIntegerFieldUpdater` Result: We can save 4 bytes (for the reference to `AtomicInteger` itself) for each `TracingContext`, which saves credible memory in a high-concurrent agent service.
Codecov Report
@@ Coverage Diff @@
## master #4305 +/- ##
==========================================
+ Coverage 26.72% 26.83% +0.11%
==========================================
Files 1170 1170
Lines 25579 25577 -2
Branches 3655 3655
==========================================
+ Hits 6835 6863 +28
+ Misses 18133 18104 -29
+ Partials 611 610 -1
Continue to review full report at Codecov.
|
|
@kezhenxu94 I think you miss an important factor, in the Especially, CPU is affecting latency, response time and throughput more. |
@wu-sheng as you can see, the updater is |
Motivation:
Reduce unnecessary memory allocation in frequently used class.
Modifications:
Replace the
AtomicIntegerwithAtomicIntegerFieldUpdaterResult:
We can save 4 bytes (for the reference to
AtomicIntegeritself) for eachTracingContext, which saves credible memory in a high-concurrent agent service.