The Linux 7.4 Kernel Will Open Files for Reading Nearly 40% Faster
Translated by a model; the original is in Russian.
A patch is making its way into the upcoming Linux 7.4 kernel that, for all its simplicity, can meaningfully speed up opening files for reading. The work was carried out by open-source developer Mateusz Guzik, and it took more than two years — over that span the patch went through five revisions.
What exactly was fixed
The optimization concerns the do_open() function in the virtual file system (VFS) subsystem, which takes part in opening files during path resolution. As Guzik himself explained, in the current code the directory entry — the "dentry" responsible for mapping a path component to an inode on disk — is handled redundantly. When a file is opened, a reference to the final dentry is taken first in __legitimize_path(), then again in do_dentry_open(), while the original reference is dropped in terminate_walk().
The result is two unnecessary changes that can be avoided: do_dentry_open() is perfectly capable of using the reference already held rather than requesting a new one. It is precisely this duplication that the patch eliminated.
How much this speeds things up
The effect of this seemingly minor tweak turned out to be noticeable. In testing on a 20-core virtual machine using the will-it-scale benchmark, which opened the same file in read-only mode, the number of operations per second rose by 39%. The entire patch, meanwhile, fits into roughly three dozen lines of code.
Phoronix news author Michael Larabel notes that it is even a little surprising how such an obvious opportunity for improvement went unnoticed in the kernel for so long.
The patch has already been placed in the vfs-7.4.lookup branch of the VFS.git repository and marked as material for version 7.4. Given that it has landed in the official VFS subsystem branch, the optimization will likely be sent into the merge window of the upcoming Linux 7.4 kernel. The improvement is expected to reach the stable kernel before the end of 2026.
Source: Phoronix
Comments
Sign in, to comment.