Repository navigation
Make the value field of a TrackedValue general from the first instance - #21667
Merged
NullVoxPopuli merged 2 commits intoOct 7, 2026
Merged
NullVoxPopuli merged 2 commits into
NullVoxPopuli merged 2 commits into
Conversation
All instances have one hidden class, and V8 records which kind of value the `#value` field held so far. If no instance held a number yet, the first number makes V8 throw away the optimized code of each function that reads a TrackedValue. The constructor now stores a number before the value, so the field is general from the first instance. Split out of emberjs#21650. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 6, 2026
NullVoxPopuli
marked this pull request as ready for review
October 6, 2026 03:28
ef4
previously approved these changes
Oct 6, 2026
Updated comments in the constructor for clarity. Linting
NullVoxPopuli
force-pushed
the
nvp/tracked-value-general-field
branch
from
October 6, 2026 18:05
5c63cac to
0080d2d
Compare
ef4
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The constructor of a
TrackedValuestores0before the value. This removes one deopt for each page load, and it costs no time and no memory.This is a part of #21650, and it merges alone. The change is one line and its comment.
Why
TrackedValuehave one hidden class, and V8 records which kind of value#valueheld so far.undefined. The first number in any later instance then made V8 throw away the optimized code of each function that reads aTrackedValue.0makes the field general in the first instance, before V8 optimizes any code.What it costs and what it gains
The numbers are from the head of #21650 with and without this line. The scripts are in this comment on #21650.
main.One group where the store looks slower, and why it is not the cause
After the first number comes, the read loop is 3% to 4% slower with the store. That is 0.06 ns to 0.09 ns for each read.
undefinedand then the value equals the build with one store.0.--trace-optshows that the deopt makes V8 compile the read loop a second time, and the second code is the faster one. The benchmark measures a different compile of the same loop.All 20 cases of the reactivity benchmark
mainThe benchmark is https://github.com/NullVoxPopuli-ai-agent/ember-reactivity-bench. One measurement is the writes of one frame, then one flush that brings every output up to date. Each case of each build runs in its own process, pinned to one core. The numbers are the median of 6 mirrored rounds on Node 24.20.
The run has
main, each of the five branches, and #21650 as columns: table and method.Tests
type-check:internals, ESLint and Prettier pass.TrackedValuecover the constructor.The parts of #21650
#21650 has all five changes in one branch. It stays open as the reference for the combined numbers. The five branches merge with no conflict, and their merge is the same code as the head of #21650.
mainTrackedValueon their first use0first in the value field of aTrackedValueRendering was measured for the combined change only:
pnpm benchshows 2.1% less script time, in this comment on #21650.🤖 Generated with Claude Code