Skip to content

25x nonparallelized speedup by avoiding MSBuildWorkspace in example tester #1338

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

Open
wants to merge 4 commits into
base: draft-v8
Choose a base branch
from

Conversation

jnm2
Copy link
Contributor

@jnm2 jnm2 commented Jun 1, 2025

Running ExampleTester on my machine takes 8 minutes. With the changes in this PR, it takes 19 seconds. That's a 25x speedup!
That's not even parallelizing- parallelized together with #1337, the entire suite of example tests runs in 8 seconds.

The goal is twofold:

  • to not have to wait ~9 minutes for the GitHub actions to finish when an update is pushed to a PR
  • to be able to run the full test suite in seconds locally while editing examples, without fiddling with filtering the tester to a given single example.

This PR speeds up all tests except the six or so multi-csproj examples which include project references. The way it speeds up the tests is by reading and interpreting the csproj XML directly. Hopefully, the new code is straightforward enough to extend as needed.

It's important to preserve the fidelity of the testing. Because of this, the fast path will bail if it sees any csproj element that it does not fully understand, falling back to the existing MSBuildWorkspace code which invokes full MSBuild out-of-process. When an example starts using an unrecognized csproj property or item, the tester will quietly fall back to the slow path without logging any notices about this. If you're running the tester with a debugger attached which has opted in to stopping on handled exceptions, you'll hit a handled NotImplementedException that will be the only clue that you're falling back to the slow path.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 1, 2025

I'd like to add the ExampleTester and ExampleExtractor projects to the filter for the GitHub Actions .yaml that runs ExampleExtractor and ExampleTester, so that we can see how the run is affected by code changes and not just by changes under the standard folder.

(Update: this is handled in #1336)

@jnm2 jnm2 marked this pull request as draft June 1, 2025 19:31
@jnm2
Copy link
Contributor Author

jnm2 commented Jun 1, 2025

Also, I need to investigate a failing example. The reason I didn't investigate this example before pushing is that this example also fails for me on my local machine with the latest commit on draft-v8, but had not been failing in GitHub actions on the same commit. I had put this down to the version of MSBuild being located, but it's clearly coming up again now, so it's time to investigate.

❌Example tester-ExampleTester::file=tools/conversions.md:771-809,line=771:: Mismatched errors: Expected CS1593, CS1661, CS1678, CS8030, CS1688, CS1661, CS1676, CS1643, CS0126, CS0029, CS1662, CS1670, CS0029, CS1662; Was CS1593, CS1661, CS1678, CS8030, CS1688, CS1676, CS1643, CS0126, CS0029, CS1662, CS1670, CS0029, CS1662

(Update: this is handled in #1336)

@Nigel-Ecma
Copy link
Contributor

Also, I need to investigate a failing example. The reason I didn't investigate this example before pushing is that this example also fails for me on my local machine with the latest commit on draft-v8, but had not been failing in GitHub actions on the same commit. I had put this down to the version of MSBuild being located, but it's clearly coming up again now, so it's time to investigate.

❌Example tester-ExampleTester::file=tools/conversions.md:771-809,line=771:: Mismatched errors: Expected CS1593, CS1661, CS1678, CS8030, CS1688, CS1661, CS1676, CS1643, CS0126, CS0029, CS1662, CS1670, CS0029, CS1662; Was CS1593, CS1661, CS1678, CS8030, CS1688, CS1676, CS1643, CS0126, CS0029, CS1662, CS1670, CS0029, CS1662

CS1661 is listed twice in the Expected list, otherwise the lists are the same – cause of problem?

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 2, 2025

@Nigel-Ecma Interesting, thank you. Sounds likely to be a change in compiler behavior. Investigating at #1336 (comment), since I realized that is the PR that will first bring on the change.

(Update: this is handled in #1336)

@jnm2 jnm2 marked this pull request as ready for review June 2, 2025 01:52
@jskeet
Copy link
Contributor

jskeet commented Jun 4, 2025

Can I check, is the intention that this replaces #1337? I'd personally rather avoid parallelization unless we actually need it.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 4, 2025

I would want to keep #1337 since it allows working with each example as a unit test in addition to running via the CLI. Then, parallelization across the unit tests could be disabled if we didn't want it to be possible. What's the nature of your concern about parallelizing?

@jskeet
Copy link
Contributor

jskeet commented Jun 4, 2025

What's the nature of your concern about parallelizing?

Only that my experience is it can make life more complicated (and harder to diagnose) for very little benefit.

I'll try to review both PRs in the next couple of days.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 4, 2025

I'm happy to make life easier by removing anything worrisome. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy