Default options for -threaded

Ben Gamari ben at well-typed.com
Mon Oct 10 13:33:43 UTC 2016


Phyx <lonetiger at gmail.com> writes:

> Oops, sorry, only just now seen this. It seems my overly aggressive filters
> couldn't decide where to put the email :)
>
> I do agree to some extend with this. I'd prefer if I made a mistake for my
> system not to hang. The one downside to this default though is that you
> can't just hand a program over to user and have it run at full capabilities.
>
> If it possible to set this from inside a program? My guess is no, since by
> the time you get to main the rts is already initialized?
>
> Would a useful alternative be to provide a compile flag that would change
> the default? e.g. opt-in? Since now there is a small burden on the end user.
>
There exist two pretty good tools for accomplishing what you want,

 1. Call Control.Concurrent.setNumCapabilities [1] from within your
    application.
 
 2. Use GHC's -with-rtsopts flag [2] to set the default RTS arguments
    during compilation of your application.

Cheers,

- Ben


[1] http://localhost:7000/file/opt/exp/ghc/roots/8.0.1/share/doc/ghc-8.0.1/html/libraries/base-4.9.0.0/Control-Concurrent.html#v:setNumCapabilities
[2] http://downloads.haskell.org/~ghc/master/users-guide//phases.html?highlight=#ghc-flag--with-rtsopts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 454 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20161010/49410c1e/attachment.sig>


More information about the ghc-devs mailing list