Skip to content

Pass a split's prepared evaluation features to the hook by handle (FFE optimization) - #13611

Draft
dougqh wants to merge 1 commit into
leo.romanovsky/ffe-allocation-scanfrom
dougqh/ffe-split-features-handle
Draft

dougqh wants to merge 1 commit into
leo.romanovsky/ffe-allocation-scanfrom
dougqh/ffe-split-features-handle

Conversation

@dougqh

@dougqh dougqh commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Stacked on #13489, whose SplitFeatures prepares each split's feature metadata once.

With evaluation features on a split, FlagEvalLoggingHook still rebuilt the features map on every evaluation, on the evaluating thread: a scan of the metadata, a HashMap, a substring per key and an unmodifiable wrapper. The map was new each time, so the flag-evaluation aggregator also had to hash it and compare it in full to find the bucket's feature set. Profiling scale/variations with #13609 put that hashCode at about 19% of the remaining worker time.

This PR prepares the evaluation-features map once, with the split, and passes it to the hook by handle:

  • SplitFeatures.prepare also builds the split's evaluation-features map, with the keys unprefixed and the values exactly as the hook would read them back. It registers the map with EvaluationFeatureHandles and writes the handle as one long metadata entry, __dd_evaluation_features_handle.
  • EvaluationFeatureHandles: a handle is the configuration epoch plus an index into that epoch's table.
    • When DDEvaluator receives a different configuration, a new epoch starts and the old table is dropped, so only the served configuration's features are retained.
    • Registration happens once per split and takes a lock. Lookups don't lock.
    • The table is capped at 65,536 entries.
  • The hook takes the prepared map when the handle resolves. Otherwise, for example after a configuration change, it rebuilds the map from the metadata entries, which are still written.
  • The prepared map caches its hash. Every evaluation of a split passes the same instance, so the aggregator finds its feature set with one cached hash and an identity check.

Motivation

This takes per-evaluation allocation off the caller for splits with evaluation features. It also removes the aggregator's per-event map hashing and comparison for feature sets.

Additional Notes

  • The handle table is process-wide. With several providers serving different configurations, each configuration change starts a new epoch, and the other providers' handles stop resolving. They fall back to rebuilding the map, which is the current behavior, so the result stays correct but loses the saving.
  • Measurement: see below.

Measurement

A benchmark worker ran ClientEvaluationBenchmark, scale/variations, unique subjects, 4 threads, JDK 21, 3 forks per side. A is the FFE roll-up plus #13609; B is A plus this change.

A B
unpaced ns/op 55,968 41,540 (−25.8%)
unpaced B/op 26,956 18,040 (−33.1%)
paced ns/op 97,359 84,121 (−13.6%)
paced B/op 27,568 20,291 (−26.4%)
  • Worker CPU: fell from 41% to 5% of a core. AbstractMap.hashCode was 16% self time (47% inclusive) on A and is absent from B. The estimated one-core ceiling rises from about 0.15M to about 1.0M events a second; that's extrapolated, not a sustained-load result.
  • Drop share: rose slightly, 0.85% → 1.7% unpaced and 0.45% → 1.1% paced, even though the worker is far less loaded. My guess, unconfirmed, is that these are flush-time drops: B evaluates about 26% faster, so more events arrive during each flush stall. These builds don't include the queue wake-up fix (Wake the event worker when an event arrives (FFE optimization) #13607).
  • scale/splits and scale/flags: no confirmed change, 1 fork each.

🤖 Generated with Claude Code

The flag evaluation hook rebuilt each evaluation's features from the
metadata entries: a scan, a HashMap, substrings and a wrapper, on the
evaluating thread, for every evaluation of a split with evaluation
features. And because the map was new each time, the aggregator had to
hash and compare it in full to find the bucket's feature set.

Prepare the evaluation features map once with the split, register it
under a handle of the current configuration's epoch, and put the handle
in the metadata. The hook takes the prepared map when the handle
resolves and rebuilds it from the entries otherwise, as after a
configuration change. The prepared map caches its hash, so the
aggregator finds its feature set by one cached hash and an identity
check.

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 21, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 98.39%
• Overall Coverage: 60.68% (+0.02%)

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

@dd-octo-sts

dd-octo-sts Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

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.90 s 14.85 s [-0.5%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 13.61 s 13.71 s [-1.4%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.87 s 17.02 s [+0.6%; +9.4%] (maybe worse)
startup:petclinic:iast:Agent 17.54 s 17.68 s [-1.5%; -0.0%] (maybe better)
startup:petclinic:profiling:Agent 17.36 s 17.46 s [-1.6%; +0.4%] (no difference)
startup:petclinic:sca:Agent 17.85 s 17.80 s [-0.8%; +1.3%] (no difference)
startup:petclinic:tracing:Agent 16.97 s 17.04 s [-1.4%; +0.6%] (no difference)

Commit: 1bf37d2f · 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.

This branch has not been deployed

No deployments
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