Beating Myers algorithm on large diffs
I was profiling our agent process recently to chase down some multi-second stalls that sometimes showed up while editing files. I expected the usual suspects: serialization, the streaming path, maybe some weird look-behind regex.
I was profiling our agent process recently to chase down some multi-second stalls that sometimes showed up while editing files. I expected the usual suspects: serialization, the streaming path, maybe some weird look-behind regex. Instead, one of the largest self-time consumers in the CPU profile was jsdiff! Every time the agent edits a file, the workspace shows a card in the activity feed with a unified diff of the change. That diff was produced by taking the file contents before and after the edit and handing both to jsdiff’s createPatch, which runs the same Myers algorithm git diff uses.…
saved by
related reading
- The Myers diff algorithm: part 1 – The If Worksblog.jcoglan.com
- abseil / Performance Hintsabseil.io
- CRDTs go brrrjosephg.com
- Diffs, by Pierre | Chase McCoychsmc.org
- NYSRGnotes.ekzhang.com
- Why Write Small Diffs - by Ryan Petermandeveloping.dev
- explain-diffgist.github.com
- Unified Versus Split Diffmatklad.github.io
- UI Skills for Design Engineers | UI Skillsui-skills.com
- GitHub · Change is constant. GitHub keeps you ahead.github.com
- Delta | A Multiplayer Environment for Coding with Agentsdelta.dev
- Levenshtein distance - Wikipediaen.wikipedia.org