Chapter 8: Maintenance
Most engineering time is spent changing systems that already work. A system that cannot change safely is already failing slowly, so maintenance is a skill in its own right, with its own techniques: versioned formats, dual-read migrations, dependency hygiene, and bisection. This chapter applies them to the running system, after its first stable release.
Concepts from other sections (9)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- KV cache: the stored keys and values of earlier tokens, bytes per token. Read more: 11.1 Counting: parameters, FLOPs, KV bytes, and memory plans in Mathematics
- fp8 E4M3: an 8-bit float with 1 sign, 4 exponent (bias 7), and 3 mantissa bits; largest finite value 448, no infinity. Read more: 8.1 Interface migration: KV format v1 to v2
- Consistent oracle: a test that says “good” for every commit before the culprit and “bad” for every commit from it on. Read more: 8.4 Performance regression bisect
- Perf gate: a check that fails a change when head is slower than base by more than the budget. Read more: 3.4 Benchmarks and perf gates
- Block pool: one slab of fixed-size KV blocks handed out by id. Read more: 21.8 A paged KV block pool in C in AI Engineering
- OpenTelemetry (OTel): the vendor-neutral standard for traces, metrics, and logs, made of an SDK, a collector, and exporters. Read more: Chapter 11: Observability in Systems Engineering
- Resolved graph: the exact versions a build uses after resolution, recorded in the lockfile, as opposed to the version requirements. Read more: 8.3 Dependency upgrades
- Reproduction envelope: the fixed metric, workload, host, configuration, and sampling under which every revision is measured. Read more: 8.4 Performance regression bisect
- Regression rule: a predeclared threshold, here a relative and an absolute bound, that decides good or bad. Read more: 8.4 Performance regression bisect
Every migration here follows the same shape. Make the change additive, prove both sides work with tests, roll out behind a switch, and remove the old path only when telemetry shows nobody uses it. Concretely, an interface changes in phases: add the new version, read both, write the new, migrate the data, stop reading the old, and remove it. Each phase is deployable and reversible.
The first two sections are interface migrations carried out under the deprecation policy of the previous chapter. The KV cache format moves from f16 to fp8 E4M3 blocks with per-(layer, head) scales, with readers upgraded before writers and mixed versions negotiated during rollout. The public API moves from v1 to v2 under the openai-subset.v2 contract, served alongside v1 with Deprecation and Sunset headers. The last two sections deal with change you did not write and change you did not notice. A dependency upgrade is reviewed like any other change: pin it, read the changelog, run the full suite, and roll it out, checked against the allowlist in allowed-deps.toml. And a performance regression is found by search rather than by staring: a benchmark with a threshold plus git bisect run finds the commit in steps.
Each section has a matching incident drill in Incident Response and Chaos, in Systems Engineering, which rehearses the same procedure on the cluster under pressure.
Learning objectives
- Migrate a binary format and an HTTP API in reversible phases, with readers or both versions live before the switch.
- Validate untrusted input completely before use and make offline conversions atomic and one-way.
- Review a dependency upgrade by its effects, with the merge rule, owner, and rollback fixed in advance.
- Bisect a performance regression with a consistent oracle and confirm the result.
Before you begin
Section titled “Before you begin”You need Releases and Deprecation, whose policy each migration follows, and The Testing Mentality, especially the benchmarks and perf gates. The migrations change parts of the running system built in AI Engineering: the KV block pool from Inference and the serving stack from Serving. The fp8 encoding behind KV v2 is explained in FP8 and microscaling formats in Mathematics. A useful exercise before the last section is to practise git bisect run on a small repository with a planted regression.
In this chapter
Section titled “In this chapter”- Interface migration: KV format v1 to v2: a reader for both formats, per-slab fp8 scales worked by hand, complete validation with checked arithmetic, and an atomic one-way converter.
- Interface migration: API v1 to v2: header-based version selection in the engine and the gateway, deprecation headers, a hard sunset, and per-version metering.
- Dependency upgrades: a model review of an OpenTelemetry family upgrade, built on evidence from the resolved graph, tests, vulnerability scans, and paired benchmarks.
- Performance regression bisect: a reproduction envelope, a predeclared regression rule, and a
git bisect rungate that respects the skip and abort exit codes.
Further reading
Section titled “Further reading”- Software Engineering at Google, ch. 21, Dependency Management, and ch. 22, Large-Scale Changes (free).
- Michael Feathers, Working Effectively with Legacy Code.
- Martin Kleppmann, Designing Data-Intensive Applications, ch. 4, on encoding and evolution.
git bisectdocumentation (free).- Protocol Buffers: updating a message type (free).