scrive / pool

A high-performance striped resource pooling implementation for Haskell
Other
18 stars 11 forks source link

`defaultPoolConfig`'s use of capability count trips up max resources check #31

Open dten opened 1 year ago

dten commented 1 year ago

Max resources must be specified when calling defaultPoolConfig but by default the stripe count is set to capability count. If someone sets max resources to for example 10, then this runs fine on a machine with 8 cores but fails with poolMaxResources must not be smaller than numStripes on a machine with 16 cores. This seems like quite an easy thing to trip over for the defaults.

arybczak commented 1 year ago

Do you have any proposition for a solution?

dten commented 1 year ago

Perhaps if the stripe count is Nothing it becomes the minimum of the number of capabilities and the max resources. Edit: I initially wrote maximum but that's wrong lol

fumieval commented 1 year ago

I think https://github.com/scrive/pool/pull/16 is a promising countermeasure

thomasjm commented 1 year ago

+1, this issue makes the library much more hazardous to use. Would love to see something like #16 merged.

chreekat commented 3 months ago

I just got an unexpected runtime error trying to upgrade because of the related change in behavior.

I honestly have no idea what values I should be supplying now. Am I supposed to know in advance how many cores my app will be run with? Or should I artificially restrict the number of stripes...?

Ah, I see in #33 that I guess I should be using GHC.Conc.numCapabilities. Ok.

Note that #33 was incomplete. There's still a second paragraph that is in error.