Skip to content

Shard GlobalObjectStore to reduce potential cross-store contention - #117

Merged
mcculls merged 3 commits into
mainfrom
mcculls/shard-objectstore
Sep 9, 2026
Merged

Shard GlobalObjectStore to reduce potential cross-store contention#117
mcculls merged 3 commits into
mainfrom
mcculls/shard-objectstore

Conversation

@mcculls

@mcculls mcculls commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

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 ObjectStoreContentionBenchmark to 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]

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.
@mcculls

mcculls commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

@DataDog review

datadog-prod-us1-5[bot]

This comment was marked as outdated.

@mcculls

mcculls commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

@DataDog review

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

Each store ID selects one stable shard. The shard keeps the old lookup, update, aging, and stale-entry removal behavior.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit b8b5aca · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 new sharedKeyTypeWithManyValueTypesSpreadsAcrossShards test.
 * <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.

Comment thread field-inject/src/main/java/datadog/instrument/fieldinject/GlobalObjectStore.java Outdated
@datadog-prod-us1-5

This comment has been minimized.

@mcculls
mcculls force-pushed the mcculls/shard-objectstore branch 4 times, most recently from b77763d to 4cc01a7 Compare September 9, 2026 11:48
@mcculls
mcculls force-pushed the mcculls/shard-objectstore branch from 4cc01a7 to e8edd59 Compare September 9, 2026 11:49
@mcculls
mcculls marked this pull request as ready for review September 9, 2026 11:54
@mcculls
mcculls requested a review from a team as a code owner September 9, 2026 11:54
@mcculls
mcculls requested review from amarziali and bric3 and removed request for a team September 9, 2026 11:54

@amarziali amarziali left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the approach sounds good to me. thanks for the improvement

@mcculls
mcculls merged commit 8967ad8 into main Sep 9, 2026
6 checks passed
@mcculls
mcculls deleted the mcculls/shard-objectstore branch September 9, 2026 14:56
@github-actions github-actions Bot added this to the 0.1.0 milestone Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants