~/talk

Understanding Escape Analysis to Speed Up Your Code

Talkat GopherCon 2025 · 2025-08-26..08-28· [go]
slides:none on file

Compares two string-search implementations with benchmarks and memory profile (p.out -> pprof) output, showing one version originally does ~53 bytes and two allocations while the alternative runs as a zero allocation algorithm. Uses go test -bench, go tool pprof and an escape analysis report via GC flag -M2 to find an interface conversion and an inlining decision that forces a heap escape. After replacing the io interface with direct method calls allocations disappear and latency drops from ~600ns to ~300ns, but the other algorithm still runs ~100% faster.

AI-written summary · about

  1. 0:00The elvis replacement story
  2. 1:31Comparing alternative code
  3. 2:58Benchmarking the algorithms
  4. 4:24Memory profiling results
  5. 5:53Escape analysis investigation
  6. 7:28Optimizing with polymorphism
  7. 11:20Achieving zero allocations
  8. 14:09Compiler optimization tricks
  9. 16:10Final profiling and takeaway
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.