GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Implement concurrent execution of individual hooks by chriskuehl · Pull Request #851 · pre-commit/pre-commit Conversation
|
| return 1 | ||
| else: | ||
| # TODO: something smart! | ||
| return multiprocessing.cpu_count() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't really know what to do here. Maybe the number of CPUs is actually a decent heuristic? Or the number minus one? Or divided by two???
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
probably need to do something like this: https://github.com/pytest-dev/pytest-xdist/pull/317/files
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ) | ||
| # TODO: teach partition to intelligently target our desired concurrency | ||
| # while still respecting max_length. | ||
| partitions = partition(cmd, varargs, **kwargs) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think the eventual change to partition would have some relatively simple logic where it tries to fill up sets of N partitions (to take advantage of the N concurrency) while respecting the max_length, rather than trying to minimize the number of partitions like it does now. Probably with some simple logic to avoid silly things like 4 partitions of 1 item each which are probably non-optimal due to per-invocation overhead (we can probably just hard-code something reasonable here?).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| assert ret == 0 | ||
| pids = stdout.splitlines() | ||
| assert len(pids) == 5 | ||
| assert elapsed < 1 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Kind of a silly test, but asserting stuff is running in parallel is hard. idk, what do you think?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return 1 | ||
| else: | ||
| # TODO: something smart! | ||
| return multiprocessing.cpu_count() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
probably need to do something like this: https://github.com/pytest-dev/pytest-xdist/pull/317/files
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| file_args, | ||
| negate=True, | ||
| # TODO: does it actually make sense to parallelize this hook, given | ||
| # it's probably I/O bound? |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
yeah, probably make this always synchronous is fine -- pcre is going away eventually anyway (for pygrep -- though I assume below I'm about to look at pygrep anyway!)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
9bbf046 to
3c2e3f4
Compare
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def _threadpool(size): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@asottile let me know if you have a preference on doing this vs installing a concurrent.futures backport on python2
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
up to you, concurrent.futures is slightly more future-proof if the code is simpler (if it isn't then definitely don't bother)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Heh, on AppVeyor: It's been passing most of the time on AppVeyor, probably flaky :\ Guess I should increase the elapsed duration... or just delete the test. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
🔪 😆 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
hmmm, one other thing I thought about is this is probably going to make the test suite hard to debug with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
deca085 to
a74e0d7
Compare
|
@asottile switched to a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
a74e0d7 to
7200945
Compare
7200945 to
9cd806c
Compare
Spawning processes is apparently really slow on Windows, and the test is occasionally taking slightly more than a second on AppVeyor. I think we can allow up to the full 2.5 seconds without losing the valuable bits of the test.
9cd806c to
9125439
Compare
|
a few little things I want to touch up, then I'll merge. thanks for the implementation on this, this is great. Are there any hooks that we should stick into the serial path? maybe flake8 since it also does multiprocessing? any others? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm excited and terrified for this feature 🎉 pushed my cleanups, will merge after CI finishes |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
nice work!!! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This has been released as part of v1.13.0 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.