Skip to content

Performance pass ​

This page sets direction: when to run, what to aim for, in what order and when to stop. It names no tools or commands. Choose the measurement and repair methods that fit the application, its host and the tools available to you; the targets and rules below are what stay fixed.

When to run ​

  • After acceptance. Run for every role and surface that independent acceptance reports CONVERGED for a new application or a feature, before reporting done. Never optimize behavior that has not been accepted: report each BLOCKED or UNVERIFIED role or surface as it is, with what it needs, and leave it out of the pass. Stop without running only when no part is CONVERGED.
  • On request. When a user reports a slow page, slow first request or slow query, run only the part that covers it, then check the others it could affect.

Choose what to run ​

Decide from the manifests, the service entry and the changed files, not from guesses about future use. Run every part whose condition holds; record each skipped part with its reason.

RunWhen the application or change hasSkip when
Front endPages a browser opens directly that the application authors: public pages, member pages, a custom frontend, Admin customisationsThe only browser UI is SDK-built Admin, unchanged; MCP and REST alone have no page to measure
Cold startA deployed Worker or service entry: always for a new application; for a change, any added or moved import in the entry, its startup graph, a page's or an MCP App entry's first-load codeThe change touched no import, entry, page or MCP App bundle
Backend readsViews, or Store reads in handlers, whose rows grow with data: lists, search, paging, joins, aggregates, totals, reportsOnly id lookups and small, bounded configuration tables
Backend writesProcedures or Store writes that run often or concurrently: stock, counters, approvals, checkout, importsRare single-row administrative writes

A change in one part can move another: an added index slows writes, a shared stylesheet or entry import affects every page. Re-measure what a repair can reach.

Plan the pass ​

The plan the user approves before the build (Build from a product brief) says in plain words how much sample data there is and what "fast enough" means for each page. Behind it, the pass fixes:

  • the parts that run and the parts skipped, each with its reason (the table above);
  • the test data for backend parts: rows per table (for example 1,000,000 RSVPs across 5,000 events and 20,000 members), its shape (owners, states, text length) and that it goes only into an isolated local database;
  • the target for each part and the stop rule below;
  • anything that needs the user, such as a deployment to measure real cold start.

Front end ​

Target: the highest Lighthouse performance score the page allows, with a floor of 90 on mobile and 95 on desktop for every distinct page template, and no regression in accessibility, SEO or best practices.

  • Measure a production build, several runs on mobile and desktop, and report the range. Separate what is real from what only the local environment causes (no compression or HTTP/2, a cold cache) and say which is which.
  • Measure pages behind sign-in (member pages, Admin) through the role's session URL that pnpm accept prints (hand each role), never by weakening sign-in.
  • Find the actual bottleneck before changing anything; a trace beats a guess.
  • Repair in this order: what blocks the first paint (render-blocking styles and font stylesheets, request chains, unused bytes), then main-thread work (heavy scripts, animations, layout of off-screen content), then repeat visits (content-hashed assets cached long, HTML revalidated).
  • When a bottleneck appears only because the measuring environment lacks something (a GPU, a fast CPU), fix it only in a way that also helps real users without it. Never detect the measuring tool to serve it a different page.
  • A cache in front of the Worker removes the render from repeat visits; caching gives the headers it needs and what it must never store.
  • After every change, prove nothing else moved: the page looks the same, links, forms and in-page anchors still work, and the public-page checks still pass without JavaScript.

Cold start ​

Target: budgets that force code to load when it is needed, not before.

  • Worker: its startup graph imports only what every request needs; auth, MCP, Admin and rarely used routes load on the request that uses them (size and startup). On Workers the startup graph is the entry chunk mantle bundle writes under <outdir>/worker plus the chunks it imports statically (outputs); anything behind a dynamic import is outside it. Report its size locally as the Worker entry static graph; measure the host's startup time only on a deployment the user has authorized, and keep it well under the host's limit (aim below 50 ms on Cloudflare).
  • Pages: each page's first-load JavaScript is at most 100 KB, and only what the first paint and first interaction need. Move the rest behind dynamic imports, on use or when the browser is idle. An MCP App the application authors holds its first-load JavaScript, the inline script text of its one HTML file, to the same budget; it renders inside a host, so Lighthouse does not measure it. Report the whole MCP App HTML document as its own number: it also holds CSS and markup, so never compare it with this budget.
  • Use the one definition of each metric in size metrics, with its measurement. Where the SDK's own checks measure differently, that page says how.
  • An overrun is a finding to repair by splitting, not a budget to raise. Raise a budget only with the user's agreement and record why.

Backend ​

Target: every read and write the application's surfaces actually make stays fast at a realistic volume, and no hot path scans a table that grows.

  • Data: seed an isolated local database, never a shared or production one, with data shaped like real use: several owners and roles, every state, long text where fields allow it, and more than one page of results everywhere. Size the largest tables at 100,000 rows or 10 times the expected first-year volume, whichever is larger. Seed with SQL straight into that database, setting the native columns as reserved entry columns describes: it is test data, not an application write. Seed the database the app's local dev server uses, not the one a test harness creates and throws away, and generate the rows inside the database in one short statement rather than sending a long list of values: local D1 refuses a single statement over about 100 KB. Seed in bulk shows both.
  • Load: call every View and Procedure through the same callers and surfaces the application uses, as each role. The app's local test harness already starts it on a fresh database, signs each role in and calls routes and MCP tools as that role (local HTTP checks). Record typical and slow-tail latency and rows read, then run concurrent writers wherever contention matters. A business rule that breaks under concurrency (oversell, double approval, lost update) is a correctness defect, not a performance finding: fix it first.
  • Aim: hot reads stay in the tens of milliseconds locally at seeded volume, and their cost does not grow with table size.
  • Repair in this order:
    1. Read the native query plan of each hot path, using the SQL in its generated query module under generated/ against the seeded database; a full scan of a growing table is a finding.
    2. Add the index that serves it in the Schema's indexes (indexes) together with a native migration (database changes). Index only what a measured query uses; every index costs writes. Read the plan on a database that reached the schema through migrations too: a fresh one has every index, so a migration that left one out shows only there. Paged Views and Schema locks are index-proven already: generation refuses one no index serves.
    3. Move complex reads (joins, aggregates, OR, reuse) into an internal View, page with keysets (results and paging), and replace exact totals on hot paths (search and totals).
    4. Re-measure reads and writes after each repair.

Rules ​

  • Speed never buys a lower standard: scope, authorization, OCC, atomicity, accessibility, the public-page requirements and every explicit user requirement stay intact. The application's writes still go through Store and Procedures; only seed data for the isolated test database is inserted directly.
  • Do not lower a target, shrink the seeded data or drop a slow case to pass. Report what is left instead.
  • Work locally. Deploying or measuring a deployment follows the deploy guide and needs the user's authorization.
  • After any repair, rerun the local HTTP checks. A repair that changes what a user sees or can do is no longer only a performance change: re-run acceptance for the scope the re-verification rule names. A changed View or Procedure widens it to every surface that reads or writes that data, and so does a uniqueIndexes entry. A non-unique indexes entry and its migration keep the business rules: run pnpm check, the local HTTP checks and your focused regressions, not acceptance.
  • Report app-added cost and SDK-existing cost separately. Built-in Admin has a recorded baseline per SDK version; while the installed version and Admin entry are unchanged, reuse it instead of repeating that experiment each round. Built-in Admin's page and MCP App both miss the first-load budget; that is SDK-existing cost, not the application's. A target the SDK's cost misses is still PARTIAL, with its owner named. Never relabel it PASS.
  • Do not patch vendor or SDK code, remove native Admin features or build a general benchmark framework to meet a target.
  • Stop when every target is met, after three rounds, or when two rounds in a row bring no measurable gain.

Summarise for the user ​

Report each change with the number it moved, so the gain is visible:

markdown
| Part | Change | Before | After |
| --- | --- | --- | --- |
| Backend read: `event-roster`, 1,000,000 RSVPs | index `[eventId, created_at]` + keyset paging | p95 1,840 ms | p95 38 ms |
| Front end: `/events/{slug}` (mobile) | inline critical CSS, sized images | Lighthouse 71 | 94 |
| Cold start: Worker entry | auth and Admin behind dynamic imports | 212 KB gzip startup graph | 61 KB |

Give the data volume beside every backend number, the device and throttling beside every Lighthouse score, and say where a target is still missed and why.

Report ​

For each part: run or skipped (with the reason), the environment, before and after numbers as ranges, what changed and what is left. Name the roles and surfaces left out because acceptance did not converge on them. Close with one verdict beside the acceptance verdict: PASS (every target that applies is met), PARTIAL (improved, with the targets still missed and why) or SKIPPED (nothing applied).