Skip to content

Reduce Feature Flags rule evaluation allocations - #12217

Draft
leoromanovsky wants to merge 1 commit into
masterfrom
agent/java-evaluation-rule-allocation
Draft

Reduce Feature Flags rule evaluation allocations#12217
leoromanovsky wants to merge 1 commit into
masterfrom
agent/java-evaluation-rule-allocation

Conversation

@leoromanovsky

Copy link
Copy Markdown
Contributor

Motivation

Regex rules compiled and normalized the expression during every evaluation. JDK 11 JMH measured 341 ns and 2,256 bytes per operation.

Shard rules created an MD5 helper, a combined input string, and a hexadecimal string. JDK 11 JMH measured 345 ns and 1,456 bytes per operation.

The static control measured 80 ns and 368 bytes per operation.

Changes and Decisions

  • Compile valid regex expressions during UFC preprocessing.
  • Keep invalid expressions uncached so evaluation preserves PARSE_ERROR behavior.
  • Cache immutable shard salt-prefix bytes during UFC preprocessing.
  • Reuse one MD5 instance per evaluation thread without shared mutation.
  • Read the first four digest bytes directly and preserve the Eppo shard algorithm.
  • Create no scheduler or worker thread.
  • Keep a JMH benchmark for static, regex, and shard rules.

Validation

JDK 11 single-thread JMH results:

  • Regex: 341 to 122 ns and 2,256 to 568 bytes per operation.
  • Shard: 345 to 232 ns and 1,456 to 448 bytes per operation.
  • Static control: 80 to 85 ns and 368 bytes per operation.

Four-thread JDK 26 JMH results:

  • Regex: 251 to 66 ns and 2,032 to 504 bytes per operation.
  • Shard: 286 to 125 ns and 1,344 to 448 bytes per operation.
  • Static control: 43 to 44 ns and 368 bytes per operation.

The shard parity test preserves the Go and Eppo vectors for eve, user-1, alice, and bob.

@leoromanovsky leoromanovsky added type: feature Enhancements and improvements comp: openfeature OpenFeature tag: ai generated Largely based on code generated by an AI or LLM 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: 44.90%
Overall Coverage: 77.52% (+19.17%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 43ba527 | 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