Replace ThreadPoolExecutor context-store with ClassValue cache - #12105
Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR updates the Java-concurrent ThreadPoolExecutor instrumentation to stop using a ContextStore<ThreadPoolExecutor, Boolean> for a per-executor “propagate?” flag, and instead uses a ClassValue<Boolean> cache keyed by executor class to better fit AOT scenarios where context-stores may fall back to global weak-maps.
Changes:
- Removed the
ThreadPoolExecutor -> Booleancontext-store entry and the constructor advice that populated it. - Added a
ClassValue<Boolean>(PROPAGATE) inTPEHelperand switched advice sites to callTPEHelper.shouldPropagate(tpe)directly. - Simplified
ThreadPoolExecutorInstrumentationto no longer depend onPlatform/ constructor instrumentation for propagation decisions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dd-java-agent/instrumentation/java/java-concurrent/java-concurrent-1.8/src/main/java/datadog/trace/instrumentation/java/concurrent/executor/ThreadPoolExecutorInstrumentation.java | Removes constructor advice + switches propagation checks to TPEHelper.shouldPropagate(tpe) |
| dd-java-agent/instrumentation/java/java-concurrent/java-concurrent-1.8/src/main/java/datadog/trace/instrumentation/java/concurrent/executor/ExecutorModule.java | Drops the ThreadPoolExecutor -> Boolean context-store mapping |
| dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/TPEHelper.java | Replaces per-instance context-store flagging with a ClassValue<Boolean> cache |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6515e4b02b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
🎯 Code Coverage (details) 🔗 Commit SHA: 585e962 | Docs | Datadog PR Page | Give us feedback! |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
The flag being stored in the TPE context-store is constant, based on whether the class is listed in the 'excludedClasses' set provided via static config. This is better suited to being stored as a ClassValue, especially for AOT scenarios where context-stores are more likely to use the global weak-map.
6515e4b to
585e962
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
More details
The ClassValue replacement preserves the previous exact executor-class exclusion decision while removing per-executor context-store state, and native-image build-time propagation remains disabled. Existing tests cover the meaningful propagation, exclusion, custom-subclass, cancellation, and legacy-mode paths; execution was blocked by the unavailable Java 25 toolchain.
🤖 Datadog Autotest · Commit 585e962 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
PerfectSlayer
left a comment
There was a problem hiding this comment.
Looking good, thanks!
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
Motivation
The flag being stored in the TPE context-store is constant, based on whether the class is listed in the 'excludedClasses' set provided via static config. This is better suited to being stored as a ClassValue, especially for AOT scenarios where context-stores are more likely to use the global weak-map.
Additional Notes
Found while looking into #10479
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]