Skip to content

bench: calibrate new ssr benchmarks iteration to reduce variability#7625

Merged
Sheraff merged 3 commits into
mainfrom
perf-ssr-calibrate-iterations
Jun 13, 2026
Merged

bench: calibrate new ssr benchmarks iteration to reduce variability#7625
Sheraff merged 3 commits into
mainfrom
perf-ssr-calibrate-iterations

Conversation

@Sheraff

@Sheraff Sheraff commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

increase iteration count in new SSR benchmarks for all those that were running in under 50ms. The goal is to improve the signal to noise ratio, and reduce variability in the results.

I'm not sure this is the solution, but I also think it can't hurt. CodSpeed has been very stable for us so far.


Also, improve response drain, from response.text() to a .getReader() that ignores all chunks.

Summary by CodeRabbit

  • Tests
    • Standardized and increased iteration counts across multiple SSR benchmark scenarios for more consistent measurements.
    • Split shared loop settings into per-scenario iteration controls.
    • Switched benchmark validation to operate on full responses and added a helper to consume response streams asynchronously for more reliable benchmarking.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3bb0af71-3aea-49c7-86ca-983fd3a7a912

📥 Commits

Reviewing files that changed from the base of the PR and between ddbbc64 and 7def91e.

📒 Files selected for processing (2)
  • benchmarks/ssr/scenarios/assets/shared.ts
  • benchmarks/ssr/scenarios/serialization/shared-bench.ts
✅ Files skipped from review due to trivial changes (1)
  • benchmarks/ssr/scenarios/assets/shared.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • benchmarks/ssr/scenarios/serialization/shared-bench.ts

📝 Walkthrough

Walkthrough

This PR centralizes and increases per-scenario benchmark iteration counts across SSR scenarios, replaces shared loop option objects with per-scenario constants, and changes bench-utils to validate using the Response and asynchronously drain response bodies.

Changes

Benchmark Iteration Parameterization

Layer / File(s) Summary
Simple iteration constant adjustments
benchmarks/ssr/scenarios/before-load/shared-bench.ts, benchmarks/ssr/scenarios/control-flow/shared.ts, benchmarks/ssr/scenarios/server-routes-middleware/shared.ts, benchmarks/ssr/scenarios/server-routes/shared.ts
Direct updates to existing iteration constants: before-load from 20→30, control-flow constants increased (to 45/50/60), server-routes-middleware 100→150, server-routes 100→200.
New iteration constants with single-runner wiring
benchmarks/ssr/scenarios/assets/shared.ts, benchmarks/ssr/scenarios/head/shared.ts, benchmarks/ssr/scenarios/loaders/shared-bench.ts, benchmarks/ssr/scenarios/rewrites/shared.ts, benchmarks/ssr/scenarios/selective-ssr/shared-bench.ts, benchmarks/ssr/scenarios/serialization/shared-bench.ts
Introduce dedicated iteration constants (e.g., inlineCssLoopIterations, headLoopIterations, loadersLoopIterations, localizedLoopIterations, passthroughLoopIterations, selectiveLoopIterations, richSerializationLoopIterations) and wire them into individual run*Loop calls.
Complex multi-scenario iteration refactoring & bench-utils changes
benchmarks/ssr/scenarios/global-middleware/bench.ts, benchmarks/ssr/scenarios/server-fn-transport/bench.ts, benchmarks/ssr/scenarios/server-fns/bench.ts, benchmarks/ssr/bench-utils.ts
Replace shared request-loop options with per-scenario iteration constants (multiple new constants per file). bench-utils.ts adds drainResponse, replaces validateBody with validateResponse, and switches loops to asynchronously drain responses.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • TanStack/router#7606: Modifies runRequestLoop options and response consumption in benchmarks/ssr/bench-utils.ts, similar to this PR.

Suggested reviewers

  • schiller-manuel

