Skip to content
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

Parallelism! #19

Open
byorgey opened this issue Sep 2, 2013 · 3 comments
Open

Parallelism! #19

byorgey opened this issue Sep 2, 2013 · 3 comments

Comments

@byorgey
Copy link
Member

byorgey commented Sep 2, 2013

diagrams-haddock has some embarrassing parallelism going on. We should add a -j flag that turns on multithreading.

@byorgey
Copy link
Member Author

byorgey commented Sep 3, 2013

Some notes:

  • spawn (http://hackage.haskell.org/package/spawn-0.3) has an abstraction for running things in a pool but it uses a deprecated API.
  • Can instead just use a QSem, something like newQSem n >>= \qs -> async (map (bracket (waitQSem qs) (signalQSem qs)) actions) (from @luite)
  • Or use a queue of tasks and fork off n workers with async. Can't use Chan since there's no way to check if it's empty. Instead use Control.Concurrent.STM.TChan.
  • From @fryguybob: worker c = join $ atomically (readTChan c >>= return . (>> worker c) <|> return ())

@fryguybob
Copy link
Member

I implemented something on the parallel branch 1d5bc08 but when I run I get the disappointing message:

This version of GHC is not thread-safe,can't safely run two instances of the interpreter simultaneously

How sad!

@byorgey
Copy link
Member Author

byorgey commented Sep 3, 2013

Bummer! See http://ghc.haskell.org/trac/ghc/ticket/3373 . I suppose one workaround would be to actually fire up N copies of the RTS in different OS processes? But that would probably have a lot of overhead, and I don't know if it would be worth the trouble.

byorgey pushed a commit that referenced this issue Sep 11, 2013
Revert "add -j flag (currently does nothing)"

This reverts commit bfc9505.

Parallel builds don't seem to be working out (see #19) so revert for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants