Introducing a new way to review your PRs.

Read the announcement

shakacode / react_on_rails

Integration of React + Webpack + Rails including server-side rendering of React, enabling a better developer experience and faster client performance.

View on GitHub

19 documents · Updated Nov 18, 2026

docs / performance-benchmarks

Performance benchmarks and rollout validation

The performance benchmark system measures throughput, latency, request health, and Node renderer rollout behavior under repeatable conditions. It supports local trend runs on dedicated hardware, same-run base-versus-head comparisons, manual hosted diagnostics, and CI reporting that blocks unreliable or significant regressions from being treated as valid results.

Benchmark system

The benchmark system turns a selected application scenario into a production-like server run and a machine-readable result. It keeps the application under test separate from the measuring harness so a harness change does not appear as an application performance change.

The system evaluates three hosted runtime scenarios and one standalone developer-experience scenario:

  • Core: Rails application routes measured with k6.
  • Pro: Pro Rails application routes measured with k6.
  • Pro Node Renderer: Node renderer requests measured with Vegeta over HTTP/2 cleartext.
  • Rails-tier developer experience: Matched generated Rails starters measured in a browser for cold startup, React Fast Refresh, and development error feedback.

The developer toolchain provides the wider build and delivery context. Application scaffolding explains how the dummy applications used by these scenarios are created, while build, test, and release automation covers the other CI paths.

References: benchmarks/README.md• L3-22 benchmarks/…/README.md• L1-18

Benchmark workloads

The workload harness warms each route, sends requests at either maximum throughput or a fixed rate, and records requests per second plus latency percentiles. It also records response status groups so a high throughput result cannot hide failed requests.

k6 route workloads

The k6 workload measures HTTP routes exposed by the Core and Pro Rails applications. It can discover routes from the Rails app or accept an explicit route list, then assigns routes to shards when a suite has enough work to run in parallel.

Each route receives a short warm-up before its measured samples. A single run reports the median latency, p90 latency, throughput, and status counts. CI can run three samples per route and reports the median across those samples; the raw sample values remain available for comparison checks.

The k6 workload has two rate modes:

  • Maximum throughput: uses a fixed number of virtual users for the duration.
  • Constant rate: aims for a requested requests-per-second value and can grow to a configured maximum number of virtual users.

The workload opens a fresh connection for each request. This reduces variation caused by a persistent connection staying with one Rails worker. The test does not use default k6 thresholds because the benchmark tracker applies the result and regression policy.

References: benchmarks/bench.rb• L10-28 benchmarks/bench.rb• L170-199 benchmarks/bench.rb• L232-307 benchmarks/k6.ts• L1-20 benchmarks/k6.ts• L38-76

Node renderer workloads

The Node renderer workload measures direct render requests against production bundles. It checks both a small JavaScript evaluation and a React server render when the matching bundle type is available. This isolates renderer throughput and latency from Rails route work.

The workload discovers production bundles and separates React Server Component bundles from non-RSC bundles. It sends Vegeta requests over HTTP/2 cleartext with the renderer protocol headers, then merges shard output into one report so the percentiles represent the complete sample set.

The result contains throughput, p50 and p90 latency, response status counts, and a human-readable summary. A failed test does not produce a benchmark payload. The suite exits with failure instead of allowing incomplete or fabricated measurements into the trend.

References: benchmarks/bench-node-renderer.rb• L1-9 benchmarks/bench-node-renderer.rb• L49-68 benchmarks/bench-node-renderer.rb• L122-152 benchmarks/bench-node-renderer.rb• L409-456 benchmarks/bench-node-renderer.rb• L460-505

Rails-tier developer-experience workloads

The Rails-tier developer-experience harness compares two pinned generated Rails starters through a real browser. It measures the time from the normal bin/dev process start to browser-ready React, then measures source edit to browser-observed Fast Refresh while checking that typed React state survives.

The harness uses at least five samples per stack. It alternates cold-start order and uses a fresh ignored starter copy for each cold sample. It records runtime versions, hardware, the harness commit, raw samples, and a descriptive generated-configuration audit so a result can be replayed and placed in its limits.

The comparison is a development workflow measure rather than a production performance score. It includes Rails boot, asset startup, browser rendering, and state-preserving refresh. It does not measure production builds, error-overlay behavior, click-to-editor behavior, or how easy a configuration is to learn.

References: benchmarks/…/README.md• L1-18 benchmarks/…/run.mjs• L20-56 benchmarks/…/run.mjs• L59-101 benchmarks/…/recorded.json• L26-57

Overlay verification

The overlay verifier adds controlled compile and runtime errors to the same pinned starters and checks the browser feedback path. It validates the error marker, the original TSX source location, compile-error click-to-editor behavior, and recovery to a healthy marker after the source is restored.

Compile and runtime probes run in separate browser sessions. A temporary editor recorder checks the exact copied source path, line, and column without opening a local editor. The harness isolates each starter in a temporary workspace, records the environment, removes local paths from evidence, and rejects a run that starts from a dirty committed worktree.

The recorded comparison is a diagnostic matrix rather than a product verdict:

StackCompile overlayRuntime overlay with original source frameCompile-error click-to-editorRecovery
React on Rails + RspackPASSFAILFAILFAIL
Inertia Rails + VitePASSFAILFAILPASS

These results record behavior on one machine and do not by themselves identify a product defect. Compile recovery is coupled to the editor-click probe in the same session, while runtime recovery uses a separate session. Run pnpm run verify:overlays for local evidence and pnpm run check to validate the helper tests and generated report.

References: benchmarks/…/README.md• L36-54 benchmarks/…/overlay.mjs• L25-78 benchmarks/…/overlay.mjs• L81-147 benchmarks/…/overlay.mjs• L149-264 benchmarks/…/overlay-helpers.mjs• L4-65 benchmarks/…/overlay-report.mjs• L9-25 benchmarks/…/OVERLAY_RESULTS.md• L1-25 benchmarks/…/overlay-recorded.json• L26-107

Generated result reports

The result report turns raw samples into a comparison table with medians, observed ranges, and a noise-aware classification. The report generator recomputes the summary from the raw samples and checks that the recorded Markdown is current, so a hand-edited result cannot silently disagree with the evidence.

The classification marks a comparison as ambiguous when either stack has a spread above half its median. Otherwise, a difference inside the larger observed spread is a wash; only a difference outside that band is called an improvement or regression. Configuration counts remain descriptive and do not represent a usability score.

References: benchmarks/…/stats.mjs• L3-45 benchmarks/…/report.mjs• L9-29 benchmarks/…/report.mjs• L31-72 benchmarks/…/RESULTS.md• L1-37

Node renderer rollout measurements

The rollout harness tests the period in which a renderer has a new bundle generation while old traffic still arrives. Its goal is to show whether startup prewarming, bundle identity, VM pool reuse, draining, and memory behavior remain safe during a rolling change.

The harness creates old and new bundle sets from a small fixture. It prewarms the declared current generation, sends serial fixed-rate requests to the old set, waits through the drain period, and sends the first request to the new set. It measures startup prewarm time, old-request latency, first-new-request latency, VM context builds, evictions, retained contexts, and memory use.

The report states its topology and its limits. It is a runtime pool test, not a full Rails workload or a visual test. It excludes disk seeding, worker startup, HTTP upload, network delay, and concurrent saturation. Release evidence requires fresh processes and at least five quiet repeats.

flowchart LR
    A[Create old and new bundle sets] --> B[Prewarm current generation]
    B --> C[Measure serial old-generation traffic]
    C --> D[Wait for drain timeout]
    D --> E[Measure first new-generation request]
    E --> F[Report latency, pool, memory, and rollout state]

References: benchmarks/bench-node-renderer-rollout.mjs• L91-173 benchmarks/bench-node-renderer-rollout.mjs• L202-267 benchmarks/bench-node-renderer-rollout.mjs• L268-354

Local benchmark comparisons

The local runner is the trusted source for performance trends because it runs the checked-out suite on dedicated hardware. It builds the selected dummy app, starts the production server or Node renderer, runs the workload, checks that the target stayed healthy, and can upload the result to Bencher.

The local A/B runner compares two refs on the same machine. It creates temporary worktrees, waits for a quiet machine window before each sample, runs the refs in balanced order, and writes per-run artifacts. It then produces a JSON summary and a Markdown summary with the largest route improvements and regressions, including median RPS and coefficient of variation.

Uploads are opt-in for comparisons. This lets engineers inspect exploratory results without adding them to the shared performance trend. When uploads are used, the runner keeps the baseline and candidate series distinct and only resets a non-main series on its first repetition.

References: benchmarks/README.md• L6-22 benchmarks/run-local-benchmark.rb• L4-18 benchmarks/run-local-benchmark.rb• L57-89 benchmarks/run-local-benchmark.rb• L185-226 benchmarks/run-local-benchmark.rb• L261-316 benchmarks/run-local-benchmark-comparison.rb• L4-10 benchmarks/run-local-benchmark-comparison.rb• L44-107 benchmarks/run-local-benchmark-comparison.rb• L266-285 benchmarks/run-local-benchmark-comparison.rb• L429-441

Comparison matrices

The generated benchmark matrix maps a selected suite to the job inputs needed to build, serve, measure, name, shard, and report it. This keeps suite behavior in one data model and lets the workflow pass one complete row into each reusable benchmark job.

