flâneur

Beating Myers algorithm on large diffs

jzhao.xyz · 1,494 words · saved by 2 readers

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