Repository navigation
Keep compare borders aligned when line heights change - #3077
tobiasmelcher wants to merge 1 commit into
Conversation
2811a31 to
51a28ab
Compare
|
In case you need an extra reviewer for a critical change in the new compare, please ping me in the corresponding PR. |
Thanks for the offer, @vogella! This fix concerns the traditional two-way compare rather than the new unified diff view. It addresses a cache invalidation problem observed on macOS in the line-height caching introduced by #1492, while preserving its performance benefits. Would you still be interested in reviewing it? |
|
I reproduced the misaligned borders on macOS without the change: after scrolling into lines with emoji and back up, the boxes sat several lines away from the change. With this PR they stay on the changed lines. Feedback:
|
51a28ab to
aba9009
Compare
|
Thank you very much, @vogella, for reproducing the issue and for such an excellent, thorough review! I've applied your feedback: the tests now run in the Compare suite with license headers, the duplicate check is removed, and cache invalidation preserves entries before the first mismatch. All 179 Compare tests pass. Do you have a skill or prompt for agent-assisted code reviews that you could share? I should have caught the missing headers and suite registration in my own local agent review, and I'd really appreciate learning from your approach. |
Technical feedback is arriving soon.
Which model are you using? Opus 5.5 should have caught that. And for this review, I think I ask Opus "What do you think about PR 3077", nothing fancy. Simplicity rules with the new models. |
|
Taking y from
Points 1 to 3 depend on whether the no-cache path is fast enough. If it is, using |
Use SWT line coordinates to keep compare geometry aligned after scrolling while retaining the height cache. Validate populated entries before drawing, preserve entries before the first mismatching line and bypass the cache while widget metrics disagree. Add geometry and scrolling regressions to the Compare CI suite. Fixes eclipse-platform#3076
|
Thanks for the review. I tested a two-way Java compare with two 31,005-line files and 5,168 differences. The performance tests, results and replay scripts are supplied separately as a ZIP attachment to this comment; the performance tests are not part of the PR. compare3077-performance-tests.zip Test machine: a desktop cloud VM with a fairly slow CPU: Intel Xeon Gold 6338N @ 2.20 GHz, 8 virtual CPUs, 32 GiB RAM, Windows 11 Enterprise, VMware, and SapMachine JDK 25. The absolute times reflect this cloud desktop; they should not be taken as timings for a fast local workstation. All versions used the same machine and current SWT/JFace/JDT runtime. I replayed the historical height calculations, rather than building complete old Eclipse releases.
I measured three things: opening the compare until both text panes had painted, scrolling to the middle until both panes had painted, and repainting both panes again. Times below are in milliseconds; lower is better. Completed results are medians of four runs after one warmup.
These runs use the 50% line-spacing preference, which produced 5 pixels of spacing here. The old code was stopped by a watchdog while scrolling; its result is an incomplete observation, not a completed timing. The first three rows show the old code without caching, the first cache implementation, and the cached code immediately before this PR. The next row is this PR as reviewed. I then tried two alternatives: skipping cache validation, and calculating heights directly from SWT's current line coordinates. The final row is this PR with caching also allowed at zero line spacing. I propose keeping the cache and its validation, and fixing the zero-spacing restriction. Opening alone misses the old performance problem: scrolling is where the pre-cache code became stuck. Using live coordinates also made repainting over four times slower than this PR as reviewed, and about three times slower than the final fix. PR #1492 did not include an automated reproducer; its linked issue #2143 describes a manual large-file reproduction. Compared with the cached code just before #3077, the final fix made the measured middle scroll about 53% faster (3,284 to 1,554 ms). Opening was about the same (2,482 to 2,449 ms), while repainting was about 8% slower (544 to 588 ms). The fix improves middle-scroll performance and addresses correctness, but it does not improve every timing. This comparison uses the recorded pre-#3077 revision, not a fresh measurement of today's master. I consider the measured 8% repaint slowdown an acceptable tradeoff for the correctness fix, especially with the substantial improvement in middle scrolling. I would proceed with the cache, validation and zero-spacing fix in this PR.
You were right that caching was disabled in some setups. I reproduced zero line spacing with extra vertical space above some lines, as used for code minings. The new correctness regression fails on the reviewed PR and passes with the fix. In that scenario:
Repainting improved, but the first middle scroll was slower. The positive-spacing repaint was also slower in the final run (588 vs 404 ms), with variable samples. I have included both fixed runs in the attachment; the cause of that increase is not established.
Validation did not show a significant cost here: disabling it changed repainting from 404 to 399 ms. A separate measurement of validation alone took 0.11 ms for the cache populated by this workload and 0.79 ms with all 31,005 lines populated. These results support keeping the correctness checks for this workload.
I am leaving the minor cleanup in point 4 unchanged. If you consider it important, please handle it in a separate PR so I can focus on the correctness and performance work here.
I implemented point 5: the geometry/paint methods are package-visible, and the tests call them through the existing internal test adapter instead of reflection. A fresh Maven |
aba9009 to
3b1bf65
Compare
|
Thanks for the performance result, they look good to me, 53% is nice. :-) You also ask for tips with using LLMs, one thing which would make looking at your responses more efficient for me, is if you would instruct your AI Engine to write more concisely. For example, add a memory which says: "Answer concisely in pull requests and use concise descriptions for new PRs." |
Fixes #3076.
Keep traditional Compare borders, connectors and hit detection aligned when SWT discovers new line metrics after scrolling. Use SWT's line coordinates while retaining Compare's height cache, preserving entries before the first mismatch and validating only populated entries. The geometry and scrolling regressions now run in the Compare CI suite.
A local macOS geometry-only benchmark with 100,000 lines, 500,000 color-only style ranges, 50-pixel spacing and 200 change positions measured a warmed median of 8.07 ms for the original production code and 5.26 ms for this change, including six cache validations. These indicative measurements invoke the production geometry methods; they are not timings for a complete editor repaint.