RC RANDOM CHAOS

Linux kernel eyes a native posix_spawn() to retire fork()+exec()

· via Hacker News

Original source

Moving beyond fork() + exec()

Hacker News →

Li Chen proposed a “spawn templates” mechanism for the Linux kernel to speed up workloads that repeatedly launch the same executable, such as tools that invoke Git in a loop. The patch set adds a spawn_template_create() syscall that opens an executable once and caches setup work, plus a spawn_template_spawn() call that supplies per-invocation argv, envp, and file-descriptor or signal actions. Benchmarks showed only about a 2% speedup, and reviewers pushed back on the design.

Mateusz Guzik argued the proposal misses the point: most of the cost lives in fork()‘s process copy, so the right move is to build a pristine process from scratch rather than clone and discard. Christian Brauner suggested layering a builder-style API on top of pidfd: a pidfd_open() variant would create an empty process, and successive pidfd_config() calls would assemble its image, environment, and descriptors, mirroring how fsconfig() works for mounts.

The shared goal is enabling a real in-kernel posix_spawn() rather than the current userspace implementation that still relies on fork()+exec() underneath. Chen accepted Brauner’s direction, so spawn templates won’t land, but the work signals that Linux is finally moving toward a dedicated process-creation primitive after decades of patching around fork()‘s cost.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.