java-sdk icon indicating copy to clipboard operation
java-sdk copied to clipboard

feat: Cache hooks per Flag Evaluation Type

Open chrfwow opened this issue 2 months ago • 4 comments

Hooks are now stored in a map to allow efficient lookup of hooks supporting certain FlagValueTypes. This and other changes makes merging the hooks cheaper.

Related Issues

Part of #1718

Follow Up Tasks

Implement efficient Hook Storage in all providers (optional, but will speed things up)

chrfwow avatar Nov 20 '25 16:11 chrfwow

  • [ ] Make sure the additions of default methods to interfaces is not a byte code incompatibility

chrfwow avatar Nov 20 '25 16:11 chrfwow

Codecov Report

:x: Patch coverage is 94.20290% with 4 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 93.36%. Comparing base (bd70a3a) to head (59530f5). :warning: Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/main/java/dev/openfeature/sdk/HookSupport.java 91.66% 0 Missing and 3 partials :warning:
...ava/dev/openfeature/sdk/FlagEvaluationOptions.java 87.50% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1734      +/-   ##
============================================
+ Coverage     92.47%   93.36%   +0.88%     
- Complexity      527      546      +19     
============================================
  Files            52       53       +1     
  Lines          1276     1326      +50     
  Branches        112      125      +13     
============================================
+ Hits           1180     1238      +58     
+ Misses           60       50      -10     
- Partials         36       38       +2     
Flag Coverage Δ
unittests 93.36% <94.20%> (+0.88%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Nov 20 '25 16:11 codecov[bot]

Benchmark results: (I ran AllocationBenchmark#main with the IntelliJ Profiler. This is not a proper JMH benchmark, so the values are not representative per evaluation, but should be helpful to compare both versions)

Baseline: Duration: 5267 ms Allocations: 16.834 GB Flamegraph of allocations: image

This PR: Duration: 5023 ms (this is an insignificant change, the deviations on those tests are quite large) Allocations: 14.224 GB Flamegraph of allocations: image

chrfwow avatar Nov 20 '25 16:11 chrfwow