-
Notifications
You must be signed in to change notification settings - Fork 710
Add --semaphore
flag to enable interaction with GHC Job Server…
#8557
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
Conversation
3a6312e
to
5563a57
Compare
res <- try job `finally` releaseSemaphore sem 1 | ||
atomically $ writeTChan outqVar res | ||
-- Wait for spawned process to take some capabilities if it wants some | ||
threadDelay 1_000_000 |
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.
Is there any sense in making this configurable? Have you experimented with different values?
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.
I don't think so.. I didn't try any different values. I think just something non-zero is good and not so small to prevent thrashing.
Updated based on @sheaf s comments now
|
Testing this feature will have to wait because there isn't a released compiler yet which supports |
--semaphore
flag to enable interaction with GHC Job Server…--semaphore
flag to enable interaction with GHC Job Server…
95c8d6a
to
660d45c
Compare
5c4fd97
to
1d74397
Compare
This will close #976, right? |
, option [] ["semaphore"] | ||
"Use a semaphore so GHC can compile components in parallel" | ||
installUseSemaphore (\v flags -> flags { installUseSemaphore = v }) | ||
trueArg |
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.
maybe this should be a boolOpt
, so it can be enabled or disabled in the global or project config (I assume we'll enable this by default after the next release if not in this pr)
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.
I changed this to boolOpt
.
I am not sure how to go about enabling it by default because you would also need a very new version of GHC, at the moment if it's enabled and you use an older version of GHC then you get an error (rather than falling back to old behaviour).
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.
I implemented it now so that if you use an older compiler and pass --sempahore
then you get a warning about falling back to old behaviour but things still work. That way it can be enabled globally without too much hassle.
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.
I actually changed the option to a yesNoOpt
which seemed to fit in better.. and also hopefully fixes some failing roundtrip tests I couldn't work out how to fix.
8cb82fb
to
3303449
Compare
As a data point, using this feature to compile |
a7331a8
to
5c6c4ce
Compare
CI is passing now :) |
959c4a2
to
d63ae09
Compare
* The top-level user interface to enable the use of the semaphore is the `--semaphore` flag. If you pass `-j4 --semaphore` then cabal will create a semaphore with 4 slots which is passed to ghc using the `-jsem` option so that all GHC processes coordinate to use 4 capabilities. - The semaphore logic is provided by a new package `semaphore-compat` which provides a cross-platform abstraction for semaphores. * The low level `./Setup.hs build` interface accepts the `--semaphore <SEMAPHORE>` option, which can be used to directly pass the semaphore you require to the Setup script.
7fbfb0f
to
25e00c3
Compare
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.
Good as far as I can see!
@Mergifyio backport 3.10 |
🟠 Waiting for conditions to match
|
GitHub needed a rebase and I pushed the button. Results are not hopeful:
|
I have rebased this and opened #9139 proposing merge. |
I understand this was subsumed by #9139 which is now merged. Please reopen if I am mistaken. |
… (-jsem)
This is a WIP patch which allows testing GHC jobserver (-jsem) using cabal. When
--semaphore
is passed tocabal-install
then cabal will create a semaphore with the number of capabilities suggested by-j
and then use this semaphore to mediate parallelism between GHC processes.