bfgminer icon indicating copy to clipboard operation
bfgminer copied to clipboard

Increase per thread stack size

Open TheBiggerGuy opened this issue 8 years ago • 3 comments
trafficstars

When using musl libc the default statck size is too small for the scrypt code that uses alloca.

see: https://github.com/luke-jr/bfgminer/issues/723

TheBiggerGuy avatar Oct 20 '17 22:10 TheBiggerGuy

Hmm, IIRC there is already stacksize stuff in BFGMiner. Do we want all these threads to have that stack size? Might it be a reduction in normal use cases, breaking other drivers?

luke-jr avatar Oct 21 '17 01:10 luke-jr

So first I should of made it clear with is a Work In Progress and should not be committed yet. The known issues with it are to do with page size alignment that I am still looking into.

To you questions:

  • "already stacksize stuff in BFGMiner": Didn't see any/can't find any, do you know where it is?
  • "Do we want all these threads to have that stack size": This is only applied to the driver threads that do the scrypt hash and actually sets it to the GLibc default so is not worse than when not using musl libc.
  • "Might it be a reduction in normal use cases, breaking other drivers": The 2 << 20 number is the GLibc default so I used that. To my page size alignment reference above the libav bug is better coded to read the current size and only bump it if required. I'm looking into that as a better patch.

For context I found this issues when moving to Alpine Linux to minimise a Docker container. This config is only compiled with scrypt, a single gridseed driver and on ARM.

TheBiggerGuy avatar Oct 21 '17 03:10 TheBiggerGuy

Looks like in the past we've just avoided using stack space too much.

Some #define magic may be needed for Windows: https://github.com/GerHobbelt/pthread-win32/blob/master/pthread_attr_setstacksize.c

luke-jr avatar Oct 21 '17 03:10 luke-jr