Skip to content
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

SubmoduleStatusProviderTests extremely slow #8279

Closed
RussKie opened this issue Jun 28, 2020 · 18 comments · Fixed by #8334
Closed

SubmoduleStatusProviderTests extremely slow #8279

RussKie opened this issue Jun 28, 2020 · 18 comments · Fixed by #8334

Comments

@RussKie
Copy link
Member

RussKie commented Jun 28, 2020

Current behaviour

Running tests under VS I've observed SubmoduleStatusProviderTests tests to take in excess of 7 minutes to complete.
image

Expected behaviour

Tests must complete faster.

@gerhardol
Copy link
Member

1,6 minutes for me. Six times execution time, virus that slows Git down?
Every test takes 4-5s, also the simple setup tests so most of the test time is likely to create repos etc.
The tests could be changed to execute in one testcase.

Not fast, but it actually test something.

image

@mstv
Copy link
Member

mstv commented Jun 29, 2020

Run all tests does not work anymore. It builds everything and does not run any test.

The SubmoduleStatusProviderTests took 6.6 minutes, too, with high CPU load by the anti-virus virus. I cannot turn it off on this machine.

@RussKie
Copy link
Member Author

RussKie commented Jun 30, 2020 via email

@sharwell
Copy link
Member

I can do a profiling pass to see what's taking time here.

@sharwell
Copy link
Member

So the general approach to use here leverages two things:

  1. Use LibGit2Sharp for repository initialization, because it's faster than the Git executable. This is not currently possible for this test because there is no API to add a submodule (SubmoduleCollection.Add() using clone libgit2/libgit2sharp#1232, Add SubmoduleCollection.Add libgit2/libgit2sharp#1501).
  2. Avoid deleting and recreating the entire repository between each test. Instead, reset the repository to its initial state. You're basically looking for something like ReferenceRepository.Reset(), except specific to the types of changes made to a repository by this test class.

Realistically you should be able to shave about 70% off the test time by avoiding some calls to git for all tests except the first.

@vbjay
Copy link
Contributor

vbjay commented Jun 30, 2020 via email

@sharwell
Copy link
Member

sharwell commented Jun 30, 2020

I'm opposed to extracting a zipped repo if it can be avoided any other way. Such a repository would not be reviewable if we need to make any changes to its form. The ReferenceRepository approach is essentially the same result, except its much smaller and the generated repository state can be determined by reviewing the code. It's similar to the difference between storing a raw SQL database and storing a SQL script that would create the database.

@vbjay
Copy link
Contributor

vbjay commented Jun 30, 2020 via email

@sharwell
Copy link
Member

sharwell commented Jun 30, 2020

😕 I don't understand how a bundle improves the ability to review changes. Isn't it still a binary file?

@vbjay
Copy link
Contributor

vbjay commented Jun 30, 2020 via email

@vbjay
Copy link
Contributor

vbjay commented Jun 30, 2020 via email

@RussKie
Copy link
Member Author

RussKie commented Jul 1, 2020

Whatever process we chose it has to be immune to concurrent access and race conditions as tests often run in parallel.

@sharwell
Copy link
Member

sharwell commented Jul 1, 2020

tests often run in parallel

xunit doesn't run tests in the same class in parallel. Does nunit?

@RussKie
Copy link
Member Author

RussKie commented Jul 1, 2020

I don't think so.

@ghost ghost added the 🚧 status: in progress Issues which have associated PRs label Jul 17, 2020
@gerhardol
Copy link
Member

The solution to improve the tests I can see is a hack to check that [SetUp] only executes once for a fixture.

GE uses BeforeTest to setup the thread handling etc, but OneTimeSetup runs before that.
https://medium.com/a-layman/test-with-nunit-create-a-test-project-and-realize-the-execution-order-18c11b636b0c

xunit doesn't run tests in the same class in parallel. Does nunit?

Seem to be possible, even if we have not set that up.
NUnit tests can be run in parallel, so changing the resource usage will require use of attributes
https://docs.nunit.org/articles/nunit/technical-notes/usage/Framework-Parallel-Test-Execution.html

For #8334 trying to improve the tests, I tried to setup according to Parallel class with non-parallel methods in NUnit documentation

@mstv
Copy link
Member

mstv commented Jul 17, 2020

Parallel test execution is no option ATM. There are too many singletons, e.g. AppSettings.

@RussKie
Copy link
Member Author

RussKie commented Jul 18, 2020 via email

@gerhardol
Copy link
Member

@RussKie see the PR for a solution

For parallel: I just tried to setup the attributes correctly if parallel is enabled

@ghost ghost removed the 🚧 status: in progress Issues which have associated PRs label Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants