- Notifications
You must be signed in to change notification settings - Fork 314
Simplify InstanceStore implementation to use simple, synchronized HashMaps #9739
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
5188fd4
to 3fea6c3
Compare 🎯 Code Coverage 🔗 Commit SHA: 08f91e1 | Docs | Was this helpful? Give us feedback! |
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 59 metrics, 6 unstable metrics. Startup time reports for insecure-bankgantt title insecure-bank - global startup overhead: candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section tracing Agent [baseline] (1.017 s) : 0, 1016622 Total [baseline] (8.677 s) : 0, 8677126 Agent [candidate] (1.039 s) : 0, 1039342 Total [candidate] (8.685 s) : 0, 8685473 section iast Agent [baseline] (1.16 s) : 0, 1159861 Total [baseline] (9.313 s) : 0, 9312627 Agent [candidate] (1.15 s) : 0, 1149883 Total [candidate] (9.261 s) : 0, 9261249
gantt title insecure-bank - break down per module: candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section tracing crashtracking [baseline] (1.472 ms) : 0, 1472 crashtracking [candidate] (1.497 ms) : 0, 1497 BytebuddyAgent [baseline] (692.329 ms) : 0, 692329 BytebuddyAgent [candidate] (708.616 ms) : 0, 708616 GlobalTracer [baseline] (241.661 ms) : 0, 241661 GlobalTracer [candidate] (246.079 ms) : 0, 246079 AppSec [baseline] (32.755 ms) : 0, 32755 AppSec [candidate] (33.181 ms) : 0, 33181 Debugger [baseline] (6.435 ms) : 0, 6435 Debugger [candidate] (6.586 ms) : 0, 6586 Remote Config [baseline] (702.192 µs) : 0, 702 Remote Config [candidate] (709.215 µs) : 0, 709 Telemetry [baseline] (9.295 ms) : 0, 9295 Telemetry [candidate] (9.373 ms) : 0, 9373 Flare Poller [baseline] (10.916 ms) : 0, 10916 Flare Poller [candidate] (11.814 ms) : 0, 11814 section iast crashtracking [baseline] (1.498 ms) : 0, 1498 crashtracking [candidate] (1.47 ms) : 0, 1470 BytebuddyAgent [baseline] (823.083 ms) : 0, 823083 BytebuddyAgent [candidate] (814.787 ms) : 0, 814787 GlobalTracer [baseline] (232.341 ms) : 0, 232341 GlobalTracer [candidate] (230.973 ms) : 0, 230973 IAST [baseline] (26.576 ms) : 0, 26576 IAST [candidate] (26.701 ms) : 0, 26701 AppSec [baseline] (34.981 ms) : 0, 34981 AppSec [candidate] (34.748 ms) : 0, 34748 Debugger [baseline] (6.156 ms) : 0, 6156 Debugger [candidate] (6.135 ms) : 0, 6135 Remote Config [baseline] (619.781 µs) : 0, 620 Remote Config [candidate] (606.02 µs) : 0, 606 Telemetry [baseline] (8.747 ms) : 0, 8747 Telemetry [candidate] (8.708 ms) : 0, 8708 Flare Poller [baseline] (4.258 ms) : 0, 4258 Flare Poller [candidate] (4.214 ms) : 0, 4214 Startup time reports for petclinicgantt title petclinic - global startup overhead: candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section tracing Agent [baseline] (1.02 s) : 0, 1020471 Total [baseline] (10.789 s) : 0, 10788548 Agent [candidate] (1.024 s) : 0, 1024492 Total [candidate] (10.724 s) : 0, 10724496 section appsec Agent [baseline] (1.201 s) : 0, 1201362 Total [baseline] (11.075 s) : 0, 11074840 Agent [candidate] (1.201 s) : 0, 1200827 Total [candidate] (11.047 s) : 0, 11046645 section iast Agent [baseline] (1.153 s) : 0, 1153313 Total [baseline] (11.124 s) : 0, 11124077 Agent [candidate] (1.162 s) : 0, 1161922 Total [candidate] (11.026 s) : 0, 11025711 section profiling Agent [baseline] (1.158 s) : 0, 1158077 Total [baseline] (11.055 s) : 0, 11055055 Agent [candidate] (1.172 s) : 0, 1171512 Total [candidate] (11.093 s) : 0, 11093094
gantt title petclinic - break down per module: candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section tracing crashtracking [baseline] (1.458 ms) : 0, 1458 crashtracking [candidate] (1.454 ms) : 0, 1454 BytebuddyAgent [baseline] (696.849 ms) : 0, 696849 BytebuddyAgent [candidate] (698.728 ms) : 0, 698728 GlobalTracer [baseline] (241.807 ms) : 0, 241807 GlobalTracer [candidate] (243.214 ms) : 0, 243214 AppSec [baseline] (32.404 ms) : 0, 32404 AppSec [candidate] (32.43 ms) : 0, 32430 Debugger [baseline] (6.426 ms) : 0, 6426 Debugger [candidate] (6.535 ms) : 0, 6535 Remote Config [baseline] (717.114 µs) : 0, 717 Remote Config [candidate] (710.126 µs) : 0, 710 Telemetry [baseline] (9.33 ms) : 0, 9330 Telemetry [candidate] (9.368 ms) : 0, 9368 Flare Poller [baseline] (10.226 ms) : 0, 10226 Flare Poller [candidate] (10.783 ms) : 0, 10783 section appsec crashtracking [baseline] (1.459 ms) : 0, 1459 crashtracking [candidate] (1.476 ms) : 0, 1476 BytebuddyAgent [baseline] (723.887 ms) : 0, 723887 BytebuddyAgent [candidate] (722.146 ms) : 0, 722146 GlobalTracer [baseline] (236.144 ms) : 0, 236144 GlobalTracer [candidate] (236.136 ms) : 0, 236136 IAST [baseline] (24.646 ms) : 0, 24646 IAST [candidate] (24.97 ms) : 0, 24970 AppSec [baseline] (174.694 ms) : 0, 174694 AppSec [candidate] (175.673 ms) : 0, 175673 Debugger [baseline] (6.147 ms) : 0, 6147 Debugger [candidate] (6.112 ms) : 0, 6112 Remote Config [baseline] (628.19 µs) : 0, 628 Remote Config [candidate] (628.025 µs) : 0, 628 Telemetry [baseline] (8.57 ms) : 0, 8570 Telemetry [candidate] (8.502 ms) : 0, 8502 Flare Poller [baseline] (3.976 ms) : 0, 3976 Flare Poller [candidate] (3.968 ms) : 0, 3968 section iast crashtracking [baseline] (1.471 ms) : 0, 1471 crashtracking [candidate] (1.456 ms) : 0, 1456 BytebuddyAgent [baseline] (816.867 ms) : 0, 816867 BytebuddyAgent [candidate] (822.24 ms) : 0, 822240 GlobalTracer [baseline] (231.823 ms) : 0, 231823 GlobalTracer [candidate] (233.883 ms) : 0, 233883 IAST [baseline] (26.765 ms) : 0, 26765 IAST [candidate] (27.126 ms) : 0, 27126 AppSec [baseline] (35.075 ms) : 0, 35075 AppSec [candidate] (35.549 ms) : 0, 35549 Debugger [baseline] (6.146 ms) : 0, 6146 Debugger [candidate] (6.246 ms) : 0, 6246 Remote Config [baseline] (626.999 µs) : 0, 627 Remote Config [candidate] (624.404 µs) : 0, 624 Telemetry [baseline] (8.69 ms) : 0, 8690 Telemetry [candidate] (8.855 ms) : 0, 8855 Flare Poller [baseline] (4.308 ms) : 0, 4308 Flare Poller [candidate] (4.285 ms) : 0, 4285 section profiling crashtracking [baseline] (1.427 ms) : 0, 1427 crashtracking [candidate] (1.435 ms) : 0, 1435 BytebuddyAgent [baseline] (719.678 ms) : 0, 719678 BytebuddyAgent [candidate] (726.908 ms) : 0, 726908 GlobalTracer [baseline] (216.919 ms) : 0, 216919 GlobalTracer [candidate] (219.277 ms) : 0, 219277 AppSec [baseline] (32.204 ms) : 0, 32204 AppSec [candidate] (32.584 ms) : 0, 32584 Debugger [baseline] (6.459 ms) : 0, 6459 Debugger [candidate] (7.333 ms) : 0, 7333 Remote Config [baseline] (750.898 µs) : 0, 751 Remote Config [candidate] (837.244 µs) : 0, 837 Telemetry [baseline] (16.03 ms) : 0, 16030 Telemetry [candidate] (15.536 ms) : 0, 15536 Flare Poller [baseline] (4.163 ms) : 0, 4163 Flare Poller [candidate] (4.225 ms) : 0, 4225 ProfilingAgent [baseline] (107.506 ms) : 0, 107506 ProfilingAgent [candidate] (109.792 ms) : 0, 109792 Profiling [baseline] (108.646 ms) : 0, 108646 Profiling [candidate] (111.056 ms) : 0, 111056 LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 2 performance regressions! Performance is the same for 8 metrics, 12 unstable metrics.
Request duration reports for insecure-bankgantt title insecure-bank - request duration [CI 0.99] : candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section baseline no_agent (4.42 ms) : 4369, 4472 . : milestone, 4420, iast (9.667 ms) : 9503, 9830 . : milestone, 9667, iast_FULL (14.407 ms) : 14118, 14696 . : milestone, 14407, iast_GLOBAL (10.879 ms) : 10684, 11074 . : milestone, 10879, profiling (8.793 ms) : 8658, 8928 . : milestone, 8793, tracing (7.956 ms) : 7830, 8081 . : milestone, 7956, section candidate no_agent (4.313 ms) : 4264, 4362 . : milestone, 4313, iast (10.049 ms) : 9881, 10216 . : milestone, 10049, iast_FULL (13.904 ms) : 13632, 14175 . : milestone, 13904, iast_GLOBAL (10.731 ms) : 10529, 10934 . : milestone, 10731, profiling (9.076 ms) : 8939, 9212 . : milestone, 9076, tracing (7.67 ms) : 7562, 7778 . : milestone, 7670,
Request duration reports for petclinicgantt title petclinic - request duration [CI 0.99] : candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section baseline no_agent (36.052 ms) : 35760, 36343 . : milestone, 36052, appsec (49.705 ms) : 49266, 50143 . : milestone, 49705, code_origins (43.466 ms) : 43098, 43834 . : milestone, 43466, iast (45.992 ms) : 45580, 46404 . : milestone, 45992, profiling (49.764 ms) : 49294, 50234 . : milestone, 49764, tracing (44.863 ms) : 44484, 45242 . : milestone, 44863, section candidate no_agent (37.548 ms) : 37253, 37842 . : milestone, 37548, appsec (48.245 ms) : 47836, 48655 . : milestone, 48245, code_origins (44.251 ms) : 43868, 44634 . : milestone, 44251, iast (45.138 ms) : 44750, 45525 . : milestone, 45138, profiling (49.63 ms) : 49129, 50130 . : milestone, 49630, tracing (44.43 ms) : 44058, 44803 . : milestone, 44430,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt title tomcat - execution time [CI 0.99] : candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section baseline no_agent (1.471 ms) : 1459, 1482 . : milestone, 1471, appsec (3.658 ms) : 3444, 3873 . : milestone, 3658, iast (2.203 ms) : 2140, 2267 . : milestone, 2203, iast_GLOBAL (2.25 ms) : 2186, 2314 . : milestone, 2250, profiling (2.066 ms) : 2013, 2118 . : milestone, 2066, tracing (2.02 ms) : 1971, 2070 . : milestone, 2020, section candidate no_agent (1.472 ms) : 1460, 1483 . : milestone, 1472, appsec (3.632 ms) : 3419, 3845 . : milestone, 3632, iast (2.2 ms) : 2136, 2263 . : milestone, 2200, iast_GLOBAL (2.252 ms) : 2187, 2316 . : milestone, 2252, profiling (2.047 ms) : 1996, 2099 . : milestone, 2047, tracing (2.025 ms) : 1976, 2075 . : milestone, 2025,
Execution time for biojavagantt title biojava - execution time [CI 0.99] : candidate=1.55.0-SNAPSHOT~08f91e1dfa, baseline=1.55.0-SNAPSHOT~6dc3f85c93 dateFormat X axisFormat %s section baseline no_agent (14.959 s) : 14959000, 14959000 . : milestone, 14959000, appsec (15.286 s) : 15286000, 15286000 . : milestone, 15286000, iast (18.688 s) : 18688000, 18688000 . : milestone, 18688000, iast_GLOBAL (17.999 s) : 17999000, 17999000 . : milestone, 17999000, profiling (15.372 s) : 15372000, 15372000 . : milestone, 15372000, tracing (15.064 s) : 15064000, 15064000 . : milestone, 15064000, section candidate no_agent (15.508 s) : 15508000, 15508000 . : milestone, 15508000, appsec (14.946 s) : 14946000, 14946000 . : milestone, 14946000, iast (18.679 s) : 18679000, 18679000 . : milestone, 18679000, iast_GLOBAL (17.763 s) : 17763000, 17763000 . : milestone, 17763000, profiling (15.427 s) : 15427000, 15427000 . : milestone, 15427000, tracing (15.211 s) : 15211000, 15211000 . : milestone, 15211000,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ question: The new implementation ends up looking very similar to @nikita-tkachenko-datadog ConcurrentHashMapContextStore
-- the underlying map being ConcurrentHashMap
instead of Collections.synchronizedMap(new HashMap<>())
Would there be a way to keep only one of them?
They serve two different use-cases - attempting to merge them would introduce an undesirable coupling and limit how they could evolve going forwards. |
3fea6c3
to b45eca2
Compare …hMaps The keys used to lookup instances are always string literals, bounded in code by a fixed number of calls. These keys are never collected, so we don't need to use a weak map. The instance store is accessed when setting up helpers to guarantee the same instance is used by different instrumentations sharing a common type (via their parent class-loader.) Therefore each store just needs basic synchronization to guarantee it only creates one instance per-key.
b45eca2
to 08f91e1
Compare
Motivation
The keys used to lookup instances are always string literals, bounded in code by a fixed number of calls. These keys are never collected, so we don't need to use a weak map. The instance store is accessed when setting up helpers to guarantee the same instance is used by different instrumentations sharing a common type (via their parent class-loader.) Therefore each store just needs basic synchronization to guarantee it only creates one instance per-key.
Additional Notes
Making this change reduces the places we (indirectly) use
com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap
Note that each instance store is maintained as a
ClassValue
of the class being implemented / extended.Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any useful labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]