mratsim / weave

A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead
Other
532 stars 22 forks source link

setting WEAVE_NUM_THREADS has no effect #125

Closed olliNiinivaara closed 4 years ago

olliNiinivaara commented 4 years ago

No matter what number i give as compile parameter, like -d:WEAVE_NUM_THREADS=100 Weave seems to spawn at most 2 tasks at a time (on 4 core CPU running Linux).

some context: https://github.com/olliNiinivaara/GuildenStern/blob/4b52391f7b7b7eb676db60a11534327ae197566e/src/guildenstern/dispatcher.nim#L15

https://github.com/olliNiinivaara/GuildenStern/blob/4b52391f7b7b7eb676db60a11534327ae197566e/src/guildenstern/dispatcher.nim#L143

https://github.com/olliNiinivaara/GuildenStern/blob/4b52391f7b7b7eb676db60a11534327ae197566e/src/guildenstern/dispatcher.nim#L110

https://github.com/olliNiinivaara/GuildenStern/blob/4b52391f7b7b7eb676db60a11534327ae197566e/src/guildenstern/dispatcher.nim#L179-L180

mratsim commented 4 years ago

Weave will not spawn more threads that your logical processor count to avoid oversubscription. However you should have a message that tells you that the number of threads was truncated:

https://github.com/mratsim/weave/blob/652399ca04d8c0d755b6f4c1b39a84ab4388277a/weave/runtime.nim#L30-L40

olliNiinivaara commented 4 years ago

Ok, WEAVE_NUM_THREADS is really an OS environment parameter, not a Nim parameter that could be set with -d:WEAVE_NUM_THREADS=100. putEnv works. Problem solved.