Linux kernel rejects spawn template proposal in favour of posix_spawn
Chen’s patch set for repeated executables offered only a 2% gain; community pivots to pidfd-based empty process creation.
The Linux kernel community has concluded its review of a patch set proposed by developer Chen, which sought to optimise the traditional fork() and exec() system call pattern. The proposal introduced a 'spawn template' mechanism designed to improve performance for applications that repeatedly launch identical executables. Although the patch offered a modest 2% performance gain, it was not merged. Reviewers, including Mateusz Guzik and Christian Brauner, identified the fork() operation itself as the primary bottleneck, arguing that creating a "pristine" or empty process is more efficient than optimising copy-on-write mechanisms. The community agreed that a native posix_spawn implementation, potentially leveraging the pidfd abstraction to create and configure empty processes, represents a superior architectural direction.
Chen’s patch set introduced specific system calls: spawn_template_create() to generate a cached template for an executable, and spawn_template_spawn_args() to execute a process using that template. The template mechanism allowed for pre-caching executable information and passing arguments, environment variables, and file descriptor actions via a structured API. Benchmark results cited in the cover letter indicated a performance improvement of approximately 2% for the targeted use case.
Mateusz Guzik argued that the fork() operation itself is the primary cost, suggesting that creating a "pristine" or empty process is a better approach than optimising the copy-on-write mechanism. He noted that the focus of the patch set was strange in that it left the fork() part of the problem untouched, where most of the cost lies. Guzik stated that optimization efforts should seek to remove fork() from the picture entirely.
Christian Brauner proposed an alternative API built on pidfd, involving a pidfd_open() option to create an empty process and a pidfd_config() system call to configure it, analogous to fsconfig(). Brauner said the right approach would be to create an option to pidfd_open() to create an empty process. A series of calls to a new pidfd_config() system call would then configure this new process as desired, setting up its environment, image to execute, and more.
Chen agreed that Brauner’s broader API sketch was superior and indicated that future work would follow this direction. A user-space proof-of-concept by developer gutschke (safeexec) was discussed as a way to validate concepts without kernel changes, though it was noted as non-portable and experimental. Consequently, the spawn template proposal will not be merged, with future work focusing on a native posix_spawn implementation.


