Limit threads#127
Conversation
|
|
||
| limitThreads = Opts.option Opts.auto $ | ||
| Opts.long "threads" | ||
| <> Opts.help "Limit the number of threads" |
There was a problem hiding this comment.
Needs better explanation
There was a problem hiding this comment.
How about renaming it to jobs and the text to Limit the number of jobs that can run concurrently?
| import System.Environment (getArgs) | ||
| import qualified System.IO as IO | ||
| import qualified System.Process as Process | ||
| import Data.Either.Combinators (rightToMaybe) |
There was a problem hiding this comment.
I really would rather not have all of these diff changes because it makes maintenance harder
|
This sounds fine overall? Just I guess we should do a pre-release in any case if we merge this to see if anyone has problems with this. |
|
No rush for me, we've included the binary from this branch in our repo until it's up on |
| errors -any, | ||
| turtle <1.6 | ||
| turtle <1.6, | ||
| SafeSemaphore -any |
There was a problem hiding this comment.
No need to depend on this package, the bugs in base's semaphore have been fixed.
|
Thanks for the reviews, I think I addressed the issues. Let me know if the current message is okay @justinwoo I haven't tested it yet, will do that tomorrow at work on our codebase and will update then. |
|
Alright, after a bit of confusion I think everything is working correctly. Tested it on appveyor and it works just fine with up to 6 jobs. Didn't encounter any issues with this version. |
| Nothing -> mapConcurrently dirFor dependencies | ||
| Just max' -> do | ||
| sem <- newQSem max' | ||
| mapConcurrently (\x -> waitQSem sem *> dirFor x <* signalQSem sem) dependencies |
There was a problem hiding this comment.
You'll want to use bracket_ (waitQSem sem) (signalQSem sem) (dirFor x) to make sure you don't lose a capacity on exception in dirFor.
EDIT:
I got that one from http://hackage.haskell.org/package/base-4.11.1.0/docs/Control-Concurrent-QSem.html#t:QSem
|
Added If you mind the Makefile I could remove that too. |
|
Thanks! I made a pre-release here: https://github.com/purescript/psc-package/releases/tag/v0.4.1-pre |
Updates that remove features and improve user experience. Adds warnings for trying to install packages without (purescript/psc-package#126 by @Dretch) Filters "installing" messages for build (purescript/psc-package#130 by @Dretch) Adds options for limiting jobs for install (purescript/psc-package#127 by @Vladciobanu) Per purescript/psc-package#121, removes the confusing misfeature "add-from-bower", which led to many users thinking this command was for adding "extra-deps" like Stack. See the thread for details on how you could readily replace this command if you used it before.
Updates that remove features and improve user experience. Adds warnings for trying to install packages without (purescript/psc-package#126 by @Dretch) Filters "installing" messages for build (purescript/psc-package#130 by @Dretch) Adds options for limiting jobs for install (purescript/psc-package#127 by @Vladciobanu) Per purescript/psc-package#121, removes the confusing misfeature "add-from-bower", which led to many users thinking this command was for adding "extra-deps" like Stack. See the thread for details on how you could readily replace this command if you used it before.
This is more of a "is this what you had in mind", I'm totally open to feedback.
I added a
--threads Noption for all commands that (eventually) hit amapConcurrentlyor aforConcurrently_. I did it by adding aMaybe Intparameter down the call stack (not sure if it's worth it refactoring all of the functions to someReaderT env IO; probably not with this PR but I could take that on if it would get accepted).A value of
Nothingmeans use old behaviour, otherwise use the method suggested by @kritzcreek's link in #126.I would also like to keep the changes to the import because I like them arranged nicely, but I'm totally fine reverting that chunk if you want me to.
This has been tested on Appveyor on our project and fixed our issues. We have only tested with
--threads 1so far and that works (but is obviously a bit slow).