-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Use coverage.collect's coverableLineCache param to speed up coverage
#136851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
coverage.collect's coverableLineCache param to speed up coveragecoverage.collect's coverableLineCache param to speed up coverage
|
wow, impressive benchmarks! |
christopherfujino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. btw, this PR rolls package:coverage, although if that merges first I wouldn't think there would be a conflict and this should still merge cleanly as is: https://github.com/flutter/flutter/pull/136924/files
| @visibleForTesting bool forceSequential = false, | ||
| @visibleForTesting FlutterVmService? serviceOverride, | ||
| bool branchCoverage = false, | ||
| required Map<String, Set<int>> coverableLineCache, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liamappelbe marking this required is a breaking change, and will be difficult to get into Google. Can we mark it as optional for the short term?
… up coverage" (#137121) Reverts #136851 Initiated by: CaseyHillers This change reverts the following previous change: Original Description: One of the reasons gathering coverage information is expensive is that we have to force compile every function in the libraries we're interested in. Without this, functions that haven't been invoked (so haven't been compiled) won't have any line number information, so the coverage tool doesn't know which lines to add to the list of misses. In flutter's case, the test infra spawns many VMs, and each of these needs to recompile all those libraries. To fix this, we need a way of skipping force compilation for libraries we've already seen in previous tests, without losing the information about which lines in each library are coverable. So I [added](dart-archive/coverage#466) the `coverableLineCache` to `coverage.collect` in package:coverage v1.7.0. This cache starts out empty, but fills up with lists of all the lines that are coverable for every library as coverage is gathered. package:coverage can then tell the VM not to force compile any libraries in this cache (using `getSourceReport`'s `librariesAlreadyCompiled` param). So the first test suite will still have to compile everything, but subsequent test suites will be much faster. This speeds up coverage collection significantly, for large test suites: | Running flutter/packages/flutter tests... | Time | Overhead | | --- | --- | --- | | without coverage | 8:53 | - | | with coverage | 20:25 | 130% | | with `coverableLineCache` | 12:21 | 40% | Bug: #100751
…7385) Relands flutter#136851, which was rolled back in flutter#137121 package:coverage has been rolled, so the breakages should be fixed. Also, in this reland I've changed the `coverableLineCache` parameter to be optional, which is safer.
One of the reasons gathering coverage information is expensive is that we have to force compile every function in the libraries we're interested in. Without this, functions that haven't been invoked (so haven't been compiled) won't have any line number information, so the coverage tool doesn't know which lines to add to the list of misses. In flutter's case, the test infra spawns many VMs, and each of these needs to recompile all those libraries.
To fix this, we need a way of skipping force compilation for libraries we've already seen in previous tests, without losing the information about which lines in each library are coverable. So I added the
coverableLineCachetocoverage.collectin package:coverage v1.7.0. This cache starts out empty, but fills up with lists of all the lines that are coverable for every library as coverage is gathered. package:coverage can then tell the VM not to force compile any libraries in this cache (usinggetSourceReport'slibrariesAlreadyCompiledparam). So the first test suite will still have to compile everything, but subsequent test suites will be much faster.This speeds up coverage collection significantly, for large test suites:
coverableLineCacheBug: #100751