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
- GitHub - kyx0r/pikevm: Russ Cox/Rob Pike pikevm regex implementationgithub.com
- CRDTs go brrrjosephg.com
- abseil / Performance Hintsabseil.io
- Peritext: A CRDT for Rich-Text Collaborationinkandswitch.com
- Fast regex search: indexing text for agent tools · Cursorcursor.com
- Shipping at Inference-Speed | Peter Steinbergersteipete.me
- An adventure in realtime collaborative editing — Dov Alperindov.dev
- Scaling long-running autonomous coding · Cursorcursor.com
- Levenshtein distance - Wikipediaen.wikipedia.org
- Coding Models Are Doing Too Much | whnrehiew.github.io
- Speed mattersscattered-thoughts.net