perf(codemining): batch and cache the jump code mining labels - #389
Merged
Merged
Conversation
Resolving the "Jump to test/tested ..." code minings ran one JDT search per method and per refresh (2 index searches + 1 call hierarchy search for each method of the file), ie. dozens of searches at every pause while typing. The labels of a compilation unit are now computed in one batch (one single search for the corresponding test cases / classes under test), the call hierarchy search only runs for the methods without test method found by name, and the labels are cached until the structure of the compilation unit or the content of the corresponding files changes (30s safety net). Typing in a method body now costs no search at all. The computed labels are strictly unchanged.
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.
Problem
With the "Jump to test method" code mining enabled, every code mining refresh (ie. every pause while typing) ran JDT index searches per method of the file:
CorrespondingTypeSearcher(search engine)TypeFacade- and thus a new search - was created per mining)MethodTestCallerFinder(call hierarchy)Fix
org.moreunit.codemining.JumpLabelComputer: the labels of all the minings of a compilation unit are computed in one batch, shared by the minings of the refresh → one single search for the corresponding test cases / classes under test (result cached by theTypeFacade);Typical case (typing inside a method body): 0 search. After a structural change: 1 search + at most 1 call hierarchy search per untested method, instead of 3 searches per method at every refresh.
Behaviour is unchanged: the labels ("Jump to test method", "Jump to tested class", ...) are strictly the same - the 6 existing
JumpCodeMiningTestscenarios pass unchanged.Tests
org.moreunit.codemining.JumpLabelComputerTest): labels for methods and types, from a class under test and from a test case; one single computation for all the elements of a file; no recomputation while the structure is unchanged (the typing case); recomputation when the structure changes, when the corresponding test case changes (eg.testFoo()just written in the test file) and when the cache expires.JumpCodeMiningTestscenarios); full unit test run: 2029 tests, 0 failure.Note: a small conflict on
JumpCodeMining.javais expected with #388 (which refactors its jump action); trivial to rebase once either one is merged.