Repository navigation
Conversation
Pull request dashboard statusWaiting on reviewers · refreshed 2026-12-02 13:08 UTC Review the latest changes. Status above doesn't look right?
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9088 +/- ##
============================================
- Coverage 90.54% 90.53% -0.01%
+ Complexity 11254 11253 -1
============================================
Files 1040 1040
Lines 30703 30703
Branches 4015 4015
============================================
- Hits 27799 27796 -3
Misses 1928 1928
- Partials 976 979 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This is the first stage of work for supporting thread context sharing in the Java SDK. Read OTEP-4947 for background if you haven't yet. This PR's code is deliberately incomplete, in order to keep the discussion focussed. Later steps will open the jumbo size can of worms that is building and packaging native code for multiple architectures, as well as the equally large one that is wiring and configuration, which the OTEP doesn't specify and probably should. Meanwhile there is still plenty to talk about... This code is intended for use in environments where the SDK's ThreadLocalContextStorage is currently used, and is a drop in replacement for it. EXCEPT: it won't work with virtual threads, unless the JDK's vthread mount/unmount is patched to support it. That's out of scope at present, but achievable by the bytecode rewriting agent. It's mentioned here to address the question of if this code belongs in the SDK repo, or in the instrumentation repo. Support for reactive (thread per core) context is also out of scope, but that's true for the SDK in general too. This code also shamelessly duplicates much of ThreadLocalContextStorage, largely to avoid having to patch the existing code in a way that would change its dependencies or performance. However, it's written with an eye on the possibility of eventually merging thread context support into ThreadLocalContextStorage as it matures and use becomes more widespread. This code uses panama FFM to access C TLS ('thread_local'), which isn't possible through a pure Java API. yes, it could use JNI instead. However, thread context relies on process context, which is also panama based. yes, this means the whole thing is Java 25+ only. It doesn't have to be and the main reason it is boils down to: we just don't want to maintain JNI code. That said, it also uses Unsafe. What's up with that? Panama has a safe (well, less unsafe) API for working with native memory. Process Context uses it. yet here we don't. This is purely a performance choice: unlike process context, this code is on the critical path and Unsafe is a lot quicker than panama's Arena/Segment model for this use case. There are remaining nits in the build system: There are remaining nits in the APIs used for integration: From the perspective of providing a fully functional implementation of the OTEP, this PR would have to be considered draft - it frankly doesn't do anything useful by itself. However, I'm offering it as a self-contained step on the path, on the basis that the review will touch on distinct aspects, and involve different stake holders to, that of other steps such as the CI and security steps for building and distributing native binaries. |
No description provided.