Description
When a program starts, we spawn a bunch of extra threads before running the main thread in Scheduler::run: one process monitor thread, an epoch thread, N process threads and N * 4 backup threads. The time it takes to spawn these threads varies, but based on some measuring it can take around 500 microseconds per thread on average. That's quite high compared to the minimum of 20 microseconds I have measured in the past, but there's not much we can do about that.
A simple way to work around this is to spawn one "spawner" thread which then takes care of spawning all the above threads. This way the main thread can start running (without waiting for the spawner thread to finish) while the background threads are set up. Most notably this means the startup time remains largely constant as the number of threads increases, instead of the startup time also increasing.
Related work
No response
Description
When a program starts, we spawn a bunch of extra threads before running the main thread in
Scheduler::run: one process monitor thread, an epoch thread, N process threads andN * 4backup threads. The time it takes to spawn these threads varies, but based on some measuring it can take around 500 microseconds per thread on average. That's quite high compared to the minimum of 20 microseconds I have measured in the past, but there's not much we can do about that.A simple way to work around this is to spawn one "spawner" thread which then takes care of spawning all the above threads. This way the main thread can start running (without waiting for the spawner thread to finish) while the background threads are set up. Most notably this means the startup time remains largely constant as the number of threads increases, instead of the startup time also increasing.
Related work
No response