Skip to content

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

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

dougqh wants to merge 2 commits 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

Measurement update: with caller-side aggregation (#13622)

On the FFE roll-up with #13622 (ClientEvaluationBenchmark scale/variations, paced, 4 threads, 5 forks per build, 27% steal):

build ns per evaluation bytes per evaluation
#13622 155,814 27,789
#13622 + this PR 131,796 (−15.4%) 20,542 (−26%)
  • On the calling thread: the hook falls from 23.8% to 1.0% of the thread's time, since it no longer rebuilds the features map. The aggregator falls from 7.5% to 0.9%, since feature comparison is now an identity check and the hash a cached field.
  • flags and splits: unchanged.

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.67%
• Overall Coverage: 60.70% (+0.04%)

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

@dd-octo-sts

dd-octo-sts Bot commented Nov 21, 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.83 s 14.73 s [-0.0%; +1.4%] (no difference)
startup:insecure-bank:tracing:Agent 13.53 s 13.67 s [-1.7%; -0.4%] (maybe better)
startup:petclinic:appsec:Agent 17.82 s 17.70 s [-0.1%; +1.5%] (no difference)
startup:petclinic:iast:Agent 17.67 s 17.77 s [-1.5%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 17.60 s 17.27 s [+0.9%; +3.0%] (maybe worse)
startup:petclinic:sca:Agent 17.99 s 17.83 s [-0.1%; +1.9%] (no difference)
startup:petclinic:tracing:Agent 16.79 s 16.98 s [-2.2%; -0.0%] (maybe better)

Commit: 2321fdc7 · 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.

The exposure hook rebuilt each split's exposure features from the
metadata entries on every exposure it sent: a scan, substrings and a
HashMap. Splits now prepare and register the exposure features the same
way as the evaluation features, and the hook takes the prepared map when
its handle resolves. Both hooks share the lookup-or-rebuild helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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