Shard GlobalObjectStore to reduce potential cross-store contention - #117
Conversation
Split the single global store into 8 fibonacci-hashed shards, each with their own independent capacity limits and ageing state, so unrelated stores are much less likely to contend on the same locks/maps. Add ObjectStoreContentionBenchmark to verify isolated stores aren't slowed by load on unrelated shards.
|
@DataDog review |
|
@DataDog review |
There was a problem hiding this comment.
More details
Each store ID selects one stable shard. The shard keeps the old lookup, update, aging, and stale-entry removal behavior.
🤖 Datadog Autotest · Commit b8b5aca · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
🟡 Changes recommended
The new per-shard capacity lifecycle is not adequately tested.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Shards GlobalObjectStore to reduce contention while preserving its global API.
Changes:
- Adds eight Fibonacci-hashed shards with independent capacity and ageing.
- Adds shard-distribution tests and a contention benchmark.
- Updates occupancy benchmarking for aggregate capacity.
File summaries
| File | Description |
|---|---|
field-inject/src/test/java/datadog/instrument/fieldinject/ObjectStoreShardingTest.java |
Tests store-ID distribution across shards. |
field-inject/src/main/java/datadog/instrument/fieldinject/GlobalObjectStore.java |
Implements sharding and per-shard lifecycle management; shard capacity testing needs updating. |
field-inject/src/jmh/java/datadog/instrument/fieldinject/ObjectStoreContentionBenchmark.java |
Benchmarks cross-store contention; shard-selection documentation needs correction. |
field-inject/src/jmh/java/datadog/instrument/fieldinject/ObjectStoreBenchmark.java |
Updates capacity scenarios and store distribution; outdated low-bit behavior documentation remains. |
Review details
Suppressed comments (1)
field-inject/src/jmh/java/datadog/instrument/fieldinject/ObjectStoreContentionBenchmark.java:37
- Value-type diversity also spreads store IDs now: the value type occupies the upper 16 bits, and
shard(int)mixes all bits before selecting a shard. This statement also contradicts the newsharedKeyTypeWithManyValueTypesSpreadsAcrossShardstest.
* <p>The contended pool uses a distinct key type per store, matching real usage where key-type
* diversity (not value-type diversity) is what spreads store-ids across shards.
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment has been minimized.
This comment has been minimized.
b77763d to
4cc01a7
Compare
4cc01a7 to
e8edd59
Compare
amarziali
left a comment
There was a problem hiding this comment.
the approach sounds good to me. thanks for the improvement
What Does This Do
Split the single global store into 8 fibonacci-hashed shards, each with their own independent capacity limits and ageing state, so unrelated stores are much less likely to contend on the same locks/maps.
Switched size sampling to take a probabilistic approach to be more shard-friendly. The rate was chosen to provide a balance between under/over sampling given the different thresholds. The periodic cleanup will still refresh sizes as before.
Add
ObjectStoreContentionBenchmarkto verify isolated stores aren't slowed by load on unrelated shards.Motivation
Reduce potential cross-store contention without needing to make everything per-store.
Also maintains the simpler global store API.
Contributor Checklist
Jira ticket: [PROJ-IDENT]