Avoid redundant content reads when opening a compare editor#2804
Draft
vogella wants to merge 1 commit into
Draft
Avoid redundant content reads when opening a compare editor#2804vogella wants to merge 1 commit into
vogella wants to merge 1 commit into
Conversation
Opening a compare editor read each side's contents up to 15 times: the content and structure switching panes looked the viewer descriptors up twice per pane, and every lookup re-ran content-type sniffing and the text heuristic against a fresh stream. The panes now cache the descriptor array computed while creating the viewer, and the sniffing results are memoized per element for the duration of one open, keyed by element identity and reset whenever a different input is examined. Each side is now read at most three times: once for content-type detection, once for the text heuristic, and once for the document shown in the viewer. Viewer selection is unchanged. Contributes to eclipse-platform#2795
Contributor
Test Results 54 files ±0 54 suites ±0 58m 21s ⏱️ -37s For more details on these failures, see this check. Results for commit b13fb21. ± Comparison against base commit 32aa15c. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening a compare editor read each side's contents up to 15 times: the content and structure switching panes looked the viewer descriptors up twice per pane, and every lookup re-ran content-type sniffing and the text heuristic against a fresh stream. The panes now cache the descriptor array computed while creating the viewer, and the sniffing results are memoized per element for the duration of one open, reset whenever a different input is examined. Each side is now read at most three times: once for content-type detection, once for the text heuristic, and once for the actual document; CompareOpenEfficiencyTest's bound tightens from 15 to 3 to lock the improvement in. Viewer selection is unchanged. For inputs whose streams are expensive to produce, such as EGit revisions that re-inflate the blob and re-run smudge filters on every read, this removes most of the I/O on the open path.
Contributes to #2795