The matrix selects suites only for an explicit workflow_dispatch run. Push and pull request events keep the hosted suites off because shared runners are too noisy for a trusted trend. The matrix can filter by application version, suppress a run for non-runtime changes, and emit a safe placeholder row when no suite is selected.

Sharding is suite-specific. An explicit route list with fewer than ten routes uses one shard; a larger list can use the configured shard count. Each shard receives a stable job name, Bencher series name, artifact suffix, report marker, and route subset. Matrix specs protect these names and gates because a mismatch can silently attach results to the wrong series.

References: benchmarks/generate_matrix.rb• L10-23 benchmarks/generate_matrix.rb• L30-68 benchmarks/generate_matrix.rb• L70-118 benchmarks/generate_matrix.rb• L124-202 benchmarks/generate_matrix.rb• L204-227 benchmarks/…/benchmark_matrix_spec.rb• L52-190 benchmarks/…/benchmark_matrix_spec.rb• L192-235

CI benchmark gates

The benchmark workflow has two roles: script validation runs on normal workflow events, while hosted workload runs are manual diagnostics. The validation jobs cover the benchmark script specs and the isolated Rails-tier developer-experience package. The trusted trend comes from the dedicated local runner rather than automatic shared-runner measurements.

For a manual hosted run, CI resolves one comparison base and measures the base and head on the same runner. Both phases use the head revision's benchmark harness while each phase builds its own application code. This makes the instrument constant while preserving the real base-versus-head application difference.

The phase flow is:

  1. Select suites and shards from the generated matrix.
  2. Resolve a concrete base commit.
  3. Build and benchmark the base application.
  4. Restore and build the head application with the same harness.
  5. Validate result files and upload base and head artifacts.
  6. Send the pair to Bencher for relative comparison and workflow reporting.

The gate refuses to trust a run when the benchmark target dies, a Node renderer worker restarts unexpectedly, the expected summary or JSON is missing, a route or renderer test fails, or a result payload is only partial. A real regression can be recorded without failing a local trend run; the explicit fail-on-alert option makes the local command fail when a regression must block a caller.

References: .github/…/benchmark.yml• L17-21 .github/…/benchmark.yml• L77-126 .github/…/benchmark.yml• L128-193 .github/…/benchmark.yml• L195-219 .github/…/benchmark-suite.yml• L1-25 .github/…/benchmark-suite.yml• L243-336 .github/…/action.yml• L1-29 .github/…/action.yml• L276-412 benchmarks/…/benchmark_target_monitor.rb• L1-8 benchmarks/…/benchmark_target_monitor.rb• L43-63

Benchmark result interpretation

The result tables show throughput and latency beside the baseline used for comparison. RPS is better when it rises, while p50 latency is better when it falls. p90 is displayed for context but is not itself a thresholded Bencher measure.

Repeated samples improve the comparison signal. CI sends the median metrics to Bencher and retains sample values so a boundary crossing must repeat across the base and head samples before it becomes a confirmed result. An unconfirmed crossing remains visible without being presented as a firm regression or improvement.

Benchmark numbers describe the measured workload and environment. Use the local comparison artifacts, runtime metadata, route set, sample settings, and caveats together when deciding whether a performance change is real. Use the RSC performance validation guide for browser-level evidence such as visual parity and Web Vitals.

References: benchmarks/…/benchmark_table.rb• L1-40 benchmarks/…/benchmark_table.rb• L99-133 benchmarks/bench.rb• L111-168 .github/…/benchmark-suite.yml• L18-20 docs/…/rsc-performance-validation.md• L44-60

Change checklist

When these files or sections are changed, remember to consider these:

  • Update the suite row and matrix specs together when a suite's tool, app mode, shard count, artifact name, or report marker changes.
  • Keep the k6 and local-runner sample defaults aligned when changing sample count or per-sample duration.
  • Preserve the same benchmark harness for both sides of a base-versus-head comparison.
  • Recheck Bencher measure names and better-direction rules when changing result fields or table columns.
  • Keep target-liveness and renderer-worker-restart checks in step with any change to server startup, logs, or result payload creation.
  • Reassess the local trend source when changing hosted-runner triggers or upload behavior.
  • Keep the Rails-tier DX report generated from its raw result, and keep its summary calculation aligned with the raw sample schema.
  • Preserve the DX harness limits when changing its sample order, cache policy, marker checks, or environment metadata.
  • Keep overlay probe expectations, source-location checks, editor-recorder checks, and recovery states aligned with the generated overlay matrix.
  • Keep recorded overlay JSON and Markdown generated from the same redacted raw result, and keep local replay outputs ignored.

Important failure modes

TriggerConsequenceGuard
A route or renderer test fails during a suitePartial metrics could look like a valid performance resultThe suite records the failure and writes no benchmark payload; the job exits non-zero.
The target process dies during measurementThroughput and latency describe a dead or restarting targetBenchmarkTargetMonitor checks the target PID before payload creation.
A Node renderer worker logs an unexpected restartThe sample includes a changed worker pool stateThe target log is windowed and scanned before metrics are accepted.
The base and head use different harness revisionsHarness changes can appear as application performance deltasCI stashes the head benchmark tree and uses it for both phases.
Hosted shared-runner results are used as the release trendRunner noise can dominate the apparent changeHosted workload runs are manual diagnostics; dedicated local hardware supplies the trusted trend.
A shard or report name changes without its matrix contractResults can be attributed to the wrong Bencher series or artifactMatrix specs pin suite selection, shard labels, names, suffixes, and markers.
The DX raw samples and recorded summary disagreeThe generated comparison can report data that does not match its evidenceverifySummary recomputes the summary and the CI check rejects a stale report.
A DX run starts with fewer than five samples or a dirty worktreeThe comparison loses its minimum repeat count or its source cannot be identifiedThe harness rejects the run before measurement.
A single machine-local DX result is treated as a general product claimHardware, caches, and background load can be mistaken for a universal differenceThe report states its development-only scope and noise limits.
An overlay report is edited without changing its raw resultThe matrix can hide the evidence produced by the browser probeThe report generator rebuilds the Markdown and --check rejects stale output.
A browser probe accepts a generated frame or an incomplete editor targetOverlay support can appear correct while pointing to the wrong sourceThe verifier requires the original TSX path and line, plus the exact workspace path, line, and column for editor clicks.
A source mutation or benchmark session is not restoredLater samples can use stale errors, processes, ports, or stateThe harness uses isolated workspaces, unique markers, bounded recovery checks, and cleanup of process groups, ports, and workspaces.

Key files

FileWhy to read it
benchmarks/README.mdEntry points, trusted local trend policy, hosted diagnostic policy, and the Rails-tier DX benchmark.
benchmarks/run-local-benchmark.rbMain local production benchmark lifecycle and optional Bencher upload.
benchmarks/run-local-benchmark-comparison.rbSame-machine repeated A/B plan, quiet-window control, and comparison artifacts.
benchmarks/bench.rbCore and Pro route workload, warm-up, k6 samples, and result aggregation.
benchmarks/k6.tsHTTP workload modes and request-level status checks.
benchmarks/bench-node-renderer.rbDirect Node renderer workload and Vegeta result collection.
benchmarks/bench-node-renderer-rollout.mjsVM pool and bundle-generation rollout measurements.
benchmarks/generate_matrix.rbSuite selection, sharding, and workflow row generation.
.github/…/benchmark.ymlEvent policy, script validation, manual inputs, base resolution, and matrix dispatch.
.github/…/benchmark-suite.ymlSame-run base/head orchestration, sample policy, and Bencher hand-off.
.github/…/action.ymlPer-ref build, server, benchmark, health validation, and cleanup lifecycle.
benchmarks/…/benchmark_target_monitor.rbSafety checks that reject metrics from a dead or restarted target.
benchmarks/…/benchmark_table.rbHuman-readable baseline deltas and significance markers.
benchmarks/…/benchmark_matrix_spec.rbContract checks for suite gates, shard rows, names, and report markers.
benchmarks/…/README.mdScope, replay method, overlay verification, sample policy, and interpretation limits for the Rails-tier DX comparison.
benchmarks/…/package.jsonLocal benchmark, overlay verification, report checks, and starter preparation commands.
benchmarks/…/run.mjsBrowser-based cold-start and Fast Refresh measurement lifecycle.
benchmarks/…/app-session.mjsShared browser session, environment capture, workspace startup, and cleanup rules.
benchmarks/…/starter-workspace.mjsIsolated generated-starter copies and source marker access.
benchmarks/…/overlay.mjsCompile-error, runtime-error, editor-click, recovery, and evidence collection flow.
benchmarks/…/overlay-helpers.mjsSource-frame matching, editor target parsing, restoration checks, and overlay report generation.
benchmarks/…/overlay-report.mjsRedacted raw-result validation and generated overlay Markdown checks.
benchmarks/…/overlay-recorded.jsonRecorded browser evidence with environment, method, and per-stack outcomes.
benchmarks/…/OVERLAY_RESULTS.mdHuman-readable generated overlay comparison and its interpretation boundary.
benchmarks/…/stats.mjsMedian, spread, and noise-aware comparison rules.
benchmarks/…/report.mjsGenerated Markdown report and stale-summary validation.
benchmarks/…/RESULTS.mdRecorded timing comparison output and its interpretation boundary.