Skip to content

Reduce GlobalObjectStore contention by sampling underlying map size - #116

Merged
mcculls merged 1 commit into
mainfrom
mcculls/sample-objectstore-map-size
Sep 7, 2026
Merged

Reduce GlobalObjectStore contention by sampling underlying map size#116
mcculls merged 1 commit into
mainfrom
mcculls/sample-objectstore-map-size

Conversation

@mcculls

@mcculls mcculls commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

What Does This Do

Reduce GlobalObjectStore contention by sampling underlying map size periodically, rather on every write

Motivation

ConcurrentHashMap.size() must sum counts across the different buckets which - we don't need to do this on every write, instead we track how many times the thread missed lookups and fell-through to use a store key. We then use this to decide when to sample the map size. This is sufficient because the thresholds are several times the sample rate.

We also update the sampled size on every scheduled cleanup.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@mcculls
mcculls force-pushed the mcculls/sample-objectstore-map-size branch from d3a4905 to 7670983 Compare September 7, 2026 15:15
@mcculls
mcculls marked this pull request as ready for review September 7, 2026 15:24
@mcculls
mcculls requested a review from a team as a code owner September 7, 2026 15:24
@mcculls
mcculls requested review from amarziali and jbachorik and removed request for a team September 7, 2026 15:24
@mcculls

mcculls commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

@DataDog review

This comment was marked as outdated.

datadog-datadog-prod-us1-2[bot]

This comment was marked as outdated.

@mcculls
mcculls force-pushed the mcculls/sample-objectstore-map-size branch from 7670983 to d270f39 Compare September 7, 2026 15:44
@mcculls

mcculls commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

@DataDog review

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

nice. lgtm I just left a couple of informative comments

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.

🟢 Approval recommended

The functional changes are cohesive and localized, with only minor documentation clarifications suggested.

Review details

Suppressed comments (1)

field-inject/src/main/java/datadog/instrument/fieldinject/GlobalObjectStore.java:350

  • LookupKey.misses is incremented by both miss() and skip(), so describing it as only "lookup missed" is inaccurate; clarifying this helps prevent confusion about what drives map-size sampling.
    /** Number of times a lookup missed when writing. */
    int misses;

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

The PR reduces map-size checks during writes. The latest commit makes each thread sample on its first write, so it fixes the earlier unbounded-growth case for short-lived threads; no open findings remain.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@mcculls
mcculls merged commit e6071cd into main Sep 7, 2026
7 checks passed
@mcculls
mcculls deleted the mcculls/sample-objectstore-map-size branch September 7, 2026 17:41
@github-actions github-actions Bot added this to the 0.1.0 milestone Sep 7, 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