Skip to content

Make ThreadSafeMapBenchmark lookup index per-thread (remove shared-counter contention)#11988

Draft
dougqh wants to merge 1 commit into
masterfrom
dougqh/fix-threadsafe-map-bench
Draft

Make ThreadSafeMapBenchmark lookup index per-thread (remove shared-counter contention)#11988
dougqh wants to merge 1 commit into
masterfrom
dougqh/fix-threadsafe-map-bench

Conversation

@dougqh

@dougqh dougqh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Makes ThreadSafeMapBenchmark's lookup-key cursor per-thread instead of a shared static counter.

Why

nextLookupKey incremented a static int sharedLookupIndex from all @Threads(8) — a cache-line-contended data race. That counter traffic is a fixed floor added to every get_* measurement; for the fastest reads it dominates, compressing exactly the differences the benchmark exists to show. SingleThreadedMapBenchmark already uses a per-thread index, and the set benchmarks got this fix in #11721 — this brings the map suite in line (it was only ever done for sets).

How

  • @State(Scope.Thread) on the class; static int sharedLookupIndex → instance int lookupIndex; nextLookupKey → instance methods.
  • The maps stay static/shared — that's the point (concurrent reads of one shared map); only the index goes per-thread.

Note

The committed Javadoc numbers predate this and need a rerun.

🤖 Generated with Claude Code

…unter contention)

nextLookupKey used a shared static counter incremented from all @threads(8) — a cache-line-contended race that floors the fastest reads and masks the very differences the benchmark compares (mirrors the per-thread index SingleThreadedMapBenchmark already uses, and the set-benchmark fix in #11721). Maps stay static/shared; only the lookup index goes per-thread via @State(Scope.Thread). Existing Javadoc numbers predate this and need a rerun.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring labels Jul 17, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.95 s 13.97 s [-0.8%; +0.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 13.01 s [-1.4%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 16.84 s 16.83 s [-1.1%; +1.1%] (no difference)
startup:petclinic:iast:Agent 16.91 s 16.97 s [-1.2%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.64 s 16.92 s [-2.9%; -0.4%] (maybe better)
startup:petclinic:sca:Agent 16.90 s 16.73 s [+0.0%; +2.1%] (maybe worse)
startup:petclinic:tracing:Agent 16.05 s 16.23 s [-2.0%; -0.2%] (maybe better)

Commit: efe0f8e7 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant