Which factors determine the appropriate value for settingsFork in a Warp application?

59 Views Asked by At

In Warp applications, the settingsFork option is available on the Settings data type. This allows one to choose a different fork model. When should this be set to something other than the default (void . forkIOWithUnmask)? Which factors should be taken into account when making this decision? (IO vs CPU bound/use of FFI, for example).

1

There are 1 best solutions below

0
On BEST ANSWER

You may want to use forkOS to create a bound thread if you're going to be manipulating thread-local state (as unbound Haskell "threads" might run on different OS threads, and therefore ruin the whole idea of using thread-local storage in the first place). The documentation mentions OpenGL as a possible example. Overall though, I find it difficult to come up with a situation where you wouldn't want the default implementation, which takes advantage of the builtin green-thread system. It's received wisdom that GHC's scheduler is hard to beat.