The Code/X ArchiveView on X
Vox

@Voxyz_ai

Tell Claude Code to "make it faster" and it'll probably ๐—ฎ๐—ฑ๐—ฑ ๐—ฎ ๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ฒ. People who actually do perf work ๐—ป๐—ฎ๐—บ๐—ฒ ๐˜๐—ต๐—ฒ ๐—ฒ๐˜…๐—ฎ๐—ฐ๐˜ ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐˜๐—ต๐—ฒ๐˜† ๐˜„๐—ฎ๐—ป๐˜ instead:

"Do a performance review of this project:
1. Run a profile first. Find the 5 slowest spots and how much time each one takes.
2. Check each spot against the cases below and only apply the one that matches:
- It uses a cache: caching is cope for a slow design. Don't add more caches. See if it can be redesigned to be fast on its own. List the existing caches and flag which ones are hiding a slow design.
- A hot loop keeps hitting hash tables: 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?
- Lots of objects, but each pass only reads one or two fields: should this be a structure of arrays instead of an array of structures (AoS โ†’ SoA)?
- Independent awaits running one after another: run them in parallel.
- Nothing matches: how do we rewrite this to better leverage data-oriented design principles?
3. For each spot, write down how much time it takes now, which case it matched, which file and lines to change, and the expected speedup.
Give me the report first. Don't change anything."
Image from the post

Jarred Sumner @jarredsumner

some things I often say to claude when doing perf optimization work:

> 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

Quoted post on X โ†’

1922425681