perf(router-core): reduce sync match update churn#7019
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRefactors load handling: Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Router as Router
participant Exec as executeBeforeLoad
participant Loader as runLoader
participant Comp as Component.preload
participant Abort as AbortController
Client->>Router: navigate(to: '/foo')
Router->>Exec: executeBeforeLoad(match)
Exec->>Abort: create AbortController
Exec->>Router: finishSyncBeforeLoad (sets __beforeLoadContext)
Exec->>Loader: runLoader(match, abortSignal)
Loader->>Comp: start component.preload()
Note right of Comp: preload pending (blocks)
Client->>Router: cancelMatches()
Router->>Abort: call abort()
Abort-->>Exec: abort event -> beforeLoad/loader receive abort
Comp->>Loader: preload resolves (after cancel)
Loader-->>Router: finalize navigation promise
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 4fc676c
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fa6a1046f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merging this PR will improve performance by 3.77%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | client-side navigation loop (react) |
61.4 ms | 59.1 ms | +3.77% |
Comparing flo/load-matches-sync-fastpaths (4fc676c) with main (6077120)1
Summary
beforeLoadfetch-state cycles for routes that do not actually runbeforeLoadbeforeLoadand synchronousloaderDataupdates soloadMatchesdoes less per-match store churn during navigationload-matches, with a small router bundle delta and a strong local React client-nav improvementBenchmark Notes
@benchmarks/client-nav: React mean29.6119ms -> 25.0985ms(~15.2% faster)@benchmarks/client-nav: Solid/Vue were roughly flat within local noise (24.7548ms -> 25.1032ms,22.5473ms -> 22.7921ms)@benchmarks/bundle-size: router scenario gzip deltas ranged from+68Bto+97BTesting
CI=1 NX_DAEMON=false pnpm nx run @benchmarks/client-nav:test:perf --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @benchmarks/bundle-size:build --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/react-router:test:unit --outputStyle=stream --skipRemoteCache -- tests/store-updates-during-navigation.test.tsx tests/routeContext.test.tsxSummary by CodeRabbit