feat(util): add ConcurrentHashtable with lock-free D1/D2 composite-key tables#11675
Draft
dougqh wants to merge 3 commits into
Draft
feat(util): add ConcurrentHashtable with lock-free D1/D2 composite-key tables#11675dougqh wants to merge 3 commits into
dougqh wants to merge 3 commits into
Conversation
…y tables Mirrors Hashtable's D1/D2 API with concurrent access guarantees: lock-free get via AtomicReferenceArray volatile reads, synchronized getOrCreate with double-checked re-read on miss. Eliminates composite key object allocation on hot read paths — the same structural advantage Hashtable.D2 has over HashMap<Pair<K1,K2>,V>, but thread-safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t class; add D2 benchmark Extract bucketIndex and forEach into ConcurrentHashtable.Support, mirroring the Hashtable.Support pattern. Add ConcurrentHashtableD2Benchmark comparing get and getOrCreate throughput against ConcurrentHashMap and ConcurrentSkipListMap. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Contributor
🟢 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. |
… ConcurrentHashtable Two gaps filled per-dimension (D1 and D2): - Chain collision: force multiple entries into the same bucket (CollidingKey with fixed hashCode for D1; pigeonhole via 2-bucket table for D2) and verify all entries are reachable after concurrent inserts. - Concurrent distinct keys: 16 threads each insert a unique key simultaneously, verifying final size and that every key is retrievable — exercises concurrent inserts to different buckets, which the single-shared-key test does not cover. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConcurrentHashtablewithD1(single-key) andD2(composite-key) inner classes, mirroring theHashtableAPI with concurrent access guaranteesget/getOrCreatefast path viaAtomicReferenceArrayvolatile bucket reads; synchronized only on miss with double-checked re-read under lockbucketIndex,forEach) extracted intoConcurrentHashtable.Support, following theHashtable.SupportpatternD2.get(K1, K2)andD2.getOrCreate(K1, K2, creator)accept key parts directly — no composite key object allocated for the lookup, unlikeConcurrentHashMap<Pair<K1,K2>, V>where EA must conservatively treat the key as escaping even on hits (ownership-transfer contract)ConcurrentHashtableD1TestandConcurrentHashtableD2Test(JUnit 5), including a concurrency correctness test verifying exactly one entry is created under 16 racing threadsConcurrentHashtableD2BenchmarkcomparinggetandgetOrCreatethroughput againstConcurrentHashMapandConcurrentSkipListMapwith sharedScope.Benchmarkstate (all threads hitting the same table)Test plan
./gradlew :internal-api:test --tests "datadog.trace.util.ConcurrentHashtable*"— all tests pass./gradlew :internal-api:jmhCompileGeneratedClasses— benchmark compiles cleanConcurrentHashtableD2Benchmarklocally to validate get/getOrCreate throughput advantage over CHM and CSLM🤖 Generated with Claude Code