-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Allow concurrent runs of pants on the same instance of pantsd #11639
Conversation
[ci skip-rust] [ci skip-build-wheels]
…ronment or a new filtered Environment type. [ci skip-build-wheels] [ci skip-rust]
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust]
10fc4e2
to
288263c
Compare
Only the top commit is relevant: the rest is #11641. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Epic!
@@ -94,7 +94,7 @@ function run_pex() { | |||
function run_packages_script() { | |||
( | |||
cd "${ROOT}" | |||
./pants --concurrent run "${ROOT}/build-support/bin/packages.py" -- "$@" | |||
./pants --no-pantsd run "${ROOT}/build-support/bin/packages.py" -- "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that in at least some of these cases the --concurrent
flag was actually meant-as "please disable pantsd
". This one didn't have a comment to explain why it was being used: since this is a bash script, it didn't seem likely that this script was "running under" pants.
This might be related to #11626, but, I ran To reproduce, probably useful to do a slower test (or add |
Mmm, no: this is an oversight: thanks. I had planned to add a test or two before landing this, but I doubt that it would have caught that case. I have a good idea of how to resolve it though (you're right that it relates to the behavior of uncacheable nodes): will do that as another prework PR. |
### Problem In order to allow concurrent runs of Pants in #11639 (part of #7654), all global mutable singletons must be either 1) thread-local, 2) replaced with explicitly passed values. `os.environ` and `sys.argv` are two of the last cases we're concerned with. ### Solution Although we could hypothetically redefine `os.environ` and `os.getenv` as thread-local, they seem to be a better fit to be explicitly passed. So this change: 1. Renames (and moves) `PantsEnvironment` to `CompleteEnvironment` 2. Adds `Environment` and `EnvironmentRequest`, which filter the `CompleteEnvironment` to a smaller subset, and should be used more frequently by `@rules`. 3. Fixes a few cases of implicit `os.environ` usage in the `PythonSetup` subsystem by explicitly selecting interpreter-selection env vars (`HOME`/`PATH`/`PYENV_ROOT`) Finally, we empty the environment for `pantsd` runs to enforce explicit usage of `CompleteEnvironment`/`Environment`. ### Result The last (?) global mutable variable blocking #7654 is removed. [ci skip-build-wheels]
See #7654 (comment) |
Problem
Concurrent execution of multiple runs of
pants
against the same instance ofpantsd
were disabled when forking was remove frompantsd
. But the v2 engine isolates state and avoids global mutable variables such that concurrent runs could be unblocked by fixing the remaining global stateful cases:Subsystem
s (Deprecate Subsystems as global singletons #11388, Remove deprecated v1 Subsystem facilities #11424)Solution
Now that all global stateful cases are removed, we can remove the lock that prevents concurrent runs in
pantsd
, and deprecate the--concurrent
flag.Result
Multiple runs of
pants
can proceed concurrently with the same instance ofpantsd
in a single workspace. See https://asciinema.org/a/397032 for an example.Fixes #7654.