Platform Development • Re: The browser hang with 0 CPU load.
Pale Moon forum - Forum index [Unofficial]
April 30, 2026
So we should probably just reserve threads so we aren't deadlocking the kernel. This is likely a subtlety of any threading model because I've seen the same kind of thing with pthreads on Linux.
If I understand correctly how this works, we add 4 to the number of physical (logical?) cores and get the number of threads for variable "threadCount".
CODE:
static size_tThreadCountForCPUCount(size_t cpuCount){ // Create additional threads on top of the number of cores available, to // provide some excess capacity in case threads pause each other. static const uint32_t EXCESS_THREADS = 4; return cpuCount + EXCESS_THREADS;}
This calculation gives a disproportionate increase in threads to the number of cores. On a modern processor with 12 cores, we will get 33% (16 versus 12) more threads than cores, and on a processor with 4 cores, the increase in threads is 100% (8 versus 4). Maybe it’s worth using a different calculation principle, for example, doubling the number of threads per core?
CODE:
static size_tThreadCountForCPUCount(size_t cpuCount){ // Create additional threads on top of the number of cores available, to // provide some excess capacity in case threads pause each other. static const uint32_t EXCESS_THREADS = 2; return cpuCount * EXCESS_THREADS;}
Discussion in the ATmosphere