Swift at Scale: Where Performance Really Comes From
summary
GoodNotes profiles a hot aggregation path and finds a large Swift struct (58 fields) causing expensive non‑trivial copies; the compiler cannot safely change data layout. They implement a hot/cold split: keep a few hot fields inline and move rare, component‑specific fields into an array of existential updates with last‑write‑wins merging via a visitor. Result: struct size drops 6 KB → 300 B (18×) and end‑to‑end CPU in that path improves 42% faster, proving layout change — not micro‑tweaks — moves the needle.
AI-written summary · about
chapters (10)
- 0:00Introduction and background
- 1:08Performance at scale overview
- 4:00Goodnotes and context
- 6:16Profiling the hot path
- 8:30Data structure analysis
- 14:06Swift cost model
- 19:17Compiler limitations
- 22:58Data layout redesign
- 28:42Results and takeaways
- 30:24Conclusion and Q&A








