Simple Optimization For Linux 7.4 Can Open Files For Reading ~39% Faster

Simple Optimization For Linux 7.4 Can Open Files For Reading ~39% Faster

More than two years in the making, Linux 7.4 is poised to introduce a patch that amounts to a rather simple optimization to avoid unnecessary/duplicative work that can net some nice gains when opening files for reading. Open-source developer Mateusz Guzik has been leading the effort to optimize the Linux kernel's do_open() VFS function used as part of opening files from a pathname lookup. Currently there is a duplicate directory entry "dentry" for translating the path component to the disk inode as part of the file opening process, which Guzik is optimizing out that duplicative dentry. Guzik explained in the patch that went through five revisions in the past two years: "Opening a file grabs a reference on the terminal dentry in __legitimize_path(), then another one in do_dentry_open() and finally drops the initial reference in terminate_walk(). That's 2 modifications which don't need to be there -- do_dentry_open() can consume the already held reference instead." It ends up being a rather significant benefit to avoid that unnecessary work as benchmarking on a 20-core VM with a will-it-scale benchmark of opening the same file in read-only mode, the operations per second increased by 39%. It's a bit surprising such low-hanging fruit was left in the Linux kernel this long. At least the improvement should be in the stable kernel before the end of 2026. The three dozen lines of code patch is queued into VFS.git's vfs-7.4.lookup Git branch. With the patch now in a formal VFS subsystem Git branch and labeled as far as "7.4" material, look for this optimization to be submitted for the upcoming Linux 7.4 merge window.

Original Source

Read the full article at Phoronix →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.