perf: speed up exact diff common cases#24
Conversation
|
Interning now maps items to integer IDs using only |
|
Or: add a caller-supplied key (e.g., |
|
Very very good catch! Fixed! |
|
I added an AOT benchmark harness (
It reports median us/iter for sizes 10/100/1000/10000, diff patterns none/few/many, for both int lists and object lists (8-field class with standard Summary:
Full tables (median us/iter, AOT): int
object
This seems at odds with the PR description claiming ~20% to 10x speedups. Can you clarify how those measurements were obtained (workload, inputs, tooling, JIT vs AOT, warmups/samples)? I want to align the benchmark methodology so we compare apples-to-apples. |
6c43d4e to
041589c
Compare
|
Sorry for the long wait. I forgot. I asked codex to rewrite everything and make sure every benchmark had speedups. To also test JIT vs AOT. It should be 1.5~2x faster. Updated here. For even faster, I didn't push, but it is possible to be inspired by https://docs.rs/imara-diff/latest/imara_diff/ which is the fastest diff out there. It adds a 256 cutoff to meyers which makes it up to 36x faster on large changes (10000 | many), however it doesn't guarantee minimal diffs, so it is not 100% equivalent to meyers. If you think that is interesting I can push for you to see. |
|
Thank you! LGTM. I noticed that in some cases this can change the edit script when duplicates are involved, e.g. Both are valid, but I'll release this with a major version bump so use cases that depend on the old order don't break.
Yes! But I think we should make this opt-in and document it, not the default behaviour. |
|
Yay!! Thanks a lot for your patience. Feel free to make a test for that duplication issue so this is known in the future (if behavior ever changes again accidentally) |
|
I don't know if it makes sense to lock-in particular sequences of operations out of the many possible valid ones - I just think if we release an update that might change them, we should do it with a major version bump, especially after so many years of no updates to be conservative and avoid breaking users that accidentally depend on one particular order. |
Summary
This replaces the earlier broad optimization experiment with a smaller exact-Myers optimization pass aimed at common diff workloads and reviewability.
Changes:
equalityCheckeris supplied, becauseHashMapequality may not match the caller's equality semanticstool/bench/bench.dartThe implementation preserves exact diff behavior. There is no heuristic cutoff or intentionally non-minimal mode.
Validation
Local checks on the pushed branch:
dart analyze dart test dart compile exe tool/bench/bench.dart -o build/diff_bench_current ./build/diff_bench_current dart run tool/bench/bench.dartI also ran the same benchmark harness against
masterby copyingtool/bench/bench.dartinto a clean master worktree before compiling, so both binaries used the same measurement code.Benchmark settings:
detectMoves: falseSpeedup is
master / branch, so values below1.00xare regressions. These are local microbenchmarks and the smallest rows are noisy.AOT Benchmarks
JIT Benchmarks
Notes
This does not claim a universal speedup. It materially improves no-change and many object-list workloads, keeps the algorithm exact, and preserves the historical duplicate anchoring covered by issue #15. A few int-heavy few/many rows are neutral to slower; accepting that is preferable to adding an imara-style non-minimal cutoff or changing duplicate matching semantics.