-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add coverableLineCache
param to collect
#466
Conversation
coverableLineCache
param to collect
coverableLineCache
param to collect
coverableLineCache
param to collect
coverableLineCache
param to collect
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.
Is there any particular reason we're keeping track of the coverable lines for each script instead of just keeping track of which scripts have already been compiled?
The purpose of force compiling all the libraries is that it tells the VM which lines are coverable, so it can generate a complete list of all the missed lines (particularly for functions that haven't been called). Each collection that the flutter tester does is in a totally fresh VM, so the VM doesn't have any knowledge about which lines are coverable left over from previous collections. So when we set the |
…age (#136851) 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-lang/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
… 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-lang/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
coverableLineCache
is a map from library URI to the set of all lines that are coverable. If users are doing multiplecollect
calls over the same set of libraries, they should pass an empty map to this param in the first call, and then pass the same map to all subsequent calls.If
coverableLineCache
is provided, we setVmService.getSourceReport
'slibrariesAlreadyCompiled
param to all its keys. This disables forced compilation for each of these libraries. The effect of this is that no misses are returned in the response for these libraries (and coverage collection is faster). To fill in the missing misses, we use the values of thecoverableLineCache
map. Finally, we fill this cache with all the hit and missed lines we've seen for each library.So
coverableLineCache
caches all the lines that have been hit or missed in previouscollect
calls, and uses it to skip recompiling those libraries, and to fill out the misses of subsequent calls.