Remove extra work when computing code coverage #1066
Comments
Summary: When jar_spool_mode is direct_to_jar, we don't generate a directory of class files. But the code coverage reporting step needs such a directory to figure out what classes are being tested. In this diff, I just extract the jar file to that directory just before calling the reporting step. Test Plan: I ran the `buck test --code-coverage` in an external repo which had the issue and looked at the generated report and it looked fine. In the buck repo, added a happy path test to cover the code extraction paths. Reviewed By: jkeljo fbshipit-source-id: 7c7c85e
@kageiit This should be easy to do, but how much of a regression are we talking about? The code coverage logic has broken a few times in the past, so having fewer variations on the code path would prevent this from breaking again. If the regression is really significant, then I can put in a few if-elses |
This is about covering all the cases consumers can write to disk for jar'ing. We should ideally avoid work unless its needed. Unzipping every single classes jar to obtain code coverage is a significant performance regression especially if the classes directory is already available. Consumers cannot spool to jar if postprocess_classes_commands are active as well, so this sort of change will break build time slas for them |
To be clear, it shouldn't be every single jar file, it should only be the ones that have the given test in their |
I dont understand what you are saying. The classes directory of a rule was replaced with |
we have several thousand rules that have associated tests with them. We should not be required to unzip the jars for computing code coverage when the unzipped classes directory is already available. We also dont spool directly to jar |
@kageiit I see, so your concern is with CI runs where you run all the tests, correct? Local runs probably don't get affected as much because people probably run a few targets at a time. Just understanding the situation right now. |
Yes. That is correct |
@tdrhq any updates on this? |
will be doing this soon, I would still love some kind of number to get a sense of what percentage increase we're talking about, an approximation would do |
Approximately 15 ~ 30 seconds more when running coverage on several thousands of test rules. Overall test run times are around 8 ~ 10 min. This is because code coverage is purely single threaded and happens at the very end after all test rules are run. The unzip has to happen for every build target that underwent tests. The number of test rules are only increasing and would be great to avoid this extra unzip time since the classes are already available |
@tdrhq any updates? |
woops sorry, I'll work on this today |
Fixed in a4cd1b0 Let me know if it works |
Going to pull this in by tomorrow. Will report back |
@tdrhq We are seeing an exception with the latest buck version
|
We're seeing the exception above too. Are there any workarounds for it? |
This seems to be fixed with |
0cc8d5d introduced a performance degradation for projects that do not use the
direct_to_jar
spool mode when computing code coverageIdeally, the classes dir can be used if it already exists to prevent unzipping for projects that output classes to the filesystem already.
The text was updated successfully, but these errors were encountered: