data-oriented-perf
data-oriented-perf
Make slow code fast by changing how its data is laid out, addressed and traversed, not by layering caches on a slow design. For a small edit on a hot path, ask the four questions below silently and mention only the answers that change the implementation. Pair with maintainable-code when available: a faster design must stay readable.
The four prompts
Jarred Sumner (@jarredsumner, creator of Bun) posted these as things he often says to Claude during perf work (https://x.com/jarredsumner/status/2117037940031496252, 2026-11-01). Keep them verbatim and attribute no other wording to him. The first quote and the start of the second were checked against the post on 2026-11-11; the rest could not be read without signing in:
how do we rewrite this to better leverage data-oriented design principles
can you replace those hash tables with a flat array? can we make the pointers an index into the array? can we pack the most commonly used data into upper bits of the index?
caching is cope for a slow design. do not add caches and delete all existing caches. instead, redesign it to be faster
should this be a structure of arrays instead of an array of structures?
Read them as design pressure on the data the hot path touches and the order it touches it: