Avoid cloning keyed comprehensions without moves#4328
Open
preciz wants to merge 1 commit into
Open
Conversation
Assisted by: GPT 5.6 Sol - Codex Clone keyed state only when a diff moves entries. Stable-position updates never read another old position, so they can merge in place instead of copying the full cached render tree. Keyed entries are encoded as: - `kc`: resulting entry count - object: new entry or same-position diff - number: old index for a move without a diff - `[old_index, diff]`: move with a diff Only the two move encodings read old positions and need a snapshot before mutation. Nested keyed diffs apply the same rule, cloning only the subtree that moves. Chromium 150 merge-only timings (median of seven calibrated samples; DOM patching excluded): - 1,000/10,000 compact two-field rows: 0.435/4.29 ms -> 0.001 ms - 1,000/10,000 rich rows (eight fields, four children): 3.94/47.5 ms -> 0.001 ms Stable keyed merges inside LiveComponents dropped from two tree clones to one, making merge-only benchmarks about 2x faster. Reordering entries still needs the move-safety clone and showed no material change.
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.
@SteffenDE I'm not familiar with the JS side of things but this seems like a small diff for a good gain in performance.
Assisted by: GPT 5.6 Sol - Codex
Clone keyed state only when a diff moves entries. Stable-position
updates never read another old position, so they can merge in place
instead of copying the full cached render tree.
Keyed entries are encoded as:
kc: resulting entry count[old_index, diff]: move with a diffOnly the two move encodings read old positions and need a snapshot
before mutation. Nested keyed diffs apply the same rule, cloning only
the subtree that moves.
Chromium 150 merge-only timings (median of seven calibrated samples;
DOM patching excluded):
Stable keyed merges inside LiveComponents dropped from two tree clones
to one, making merge-only benchmarks about 2x faster. Reordering
entries still needs the move-safety clone and showed no material change.