🐰 Iterations named and tidy, streams drained with care,
Benchmarks march onward, numbers counted fair,
Constants lined like carrots, neat in every row,
A rabbit hops in joy — steady metrics, steady flow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: calibrating SSR benchmark iterations to reduce variability by increasing iteration counts for fast-completing benchmarks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-ssr-calibrate-iterations

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 7def91e

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 4m 34s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 25s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-13 09:34:34 UTC

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.15 → 1.170.16 Changeset
@tanstack/solid-router 1.170.15 → 1.170.16 Changeset
@tanstack/start-server-core 1.169.14 → 1.169.15 Changeset
@tanstack/react-start 1.168.25 → 1.168.26 Dependent
@tanstack/react-start-client 1.168.13 → 1.168.14 Dependent
@tanstack/react-start-rsc 0.1.24 → 0.1.25 Dependent
@tanstack/react-start-server 1.167.19 → 1.167.20 Dependent
@tanstack/solid-start 1.168.25 → 1.168.26 Dependent
@tanstack/solid-start-client 1.168.13 → 1.168.14 Dependent
@tanstack/solid-start-server 1.167.19 → 1.167.20 Dependent
@tanstack/start-plugin-core 1.171.17 → 1.171.18 Dependent
@tanstack/vue-start 1.168.24 → 1.168.25 Dependent
@tanstack/vue-start-server 1.167.19 → 1.167.20 Dependent

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 26030114eca0
  • Measured at: 2026-06-13T09:31:22.565Z
  • Baseline source: history:a2b9d51b0a21
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.29 KiB 0 B (0.00%) 87.15 KiB 273.66 KiB 75.88 KiB ▁▁▁▁▁▁▃████
react-router.full 91.02 KiB 0 B (0.00%) 90.88 KiB 285.56 KiB 79.09 KiB ███▁▁▁▁▄▄▄▄
solid-router.minimal 35.48 KiB 0 B (0.00%) 35.36 KiB 105.86 KiB 32.03 KiB ▆▆▆▆█▁▁▁▁▁▁
solid-router.full 40.53 KiB 0 B (0.00%) 40.41 KiB 121.08 KiB 36.46 KiB ▆▆▆▆█▁▁▁▁▁▁
vue-router.minimal 52.97 KiB 0 B (0.00%) 52.84 KiB 149.90 KiB 47.62 KiB ████▁▁▁▁▁▁▁
vue-router.full 58.96 KiB 0 B (0.00%) 58.83 KiB 168.66 KiB 52.87 KiB ▁▁▁▁███████
react-start.minimal 101.91 KiB 0 B (0.00%) 101.77 KiB 321.98 KiB 88.21 KiB ▁▁▁▁▂▂▃████
react-start.deferred-hydration 102.65 KiB 0 B (0.00%) 101.80 KiB 323.36 KiB 88.90 KiB ▁▁▁▂▂▂▂████
react-start.full 105.31 KiB 0 B (0.00%) 105.18 KiB 331.91 KiB 91.06 KiB ███▁▁▁▂▆▆▆▆
react-start.rsbuild.minimal 99.63 KiB 0 B (0.00%) 99.46 KiB 316.43 KiB 85.79 KiB ▃▃▃▁▂▂▃████
react-start.rsbuild.minimal-iife 100.03 KiB 0 B (0.00%) 99.87 KiB 317.37 KiB 86.08 KiB ▃▃▃▁▂▂▃████
react-start.rsbuild.full 102.86 KiB 0 B (0.00%) 102.68 KiB 326.48 KiB 88.53 KiB ███▁▁▁▁▅▅▅▅
solid-start.minimal 49.60 KiB 0 B (0.00%) 49.47 KiB 151.93 KiB 43.79 KiB ▆▆▆▆█▁▁▁▁▁▁
solid-start.deferred-hydration 52.86 KiB 0 B (0.00%) 49.53 KiB 159.97 KiB 46.81 KiB ▄▄▄▄█▁▁▁▁▁▁
solid-start.full 55.40 KiB 0 B (0.00%) 55.27 KiB 168.97 KiB 48.80 KiB ▅▅▅▅█▁▁▁▁▁▁
vue-start.minimal 71.02 KiB 0 B (0.00%) 70.89 KiB 207.04 KiB 62.93 KiB ▁▁▁▁███████
vue-start.full 75.01 KiB 0 B (0.00%) 74.88 KiB 219.68 KiB 66.40 KiB ▁▁▁▁███████

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7625

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7625

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7625

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7625

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7625

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7625

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7625

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7625

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7625

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7625

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7625

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7625

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7625

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7625

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7625

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7625

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7625

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7625

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7625

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7625

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7625

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7625

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7625

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7625

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7625

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7625

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7625

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7625

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7625

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7625

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7625

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7625

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7625

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7625

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7625

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7625

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7625

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7625

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7625

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7625

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7625

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7625

commit: 7def91e

@codspeed-hq

codspeed-hq Bot commented Jun 13, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 45.01%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 78 (👁 78) regressed benchmarks
✅ 15 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ssr server-fn raw-stream (react) 125 ms 106.4 ms +17.46%
Simulation ssr server-fn raw-stream (solid) 130.7 ms 111.7 ms +17%
Simulation ssr server-fn raw-stream (vue) 128.4 ms 110.5 ms +16.26%
👁 Simulation ssr not-found (vue) 73.3 ms 168.8 ms -56.57%
👁 Simulation ssr head (vue) 147 ms 324.9 ms -54.75%
👁 Simulation ssr loaders (vue) 94.4 ms 136.7 ms -30.94%
👁 Simulation ssr selective (vue) 72 ms 139.8 ms -48.48%
👁 Simulation ssr server-fn POST (vue) 49.6 ms 71.4 ms -30.43%
👁 Simulation ssr server-route middleware (vue) 44.8 ms 63.2 ms -29.25%
👁 Simulation ssr server-route (vue) 33.6 ms 60.7 ms -44.56%
👁 Simulation ssr assets inline-css cdn (vue) 82.3 ms 187.6 ms -56.1%
👁 Simulation ssr assets linked-css control (vue) 72 ms 214.5 ms -66.43%
👁 Simulation ssr before-load chain (vue) 127.3 ms 183.8 ms -30.72%
👁 Simulation ssr control-flow error 500 (vue) 92.9 ms 198.1 ms -53.13%
👁 Simulation ssr control-flow route headers (vue) 88.6 ms 213.4 ms -58.51%
👁 Simulation ssr control-flow unmatched 404 (vue) 128.5 ms 190.1 ms -32.39%
👁 Simulation ssr global-mw document (vue) 92.4 ms 221 ms -58.18%
👁 Simulation ssr global-mw server-fn (vue) 48.8 ms 59.9 ms -18.65%
👁 Simulation ssr global-mw server-route (vue) 29.6 ms 71.6 ms -58.6%
👁 Simulation ssr rewrite localized (vue) 80.1 ms 177.3 ms -54.85%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf-ssr-calibrate-iterations (7def91e) with main (a2b9d51)

Open in CodSpeed

@Sheraff Sheraff merged commit 36ed574 into main Jun 13, 2026
20 checks passed
@Sheraff Sheraff deleted the perf-ssr-calibrate-iterations branch June 13, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant