Skip to content

perf(feature-flagging): avoid duplicate exposure context capture - #12218

Draft
leoromanovsky wants to merge 1 commit into
masterfrom
agent/java-exposure-context-deduplication
Draft

perf(feature-flagging): avoid duplicate exposure context capture#12218
leoromanovsky wants to merge 1 commit into
masterfrom
agent/java-exposure-context-deduplication

Conversation

@leoromanovsky

Copy link
Copy Markdown
Contributor

Motivation

The evaluator copied the complete context before the writer removed duplicate exposures. Repeated exposure cost increased with customer context size. A 1,000-field duplicate allocated 162,000 bytes and took 29.65 microseconds.

Changes and Decisions

  • Check the four-field exposure identity before context capture.
  • Keep the serializer LRU cache as the final exact deduplication guard.
  • Record admission only after the queue accepts an event.
  • Bound the admission cache to the queue capacity.
  • Replace snapshot-then-flatten with one bounded context copy.
  • Preserve the targeting key and normal exposure payload semantics.
  • Add no worker or scheduler thread.

Validation

JDK 11 JMH, one thread:

Exposure path Before After
Duplicate, empty 81.07 ns, 1,264 B/op 7.31 ns, 24 B/op
Duplicate, 100 flat fields 2.77 us, 18,032 B/op 7.38 ns, 24 B/op
Duplicate, 100 nested fields 8.90 us, 42,952 B/op 7.72 ns, 24 B/op
Duplicate, 1,000 flat fields 29.65 us, 162,000 B/op 7.77 ns, 24 B/op
First, 1,000 flat fields 30.62 us, 162,000 B/op 3.91 us, 13,128 B/op

@leoromanovsky leoromanovsky added tag: ai generated Largely based on code generated by an AI or LLM comp: openfeature OpenFeature type: feature Enhancements and improvements labels Aug 15, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 97.70%
Overall Coverage: 78.34% (+19.99%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 577b37b | Docs | Datadog PR Page | Give us feedback!

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 type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant