-
Notifications
You must be signed in to change notification settings - Fork 325
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
Xunit adapter perf issue in VisualStudio and vstest.console runners #485
Comments
We did more profiling on netcore (to see if there are issues that come up after the appdomain issue is fixed). There are two buckets that need more investigation:
|
Updating the current action plan:
Please share feedback on (3) - if you find auto test discovery feature useful. |
re (3) - yep, would love to cancel if it's taking too long. Scenario: I just need to test one test out and fix stuff. Not have to wait etc... |
Status: Fix for SourceInformation issue (a): xunit/xunit#1142 (Review pending) Partial fix for xUnitTestCase to VSTestCase conversion (c): xunit/visualstudio.xunit#104 (Fix merged) |
This is being tracked external to this repo here: |
We recently did test discovery perf analysis of some of the xunit runners. Following are the results for 25k tests discovery on a Win 10 64 bit machine having 8 core 56 GB RAM.
Clearly the VisualStudio commandline and IDE runners are lot slower than xunit.console.
PerfView analysis of VSTest.console and VS.xunit adapter revealed following as the top issues:
Communication across Appdomains. Major contributors are:
⦁ SourceInformation collection - Filename and linenumber for each test
⦁ Xunit to VSTestCase conversion
⦁ Xunit discovered tests transfer
⦁ Test case object serialization\deserialization
JSON over TCP socket communication, which is a known issue
To ascertain that it is indeed the inter appdomain communication which is taking up maximum time, we modified the xunit code temporarily to force it to work in a single appdomain and found that discovery time for VisualStudio.xunit reduced to 44 sec. However due to some technical limitations, the adapter cannot work in a single appdomain.
Why is xunit.console the fastest ?
Xunit.console is faster than VS xunit and VSTest.console xunit because:
1. Socket communication is not required
2. Source information is not collected
3. Xunit to VSTestCase conversion is not required
2 and 3 saves lot of inter appdomain communication cost for xunit.console
In order to find solution to above problems for VS xunit runners, we compared them with MSTest v2 adapter and found that MSTest takes 30.13 sec to discover 25k tests which is although slower than xunit.console but significantly faster that VS xunit runners.
Why is MSTest v2 faster ?
It is faster than VS xunit and VSTest.console xunit because:
a. Instead of source dll appdomain, source information is collected in default appdomain which has MS.VS.TP.ObjectModel loaded (the DIASession class)
b. UnitTestElement is serializable and not MarshalByRef. Hence UnitTestElement to VSTestCase conversion doesn't involve cross appdomain marshalbyref cost
c. Discovered tests get batched and transferred in a single burst across appdomains
Taking inspiration from MSTest V2 adapter design, we found that following changes in xunit adapter can give some perf benefits by reducing the inter appdomain communication cost:
On making temporary code changes for first issue, we observed 25% improvement:
where, CLI: Command line runner, i.e., vstest.console.exe
IDE: IDE runner, i.e., VisualStudio runner
Fix for other issues will likely involve significant code and design changes and will be taken up later.
We will continue working on these identified issues to improve the xunit adapters performance for VS runners.
The text was updated successfully, but these errors were encountered: