哪些因素决定了 Warp 应用程序中 settingsFork 的适当值?
Which factors determine the appropriate value for settingsFork in a Warp application?
在Warp applications, the settingsFork
option is available on the Settings数据类型中。这允许人们选择不同的货叉模型。什么时候应该将其设置为默认值 (void . forkIOWithUnmask
) 以外的值?做出此决定时应考虑哪些因素? (例如,IO 与 FFI 的 CPU bound/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。
在Warp applications, the settingsFork
option is available on the Settings数据类型中。这允许人们选择不同的货叉模型。什么时候应该将其设置为默认值 (void . forkIOWithUnmask
) 以外的值?做出此决定时应考虑哪些因素? (例如,IO 与 FFI 的 CPU bound/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。