Repository navigation
perf: reduce effect and ref postorder ancestry scans - #998
Merged
domgan-oai merged 2 commits intoSep 8, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 8, 2026 17:49
Closed
15 of 24 tasks
Closed
68 of 84 tasks
14 of 21 tasks
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.
Summary
Why
The previous comparator scans both complete parent chains for each comparison, even when comparing a component with its direct parent or a sibling.
Changes
mainand measures chain, sibling, and uneven-branch sort workloads. Add anoctanepatch changeset.Validation
node scripts/workspace-packages.mjs --check,git diff --check, and focused benchmark ordering gates.pnpm sync, Vitest, and typecheck: the configured Socket registry returned HTTP 403 for pinned@tsrx/[email protected]before scripts could start; frozen-lockfile supply-chain verification passed. The offline filtered install also lacked@tsrx/[email protected].Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes commit-phase ordering logic for effects and refs; incorrect comparisons would be user-visible, though existing and new conformance tests target the tricky cross-depth and nested lifecycle cases.
Overview
Optimizes how queued layout/passive effects and ref attachments are sorted so commit order still matches React’s post-order tree walk, with fewer
parentBlockwalks during sorting.comparePostOrderinruntime.tsno longer callsblockIsAncestorOftwice per comparison. It resolves direct parent/child pairs, same-parent siblings (via enqueueseq), then only walks one side’s chain when needed before falling back toaSeq - bSeq.Adds a standalone benchmark (
benchmarks/effect-postorder) that extracts the comparator from a Git ref vs the worktree, checks postorder correctness, counts parent reads, and reports median sort time for chain, sibling, and mixed trees.Adds conformance coverage (
NestedLifecycleOrder) for shallow sibling + deep nested tree layout and passive effect order across mount and update, including cleanups.Reviewed by Cursor Bugbot for commit 155c7dd. Bugbot is set up for automated code reviews on this repo. Configure here.