Skip to content

Read the compared contents once, in the background - #2840

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-prefetch-contents
Aug 3, 2026
Merged

Read the compared contents once, in the background#2840
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-prefetch-contents

Conversation

@vogella

@vogella vogella commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Opening a compare editor read each side three times: once for content type detection, once for the text heuristic and once for the document shown in the viewer. All three happened on the UI thread and each one paid whatever the provider charges for producing a stream; for an EGit revision that means inflating the blob and running the smudge and EOL filters three times over.

The background job that prepares the input now reads the contents once, and both the sniffing and the merge viewer are served from that. Elements backed by a shared document are skipped, since those are served from the file buffer and never read a stream anyway, which is exactly the local side of a typical comparison. An entry is dropped as soon as it became a document, so at most one input's contents are held at a time.

CompareOpenEfficiencyTest's bound drops from 3 reads per side to 1, and I verified that the bound really depends on the prefetch: with the prefetch call removed the test reports 3 again.

Contributes to #2795

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   59m 25s ⏱️ + 3m 22s
 4 703 tests +1   4 681 ✅ +1   22 💤 ±0  0 ❌ ±0 
12 003 runs  +3  11 850 ✅ +3  153 💤 ±0  0 ❌ ±0 

Results for commit c1ff1d1. ± Comparison against base commit 29df77f.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the compare-prefetch-contents branch 2 times, most recently from c8e3000 to fee6afc Compare July 31, 2026 14:34
@vogella
vogella marked this pull request as ready for review July 31, 2026 14:34
@vogella
vogella force-pushed the compare-prefetch-contents branch from fee6afc to 3ec0c54 Compare August 2, 2026 18:16
Opening a compare editor read each side three times: once for content type
detection, once for the text heuristic and once for the document shown in
the viewer, all three on the UI thread and each one paying whatever the
provider charges for opening a stream. For an EGit revision that means
inflating the blob and running the smudge filters three times over.

The background job that prepares the input now reads the contents once and
the sniffing and the merge viewer are served from that. Elements backed by
a shared document are skipped, since those come from the file buffer and
never read a stream anyway.

Only contents that look like text are kept, and only up to 8 MB of them.
The binary viewer stops at the first differing byte, so reading a binary
in full ahead of it would be slower than not prefetching at all, and the
text merge viewer never sees it. Deciding that costs an 8 KB probe. What
is kept is held weakly and dropped as soon as it became a document, so it
goes away with the editor that prepared it even when no viewer asks for it.
The read checks the monitor, so cancelling stays responsive on exactly the
slow providers this targets.

CompareOpenEfficiencyTest's bound drops from 3 reads per side to 1, and a
new test pins the binary side to a bounded number of bytes.

Contributes to eclipse-platform#2795
@vogella
vogella force-pushed the compare-prefetch-contents branch from 3ec0c54 to c1ff1d1 Compare August 2, 2026 18:36
@vogella
vogella merged commit 7beef1c into eclipse-platform:master Aug 3, 2026
18 checks passed
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