-
Notifications
You must be signed in to change notification settings - Fork 389
Huge performance drop when using --collect:"XPlat Code Coverage"
in dotnet test
(.NET 6)
#1192
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
Comments
I didn't investigate yet but sometimes is "rare but expected", if your tests/code has got a lot of loop can happen. We're injecting some code for every sequence point and this can affect jitter optimization(inlining etc...). And we have some possible solution but the change is unfortunately huge at the moment: The main issue is that current strategy of coverlet instrumentation is based on sequence point and not on code block so we're sometimes "instrumenting too much". That said we should take a dump and check if it's related to that or injecting code lead to some latent bug somewhere(infinite loop for some wrong synchronization). |
@eduherminio have you tried with different runtime version is it the same with 5.0? |
I just did with an older version of the codebase using:
Similar results for the tests mentioned in the description: And yes. this project heavily relies on loops @MarcoRossignoli 😄 I'll monitor those issues as well, hopefully you can find a solution soon 💪🏼💪🏼 |
Are you testing in debug or release? |
Originally Release, but I see similar results in Debug: |
We are seeing this too on .NET 5. Drop in performance from 30 seconds to over 5 minutes in our case. |
To be sure that issue is what I expect someone should take a dump of process and check if threads are for most of the time inside In that case for now we don't have a solution 😞 Coverlet instrumentation relies heavily on sequence points and not "blocks" so for every sequence point it emits a "hit records" that despite inlined(is a update indexed array location with +1) can lead to perf issue or maybe to some missing optimization due to "more code to run". |
(edit) I withdraw my original comment. I had a misconfiguration which meant the Migrations were being included in the coverage. Once the appropriate exclude filters were actually applying then run time has dropped to normal levels. (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md) |
Hi @MarcoRossignoli , thanks for your job.
|
@eduherminio I was able to get code coverage using Microsoft.CodeCoverage package:
I've upgraded Microsoft.CodeCoverage to latest Preview version. Still huge perf drop is there but at least tests are finishing.
You can also use |
That's definitely a step forward, thanks @jakubch1! |
At the moment we have not plan to change the engine of coverlet. The main issue I suppose is the fact that coverlet is based on sequence points(so we're inserting more probes than needed for coverage analysis) and we're inserting "hit calls method" in the code(doesn't inline well, for instance in debug). The update needed to change the two points above is not trivial.
Yep coverlet is sharing the same engine for all drivers(.NET tool, msbuild, vstest collector). |
Is there any work around for this? |
As said in the message above at the moment we don't have "workaround". We don't plan at the moment to change how the engine is working, is someone of you want to try something feel free to open a PR I'll be happy to review/help/suggest. |
Hit the same issue here with at test taking a very very long time to run with |
Please use latest coverage.collector V6.0.2 package and check whether the performance improved. |
There have been clear improvements vs when I opened this issue. See
I just realized that the results Jakub reported in February last year were not against the commit id I posted in the description, and therefore can't be compared with the repro because of test categories changes. |
@eduherminio you could try |
Thanks I just tried that and it cut the time to ~30min! |
To be clear, on my end the performance hit is no longer a blocker, so this issue can be closed unless you choose to use it to track further improvements. Quick summary with some rough numbers:
|
Yeah I was just trying to setup coverlet in a xunit project and also ran into coverage taking a long time to generate (I didn't wait for it to finish, but without it the tests run in seconds). |
Please use coverage.collector V6.0.3-preview.10.g7c8c6fae27 package from nightly build and send your feedback. Thanks. |
For our case this nightly build has improved a lot Thanks! NB: Is it possible to know when this version will be ready for production? Edit: Same improvement also can be seen with |
Coverlet V6.0.3 is published on nuget.org. |
I have an NUnit test project with a dependency on
coverlet.collector v3.0.3
which becomes unusable whendotnet test
is invoked with--collect:"XPlat Code Coverage"
.Repro steps:
See also some GH Actions runs (see long-running tests ->
Run long-running tests
):coverlet.collector
and with--collect:"XPlat Code Coverage"
- Manually cancelled after 45 min 🔴coverlet.collector
and without--collect:"XPlat Code Coverage"
- ~2.5 min ✔️coverlet.collector
and without--collect:"XPlat Code Coverage"
- ~2.5 min ✔️(the failure in the next step of the job is unrelated)Versions;
The text was updated successfully, but these errors were encountered: