Skip to content

Hash the evaluation context while the hook copies it (FFE optimization) - #13625

Closed
dougqh wants to merge 1 commit into
dougqh/ffe-caller-side-aggregationfrom
dougqh/ffe-context-hash-in-copy
Closed

dougqh wants to merge 1 commit into
dougqh/ffe-caller-side-aggregationfrom
dougqh/ffe-context-hash-in-copy

Conversation

@dougqh

@dougqh dougqh commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Stacked on #13622.

With aggregation on the evaluating thread (#13622), keying a consented evaluation's bucket walks its copied context a second time to compute the order-independent context hash. That moved a cost the queue path paid on its worker onto the calling thread: 7.2% of evaluating-thread time on scale/variations, and +6.9% per evaluation at equal work.

The hook's bounded context copy (DDEvaluator.copyPrunedContext) now fills a HashedContext, a HashMap that adds each entry's share of the hash as it's put, keeping it correct across replacements, removals and clears. ConcurrentFlagAggregator.contextHash returns that cached hash when it's given a HashedContext and walks any other map as before, with both computing the same value. record's signature is unchanged.

Motivation

This removes the extra walk over every consented context on the calling thread. The copy itself remains; copying only when a new bucket is created is a possible follow-up.

Measurement: no gain, and why

A benchmark worker ran ClientEvaluationBenchmark scale/variations (paced, 4 threads, 5 forks per build, rotated, 27% steal):

build ns per evaluation bytes per evaluation
queue path 151,233 27,854
#13622 155,404 (+2.8%, overlapping) 27,764
this PR 158,619 (+2.1% against #13622, overlapping) 27,789

Additional Notes

  • Measured: no improvement. See below. This PR is likely to be closed.
  • Tests: the cached hash equals the walked hash, after puts, replacements with a different value type, removals and clears, and equals the hash of an equal plain map.

🤖 Generated with Claude Code

With aggregation on the evaluating thread, keying a consented
evaluation's bucket walked its copied context a second time to hash it:
7% of evaluating-thread time on the variations benchmark. The hook's
copy is now a HashedContext, which adds each entry's share of the
order-independent hash as it is put, and the aggregator takes that hash
instead of walking the map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added type: feature Enhancements and improvements tag: performance Performance related changes tag: ai generated Largely based on code generated by an AI or LLM comp: openfeature OpenFeature labels Nov 22, 2026
@pr-commenter

pr-commenter Bot commented Nov 22, 2026

Copy link
Copy Markdown

LLM Validation

LLM Validation Gate — java-agent-instructions

✅ PASS

  • No blocking-case regressions; the quality change is within noise (baseline/candidate confidence intervals overlap).

6 case(s) · quality 81.3 → 81.4 (0.0) · win-rate 49% [45%–53%]

Details — analysis and per-case results

Analysis

Changed instruction file(s): AGENTS.md.

1 case(s) dipped but stayed within the pass bar.

  • java-documentation-only-validation-001 (advisory): won 33% of blind comparisons, quality -2.8.
    • Asked: My PR fixes one spelling mistake in an explanatory sentence in an existing Markdown document. It changes no commands, code examples, links, generated content,
    • Baseline answer: Keep it light. A one-word prose fix doesn't need a build, tests, or Spotless (Spotless formats Java code, not prose). Before requesting review: 1. Check the diff itself. It should touch one file, change only the misspelled word, and add no stray whitespace or line-ending changes. If it renders differently,
    • Candidate answer: For a one-word spelling fix in prose, you don't need a build, tests, or spotlessApply. Spotless formats code, and nothing in the change can affect compilation or runtime behaviour. Required by the repo's rules: - /sdk-review: AGENTS.md says to run it over the committed branch changes before pushing, and

Results

  • Pairwise win-rate: 49% [45%–53%] — candidate's share of blind comparisons (90% CI; spanning 50% = no clear difference)
  • Overall quality: 81.3 → 81.4 (/100, 0.0)
  • Bad signals introduced (advisory): 0
  • Candidate criteria coverage (advisory): 23/27 (85%) — expected_criteria the candidate met; does not affect the gate
  • Blocking-case regressions: 0

Cases

Case Mode Quality Δ Win-rate (90% CI) Safety
java-core-validation-001 warn +2.8 58% [45%–72%] ok
java-unit-test-conventions-001 warn -0.3 50% [50%–50%] ok
java-premain-safety-001 warn +0.3 50% [50%–50%] ok
java-ci-download-guidance-001 warn +0.3 50% [50%–50%] ok
java-documentation-only-validation-001 🟡 warn -2.8 33% [16%–51%] ok
java-existing-spock-maintenance-001 warn 0.0 50% [50%–50%] ok

Per-dimension scores, token usage, latency, and estimated cost are in the CI job logs.

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 60.78% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 09c6c52 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 22, 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 14.08 s 14.00 s [-0.4%; +1.5%] (no difference)
startup:insecure-bank:tracing:Agent 13.00 s 13.07 s [-1.3%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 17.12 s 16.44 s [-0.1%; +8.4%] (no difference)
startup:petclinic:iast:Agent 16.99 s 17.07 s [-1.2%; +0.4%] (no difference)
startup:petclinic:profiling:Agent 16.83 s 16.34 s [-1.4%; +7.3%] (no difference)
startup:petclinic:sca:Agent 17.09 s 17.14 s [-1.3%; +0.8%] (no difference)
startup:petclinic:tracing:Agent 16.21 s 16.27 s [-0.9%; +0.2%] (no difference)

Commit: 09c6c52e · 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.

@dougqh

dougqh commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Closing: measured no gain. The calling-thread cost it targeted came from the features map, not the context hash; #13611 fixes that (see #13622).

@dougqh dougqh closed this Nov 22, 2026
@dougqh
dougqh deleted the dougqh/ffe-context-hash-in-copy branch November 22, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: openfeature OpenFeature tag: ai generated Largely based on code generated by an AI or LLM tag: performance Performance related changes type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant