Linux 7.0 Merges "Significant Improvement" For close_range System Call
#Infrastructure

Linux 7.0 Merges "Significant Improvement" For close_range System Call

Hardware Reporter
2 min read

The upcoming Linux 7.0 kernel includes a major optimization to the close_range system call, reducing its complexity from O(range size) to O(active FDs) for sparse file descriptor tables.

The Linux 7.0 kernel development cycle continues to deliver substantial performance improvements, with the latest merge bringing a significant optimization to the close_range system call. This system call, which closes all file descriptors in a specified range, has been optimized from O(range size) to O(active FDs) complexity, marking a notable advancement for systems handling large numbers of file descriptors.

LINUX KERNEL

The optimization was submitted by Qiliang Yuan of China Telecom and reviewed by Christian Brauner, who described it as providing a "significant improvement" for large-range close operations on sparse file descriptor tables. The change fundamentally alters how the kernel processes close_range requests by leveraging the open_fds bitmap rather than performing a linear scan across the entire requested range.

Technical Details of the Optimization

The previous implementation of close_range() performed a linear scan over the [fd, max_fd] range, resulting in O(N) complexity where N represents the range size. For processes with sparse file descriptor tables - where many file descriptors in the range are unallocated - this approach proved inefficient as it checked numerous empty slots.

The new implementation uses find_next_bit() on the open_fds bitmap to skip over these holes. This algorithmic shift from O(Range Size) to O(Active FDs) provides a substantial performance boost, particularly for applications that maintain large file descriptor ranges but only actively use a subset of them.

Context in Linux 7.0 Development

This optimization is part of the broader VFS (Virtual File System) improvements being merged for Linux 7.0. Last week's VFS pull requests introduced several other significant features including nullfs and open_tree_namespace, standardized generic I/O error reporting, and non-blocking timestamps. The close_range optimization represents another piece of the puzzle in making Linux more efficient at handling file system operations.

Practical Impact

For system administrators and developers, this optimization means faster cleanup operations when closing ranges of file descriptors. Applications that frequently use close_range, such as web servers, database systems, or any software managing numerous connections, may see measurable performance improvements during shutdown or resource cleanup phases.

The merge was completed today and is now available in the Linux Git repository, marking another step forward in the Linux 7.0 development cycle. With these kinds of optimizations being prioritized, Linux 7.0 is shaping up to be a release focused on both new features and performance refinements.

Comments

Loading comments...