Repository navigation
Conversation
Actions#ready() read every plugin's pending set before awaiting the scheduled actions. Those actions are applied on the next animation frame, and the React plugin only starts tracking a fragment render when the morph reaches it, so ready() never awaited the renders its own actions triggered. It only appeared to: each render committed in a microtask continuation (after preload) that ran before ready() resumed. The existing "actions plugin" test fails as soon as a render commits any later, which the next commit does. Await the scheduled actions first, then ask the plugins: the renders they started are in the pending set by then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every notify() commits the root, and a commit re-renders the portal of every mounted fragment. Replacing many fragments at once is therefore quadratic: in demarche.numerique's form-field editor, an autosave on a 275-field procedure replaces ~265 fragments (one turbo-stream each) and took 518 React commits (542 with the flushSync of 0.19.5), blocking the main thread for 1.4–1.9 s. Loading that page took 553 commits. notify() now schedules a single flush in a later task and returns a promise resolved once it has run. render() awaits it before dropping the loading class, so ready() resolves after the fragments its actions rendered are committed. Removals (a fragment removed by a morph, remove(), finalizeMorph) are committed by the same deferred flush without being awaited, as they were on the concurrent root before 0.19.5. Coalescing in a microtask does not help: actions are applied in separate animation-frame callbacks, each followed by its own microtask checkpoint. The flush itself keeps flushSync. With this change the same autosave takes 2 commits and ~0.14 s of rendering, and the page load 3 commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
colinux
force-pushed
the
perf/batch-root-notifications
branch
from
November 2, 2026 15:23
dd68a37 to
6f88957
Compare
colinux
marked this pull request as ready for review
November 2, 2026 15:47
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.
Why
In demarche.numerique's form-field editor, each field editor holds a
<react-fragment>(a react-aria select). On a 275-field form, autosaving a field near the top returns one turbo-streamreplaceper following field: ~265 fragments removed and re-created at once.Each of them calls
notify(), which commits the single root, and every commit re-renders the portal of every mounted fragment: the work is quadratic. Measured in Chromium on that page:What
fix(actions):ready()awaits the scheduled actions before asking plugins for their pending work. It used to read the plugins first, so it never awaited the renders its own actions start; it only worked because those renders committed in a microtask.perf(react):notify()schedules a single flush (stillflushSync) in a later task, andrender()awaits it. A microtask doesn't help: actions run in separate animation-frame callbacks, each followed by its own microtask checkpoint. The new test reproduces this: 1 commit, 30 with a microtask.Trade-offs
ready()doesn't await the unmount of removed fragments: flushing removals synchronously would bring back half of the commits.Verification
✅ Final review done on
6f88957, findings addressedTests:
vp testandvp checkpass, on Chromium only (no Firefox or WebKit locally).Final review: 9 findings. 3 fixed (the test, a test title, a comment), 1 kept as a trade-off above, 1 dismissed (React 19's
flushSyncdoesn't rethrow uncaught render errors, it reports them throughonUncaughtError), 4 without a reachable scenario.Not proven: Firefox and WebKit; the one-frame empty paint is reasoned, not observed.