Skip to content

Split the uniqueKeyFor seen-map into object and primitive maps - #21597

Open
NullVoxPopuli wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli:nvp/perf/iterable-key-maps
Open

Split the uniqueKeyFor seen-map into object and primitive maps#21597
NullVoxPopuli wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli:nvp/perf/iterable-key-maps

Conversation

@NullVoxPopuli

@NullVoxPopuli NullVoxPopuli commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the WeakMapWithPrimitives wrapper used by uniqueKeyFor and identityForNthOccurence with a WeakMap and a Map selected inline.

This runs once per item on every pass over a list, so it removes two method calls and a redundant isIndexable check per item.

Split out of nvp/simplify-some-vm-hot-paths.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli changed the title [PERF] Split the uniqueKeyFor seen-map into object and primitive maps Split the uniqueKeyFor seen-map into object and primitive maps Sep 9, 2026
@NullVoxPopuli

Copy link
Copy Markdown
Contributor Author

Benchmark: main (bdb2580) vs nvp/perf/iterable-key-maps (43c3c4a)

Ran via pnpm bench (the krausest js-framework-benchmark scenario in smoke-tests/benchmark-app, tracerbench, 20 samples each, 8x CPU throttle). Negative delta means the PR is faster. Only rows tracerbench marks significant (p < 0.05) are meaningful.

Phase main median PR median Δ (estimator) 95% CI Significant
Total duration 10,646ms 10,596ms -32ms (-0.3%) -163ms .. 60ms
render 170ms 168ms -2ms (-1.3%) -7ms .. 2ms
render1000Items1 384ms 384ms 1ms (+0.1%) -5ms .. 7ms
clearItems1 41ms 41ms 1ms (+1.4%) 0ms .. 1ms
render1000Items2 324ms 325ms 0ms (+0.1%) -5ms .. 4ms
clearItems2 140ms 138ms -1ms (-0.8%) -2ms .. 0ms ✅
render10000Items1 2,998ms 2,978ms -15ms (-0.5%) -59ms .. 4ms
clearManyItems1 390ms 389ms -1ms (-0.3%) -4ms .. 1ms
render10000Items2 2,997ms 2,993ms 3ms (+0.1%) -22ms .. 29ms
clearManyItems2 280ms 280ms 0ms (+0.1%) -2ms .. 3ms
render1000Items3 300ms 299ms -1ms (-0.3%) -8ms .. 6ms
append1000Items1 399ms 397ms -1ms (-0.2%) -16ms .. 14ms
append1000Items2 363ms 366ms 4ms (+1.1%) -6ms .. 34ms
updateEvery10thItem1 324ms 329ms 4ms (+1.2%) -3ms .. 9ms
updateEvery10thItem2 368ms 371ms 1ms (+0.4%) -11ms .. 12ms
selectFirstRow1 92ms 89ms -1ms (-1.1%) -4ms .. 3ms
selectSecondRow1 76ms 77ms 0ms (+0.6%) -4ms .. 4ms
removeFirstRow1 233ms 233ms -1ms (-0.4%) -6ms .. 4ms
removeSecondRow1 224ms 228ms 3ms (+1.5%) -2ms .. 10ms
swapRows1 162ms 165ms 1ms (+0.5%) -5ms .. 7ms
swapRows2 161ms 167ms 5ms (+3.3%) -4ms .. 13ms
clearItems4 113ms 113ms 0ms (+0.4%) -2ms .. 3ms
paint 8ms 10ms 1ms (+19.0%) 0ms .. 4ms

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.

1 participant