Don't parallelize scanning for small codebases#207
Merged
Conversation
This significantly speeds up the test suite, which had slowed down when we added scanning parallelization.
CodSpeed Instrumentation Performance ReportMerging #207 will degrade performances by 54.35%Comparing Summary
Benchmarks breakdown
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The recently-introduced multiprocessing work had slowed down the test suite, because we were spawning multiple processes for each functional test that scanned relatively small packages.
This introduces a constant defining the minimum number of modules before using multiprocessing, returning the test suite to its previous speed.
pytest --benchmark-skipBefore: 13.85s.
After: 4.91s
We can see there's a regression here for scanning Django with 15 cache misses: as it happens, the same size as the
testpackagethat is sped up. I think the reason for that is that the test package has very little AST parsing to do as the Python modules are almost empty, whereas the Django benchmark includes 15 quite complex modules. We could adjust this a bit (or even run it at a higher threshold when running tests), but given that scanning 50 modules in a single process is still quite fast, I doubt it will impact users in practice. We can easily revisit this later if need be.