Skip to content

Show a large comparison before computing its differences - #2837

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-async-initial-diff
Jul 31, 2026
Merged

Show a large comparison before computing its differences#2837
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-async-initial-diff

Conversation

@vogella

@vogella vogella commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

TextMergeViewer computed the line diff and the token diffs of every change before the documents were painted, so opening a compare editor left it blank for the whole comparison. Once both sides together exceed 2000 lines, the first comparison now runs in a follow-up UI event, exactly the way the re-diff after an edit already works, and the change highlighting plus the jump to the first difference follow when it is done. Time from openCompareEditor until the text is visible, medians over 15 repetitions on Linux with Xvfb: 237ms to 77ms for 5000 lines with 100 changes, 491ms to 96ms for 5000 lines with 1250 changes, and 427ms to 135ms for 50000 lines with 1000 changes.

Two cases stay synchronous on purpose. Smaller inputs are compared right away, because there the diff costs next to nothing and showing the text and then jumping to the first change would only flicker; that also keeps the existing contract for the many small comparisons that dominate in practice. A refresh is never deferred either, since it restores the cached selection and scroll position, and that cache is dropped as soon as the refresh returns.

TextMergeViewerTest.testLargeInputIsShownBeforeItIsCompared pins the new behaviour and fails without the change.

Contributes to #2795

@vogella
vogella requested a review from tobiasmelcher July 30, 2026 10:01
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   1h 0m 15s ⏱️ + 4m 42s
 4 701 tests +1   4 679 ✅ +1   22 💤 ±0  0 ❌ ±0 
11 997 runs  +3  11 844 ✅ +3  153 💤 ±0  0 ❌ ±0 

Results for commit bb67c21. ± Comparison against base commit 55d7ddf.

♻️ This comment has been updated with latest results.

TextMergeViewer computed the line diff and the token diffs of every change
before the documents were painted, so the editor stayed blank for the whole
comparison. Once both sides together exceed 2000 lines the first comparison
now runs in a follow-up UI event, the same way the re-diff after an edit
already does, and the change highlighting plus the jump to the first
difference follow when it is done.

Smaller inputs are still compared right away: there the diff costs next to
nothing and showing the text and jumping to the first change in two steps
would only flicker. A refresh is never deferred either, because it restores
the cached selection and scroll position which are dropped as soon as the
refresh returns.

Measured on Linux with Xvfb, medians over 15 repetitions, time from
openCompareEditor until the text is visible:

  5000 lines, 100 changes:    237ms -> 77ms
  5000 lines, 1250 changes:   491ms -> 96ms
  50000 lines, 1000 changes:  427ms -> 135ms

Contributes to eclipse-platform#2795
@vogella
vogella force-pushed the compare-async-initial-diff branch from 23b30c8 to bb67c21 Compare July 31, 2026 08:11
@vogella
vogella merged commit 196a2b9 into eclipse-platform:master Jul 31, 2026
18 checks passed
@vogella
vogella deleted the compare-async-initial-diff branch July 31, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant