You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/blog/tanstack-start-ssr-performance-600-percent.md
+61-13Lines changed: 61 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,8 +40,8 @@ We highlight the highest-impact patterns below.
40
40
We are not claiming that any single line of code is "the" reason. This work spanned over [20 PRs](https://github.com/TanStack/router/compare/v1.154.4...v1.157.18), with still more to come. Every change was validated by:
41
41
42
42
- a stable load test (same endpoint, same load)
43
-
- a CPU profile (flamegraph) that explains the delta
44
43
- a before/after comparison on the same benchmark endpoint
44
+
- a CPU profile (flamegraph) that explains the delta
Like every PR in this series, this change was validated by profiling the impacted method before and after. For example we can see in the example below that the `buildLocation` method went from being one of the major bottlenecks of a navigation to being a very small part of the overall cost:
| Before ||
141
-
| After ||
138
+
139
+
<figure>
140
+
<imgsrc="/blog-assets/tanstack-start-ssr-performance-600-percent/build-location-before.png"alt="CPU profiling of buildLocation before the changes">
141
+
<figcaption>
142
+
<b>Before:</b> The <code>RouterCore.buildLocation</code> (red arrow) method was creating a <code>new URL</code> every time (purple blocks), and then updating its search which re-triggers an expensive parsing step.
alt="CPU profiling of buildLocation after the changes"
150
+
>
151
+
<figcaption>
152
+
<b>After:</b> The <code>isSafeInternal</code> check is able to fully skip the <code>URL</code>. <code>RouterCore.buildLocation</code> becomes an almost insignificant part of the overall cost.
Taking the example of the `useRouterState` hook, we can see that most of the client-only work was removed from the SSR pass, leading to a ~2x improvement in the total CPU time of this hook.
alt="CPU profiling of useRouterState before the changes"
203
+
>
204
+
<figcaption>
205
+
<b>Before:</b> The <code>useRouterState</code> hook was subscribing to the router store, which triggers many sync and memoization calls before calling the <code>select</code> callback.
alt="CPU profiling of startViewTransition before the changes"
307
+
>
308
+
<figcaption>
309
+
<b>Before:</b> The <code>startViewTransition</code> function (red arrow) has ~400ms of self-time in the hot path (i.e. not including the time spent in its children).
0 commit comments