Although the kernel marks pages (and page tables) as copy on write to make the fork
syscall work efficiently, the creation and tear-down of page tables and related structures is still an expensive task.
Thus I wonder why the linux community has never managed to implement posix_spawn
as a real kernel syscall that just spawns a new process, eliminating the need to call fork
beforehand.
Instead, posix_spawn
is just a poor glibc wrapper around fork
and exec
.
The performance gains would be significantly for workloads that have to spawn thousands of new processes every second. The latency for launching new processes would be improved as well.