# ADR 0012 — Compiled profile

**Status:** accepted. **Date:** 2026-12-03.

## Context
The compiled profile is an option to be measured, not as the default: a single executable makes
delivery easier on servers without Bun (municipalities, restricted environments), but it is only justified without any loss of performance or
compatibility.

## Decision
- `fellow build --profile compiled` produces Nitro's production output and compiles it with `bun build --compile`
  (`.output/compiled/<name>`), copying `public/` next to the executable.
- Nitro's output anchors paths on `import.meta.url` (`globalThis.__nitro_main__`), which inside an executable
  points to the virtual file system. Fellow rewrites only that line to point to the executable's
  directory; if the shape of Nitro's output changes, the build fails with `build.unsupported_output` instead of producing a
  broken binary.
- The production profile (`bun .output/server/index.mjs`) remains the default.

## Evidence
`bun benchmarks/profiles/run.ts` on the example application (Bun 1.4.4, linux-x64, 4 CPUs, 32 connections, 5 s), with
the executable copied to another directory:

| Measure | Production | Compiled |
|---|---|---|
| Startup (median of 5) | 190 ms | 170 ms |
| Idle memory / after load | 46 / 72 MB | 49 / 75 MB |
| `/__fellow/health` | 77.8k req/s | 76.4k req/s |
| Authenticated listing with RLS | 4,017 req/s, p99 15.6 ms | 4,396 req/s, p99 13.6 ms |
| Creation (201) and static asset (200) | ok | ok |
| Size | `.output/` | 104 MB executable |

Results in `benchmarks/profiles/results/`. The throughput differences are within run-to-run variation.

## Consequences
- Same performance, slightly faster startup, large executable (it includes the runtime).
- Migrations and the CLI are not included in the executable: they run from the release's code, before the instances start.
- Depends on a detail of Nitro 3's output (a release candidate); the shape test guards against changes.

## Risks and conditions for reassessment
A change in Nitro's output or in Bun's `--compile` (reassess on every upgrade of either); a need to embed
the assets in the executable; if the compiled profile becomes consistently faster, consider making it the
default for non-container targets.
