Araq / malebolgia

Malebolgia creates new spawns. Structured concurrency. Thread pools and related APIs.
MIT License
104 stars 10 forks source link

Added option to set global thread number during runtime #33

Closed tsoj closed 4 months ago

tsoj commented 4 months ago

This is roughly my suggestion. Use case is that to run a program on different systems where I am each allowed to use half of all CPU threads.

Araq commented 4 months ago

But a thread is not tied to a CPU so how is this even enforced.

tsoj commented 4 months ago

Could be that I'm missing something obvious, but I thought that limiting the number of workers provides an upper bound how many threads can run at the same time, and thus how much a CPU gets utilized.

Also, it seems likely to me, that if N workers exist, that the OS tries to run these on as many (up to N) Cores/Hyperthreads as possible.

EDIT: or if you're referring to the systems where I am allowed to use "half of a CPU": This is not a hard limit but just a rough rule to follow. The reference would be something like htop (or taskmanager).

Araq commented 4 months ago

EDIT: or if you're referring to the systems where I am allowed to use "half of a CPU": This is not a hard limit but just a rough rule to follow. The reference would be something like htop (or taskmanager).

That is what I meant. Well, I don't really like the idea -- you already need to use -d:maleSkipSetup so why not just use -d:ThreadPoolSize=8. Sure, you need to recompile for every machine but it's seems to be such a niche use case.

tsoj commented 4 months ago

Fair enough. I'll keep the issue https://github.com/Araq/malebolgia/issues/27 open though, maybe there'll be more people who want something like this.