Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exec without replacing current process, posix_spawn kernel implementation

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.

like image 227
Mike76 Avatar asked Aug 24 '26 04:08

Mike76


1 Answers

That's basically what posix_spawn is for. It is also a more flexible API. The real bug is that the Linux exec man page still doesn't include a cross-reference for it.

like image 199
dgatwood Avatar answered Aug 26 '26 19:08

dgatwood