Skip to content

Reduce allocations in evalPath#199

Open
madhuchavva wants to merge 9 commits intomainfrom
fix/perf-imp-pr-196
Open

Reduce allocations in evalPath#199
madhuchavva wants to merge 9 commits intomainfrom
fix/perf-imp-pr-196

Conversation

@madhuchavva
Copy link
Copy Markdown
Contributor

Summary

This PR builds on top of the improvements in #196. The goal is to reduce allocations in the feature/experiment evaluation path highlighted in PR #196, especially around forced override lookups.

The PR #196 already removes a stream/list-based map merge from a hot evaluation path. This follow-up keeps the change(removal of stream/list-based map merge from a hot evaluation path) intact and adds below:

  • avoid any breaking changes for people relying on GrowthBookUtils.mergeMaps(...) and preserve API compatibility.
  • remove the remaining merged-map allocations from forced override lookups
  • normalize a couple of UserContext defaults so getters stop allocating on read
  • add a reproducible perf harness and comparison artifacts

Performance Results

Measured with:

JAVA_HOME=/opt/homebrew/Cellar/openjdk@17/17.0.18/libexec/openjdk.jdk/Contents/Home \
  ./gradlew :lib:runPerfHarness -PperfWarmupIterations=20000 -PperfIterations=100000
Scenario main pr-196 fix/perf-imp-pr-196
feature-no-overrides 586.8 ns/op 201.4 ns/op 201.5 ns/op
feature-global-override 1171.7 ns/op 318.6 ns/op 152.2 ns/op
feature-user-override 874.0 ns/op 463.6 ns/op 234.5 ns/op
experiment-no-forced-variations 1482.1 ns/op 1123.6 ns/op 1065.6 ns/op
experiment-global-forced-variation 300.6 ns/op 384.9 ns/op 197.2 ns/op
experiment-user-forced-variation 353.7 ns/op 481.3 ns/op 203.4 ns/op

Test Harness Results

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants