Performance Budgets

Sub-50ms TTFB and how we got there.

Squilla treats response time as a feature: every public page should serve in single-digit milliseconds of kernel work, leaving the bulk of any TTFB budget for the network. This post is the engineering note on how we get there.

Where the time goes (and doesn't)

A public page request hits the Fiber router, resolves to a node-handler, fetches the node, runs the filter chain, renders the template, and flushes. The expensive parts are the node fetch and the template render. Everything else is sub-millisecond.

The choices that matter

  • Pre-resolved layout trees. A theme's layouts are compiled at activation time, not at request time. The handler doesn't “look up which layout this page uses” — the layout tree is a hot-swapped pointer.
  • JSONB + GIN indexes. All node fields live in a single JSONB column with a GIN index. Custom node types don't get their own SQL tables; adding a type is metadata-only. Field queries hit the GIN index and return in sub-millisecond time.
  • Atomic config maps. Settings, layouts, and blocks live in maps that the kernel atomically swaps when the theme or extension state changes. Reads never block. There's no read lock.
  • Connection pooling. pgxpool, sized to saturate under expected load. Per-tenant scoping when the deployment uses it.
  • No N+1. Read paths eager-load relations. Code review actively rejects new N+1 patterns.
  • Compression at flush. The kernel handles gzip/brotli at the response writer; templates aren't post-processed.

What we don't do (yet)

We don't ship a public page cache. The kernel is fast enough that cold renders meet our internal goals; adding a cache layer trades simplicity for tail-latency improvement we don't need yet. When we do, it'll be an extension, not a kernel feature.

How we keep it honest

Performance regressions in the kernel block merge. Adding a feature that introduces a per-request DB round-trip is the same kind of change as adding a feature that breaks a test — it doesn't ship. Most of the discipline is just refusing to take on work that doesn't fit the budget.

None of this is novel. It's the boring stuff done deliberately. The shrimp punches fast because it doesn't waste motion.

← all posts