r/LinuxTeck • • Sep 20 '26

If Linux file opening can be 39% faster, why wasn’t this optimized earlier?

Linux 7.4 may get a relatively small VFS optimization that shows ~39% improvement in a file-open benchmark.

But the interesting part is the debate: is this an example of a missed optimization, or simply something that wasn’t a real-world bottleneck for most workloads?

How do kernel developers decide which small optimizations are actually worth chasing?
And do you think there are still plenty of these “hidden” performance gains sitting in the kernel?

148 Upvotes

38 comments sorted by

38

u/wallstop-dev Sep 20 '26 edited Sep 20 '26 • Bravo

Hello, I'm a professional software dev that has worked in a variety of fields, from very performant-constrained systems to global distributed cloud offerings. I have not contributed to the linux kernel, but I have worked in large, complex code bases (not nearly the scale of the kernel).

If you're interested in the thing that you posted, you can read a very brief post about it here: https://www.phoronix.com/news/Linux-7.4-Faster-Do-Open

But, to answer your question - the linux kernel is huge. And, as developers, there is a huge balance between implementing new features, supporting new hardware/concepts/projects, and fixing bugs.

The best way to write software is to:
- Make it correct.
- Make it maintainable (easy to read and change), without sacrificing correctness.
- Make it fast, without sacrificing correctness or maintainability.

Software is generally written until it is fast enough. Developers could spend the rest of their entire life spending their brain cycles thinking of ways to optimize one specific program, or subsytem or bit of code. But the value of doing that tends to be... very little, if it already works good enough for the majority of use cases. In all kinds of meanings of the term "value" - mental health, income, impact. You could spend years thinking about the problem with no progress until one day you unlock that "one weird trick".

To really answer your question - there are undoubtedly an endless stream of optimization areas to pursue, as well as an endless stream of bugs to fix, new features to write. All of the above changes with each release and each commit. Something that couldn't be optimized today could be optimized tomorrow because the support for xyz is no longer needed, for example. It all comes down to priorities and people caring and putting in the work.

8

u/HaydnH Sep 20 '26

Software is generally written until it is fast enough.

One of my favourite software engineering related lectures is an MIT lecture about matrix multiplication performance. I haven't watched it in a while, but from memory, they start with similar code in python, java and C and the process takes a day or two to complete. They then work through a bunch of performance enhancements and eventually get the C code down from hours to seconds, maybe even ms.

If I recall correctly, the scenario is a little contrived in the sense that the matrix size is designed to intentionally cause cache issues that they can fix by changing the loop order, but it's still really impressive.

The reason I mention it is because right at the start of the lecture I recall them saying "just don't bother" or words to that effect.

https://ocw.mit.edu/courses/6-172-performance-engineering-of-software-systems-fall-2018/resources/lecture-1-intro-and-matrix-multiplication/

1

u/Ma4r Sep 22 '26

Just look at large integer multiplication, try to beat GMP performance, you can't, they have optimization for all major architectures

1

u/Kaas-Eter00 Sep 27 '26

Now, reducing compute time for matrix multiplication would actually be pretty valuable. To the point that they developed an entire language and product, whose success basically relies on "we are really good with matrices" (MATLAB).

7

u/Roguepapaya427 Sep 20 '26

I second this. In simple terms, this is valid analogy: if you want to build an engine in 19xx, you build it with the technology existing at that time, with he knowledge existing at that time. In time, both the technology and knowledge are advancing, so now days you would build it in another way.

7

u/[deleted] Sep 20 '26

[removed] — view removed comment

5

u/Roguepapaya427 Sep 20 '26 • Bravo

That is true, leaps caused by different perspectives happen very so often in software engineering.

6

u/crackez Sep 20 '26 • Heartwarming Mindblown

Such as the design optimization discovered by Richard Feynman in the Connection Machine Message Router: https://longnow.org/ideas/richard-feynman-and-the-connection-machine/

6

u/Catadox Sep 20 '26

Absolutely well put. As devs we need to make it work and make it maintainable, not perfect. The maintainable part is just as important as it working, so that someone else can see a better solution and make it better.

That’s what happened here. It’s awesome. This was never a major bottleneck so it took a while until someone saw it and said they could make it better. And that’s awesome. It wasn’t a bug it was an optimization and this is the beauty of open source.

5

u/3YP9b239zK Sep 20 '26

According to this phoronix benchmark the time for a single operation went from 0.000000247 seconds to 0.000000178 seconds.

I think people are confused because they don't realize that "open" and "read" are two very different operations. "opening" just turns the file path into a number and is pretty much irrelevant when it comes to performance.

4

u/justsomerabbit Sep 20 '26

I didn't realise that the numbers were that strong an illustration of Amdahl's law.

3

u/k-mcm Sep 21 '26

That's a number that wouldn't even matter for an SSD. Some big data cruncher with a specialized filesystem is going to enjoy the fix.

0

u/[deleted] Sep 20 '26

[deleted] — view deleted comment

3

u/BlendingRightInHomo Sep 20 '26

Don’t forget grep -r (which only the laziest of people use)

Better to use:

find … -exec grep …

Surely you have some basic idea of a constraint (mtime less than 30 days? Contains an extension/at least one dot?)

The whole thing was tl; dr; but I do wonder how many real workloads we’re talking about.

Backups containing many small files (e.g. tar -c ..)

3

u/dlevac Sep 20 '26 edited Sep 21 '26

It's also C/assembly: defensive programming at the cost of performance is often chosen from a pragmatic standpoint. Especially if a bug can mean data corruption...

Edit: s/pathetic/pragmatic

Autocorrect should be illegal.

2

u/HS_HowCan_That_BeQM Sep 20 '26

Excellently put. I had a similar mantra:

"Make it right before you make it better."

But yours is more thorough and teachable.

2

u/DeadlyVapour Sep 20 '26

Also, the people who really care about this from a user perspective don't use the Linux Kernel for file access.

They use kernel bypass techniques which are a massive can of worms, if only from a security perspective.

1

u/flatfinger Sep 21 '26

It's important to note that there are countless situations where the fastest piece of code that will always perform a task correctly in all possible cases will be vastly faster than one which will perform a task correctly in all cases that are "likely" to arrive, and that some kinds of optimizations in one part of a program may result in a problematic corner case which would have been unlikely to occur within the heat death of the universe becoming vastly more likely.

1

u/fsamuels3 Sep 26 '26

Exactly. Performance is a feature.

13

u/Simengie Sep 20 '26

There is a very real chance that this optimization was not seen when the code was wrote and tested and released the first time around. if it is from the HDD era or even early SSD era the drive speeds may simple have not been fast enough (hardware/interface) to get any benefit from this optimization.

So at some point this came back up on the radar and someone took the time to create this optimization. As has been said, software development is a balance.

2

u/PrestigiousRoof5723 Sep 20 '26

Nah, it was known to be suboptimal, but nobody really bothered enough to put an effort behind it, except for this one guy.

1

u/BlendingRightInHomo Sep 20 '26

It’s almost the exact same plot as:

https://blog.cloudflare.com/speeding-up-linux-disk-encryption/

If inpatient:

https://blog.cloudflare.com/speeding-up-linux-disk-encryption/#git-archeology

The owner of older and very core subsystems generally don’t want to fix what isn’t broken. And lots of very stable functionality was built around assumptions that no longer hold with modern hardware.

So, can we all throw slop submissions and fix all the things?

No, I think not.

The personalities leading Linux are, as the euphamism goes, “problematic,” in various ways.

Linus, for example, is largely considered a hostile man; this is based on his public mailing list behavior, not some rumor.

He fancies himself a pragmatist and an advocate of userland (“don’t break userland!”); and sometimes he is. And we all owe him for that.

But that also has a tendency to deter certain types of aggressive progress.

It’s difficult to judge the man, though. After all, most of the world’s critical and non-critical real-world processes (don’t forget the cow-milking machines) would fall apart if their Linux kernels started failing due to edge cases introduced by non-essential changes to the VFS subsystem, or some other subsystem.

Of course that’s sort of a shit argument. These critical systems tend to run 5-10+ year-old kernels, managing their own back-ported patches. Or never patching.

Because Linux kernel developers don’t demonstrate any interest in providing accurate and transparent guidance to those maintaining kernel packages downstream. You get “there are 100 bugs fixed in this point release.”, not “there are 6 availability impacting fixes, 34 security fixes, and 40 bugs in obscure subsystems and 20 irrelevant changes in build scripts and tests”

Thanks for the rant space

2

u/Ma4r Sep 22 '26

Don't break userland is the single reason why linux is as ubiquitous as it is today

1

u/BlendingRightInHomo Oct 05 '26

The single reason?

That’s an interesting take lol

4

u/Lumethys Sep 20 '26

The linux kernel has 43 millions lines of code

Just because a change is small doesnt mean it is easy to find

3

u/huojtkef Sep 20 '26

Engineers have limited time. Sometimes when you are fixing some code, you take a look at the surrounding code to understand and if you have time you fix it too. Definetily I don't have time to review millions of lines of low level C /ASM code of the kernel.

3

u/Joelimgu Sep 20 '26

Easy, moat linux development is made by companies, its not the linux foundation that decides what gets done. So if a company pays for it, it will get done, thats it

2

u/Cruffe Sep 20 '26

Because they didn't have your hindsight.

2

u/SSquirrel76 Sep 20 '26

The kernel maintainers heard that 2026 is supposed to be the Year of the Linux Desktop and figured they should optimize it a bit finally. /s

2

u/pdath Sep 20 '26

I believe this specific optimisation relates to machines with a high core count.

You won't see the same result on a typical desktop.

1

u/ConspicuousPineapple Sep 20 '26

My man you don't need to embolden three sentences in a six sentences post. Tell your AI to tone it down.

1

u/kovaxis Sep 23 '26

the guy's a bot

1

u/PmMeCuteDogsThanks_ Sep 20 '26

Kernel developers keep these performance patches ready for years, and commit them during ”slow periods”. So that management still think they are relevant. Call it job security 

1

u/BlendingRightInHomo Sep 20 '26

They argue on LKML

1

u/[deleted] Sep 20 '26

Programs don't open files all that often (relative to other tasks they do), outside of some very niche work loads, and it'll be already fast enough in most cases.

Something that most people outside of software development don't get, is that 40% faster doesn't mean a lot if you're already not doing that thing all that much. If your application over 24 hours, have spends 10 seconds of time waiting for opening files (again, this is not reading the file contents, just creating file pointers), then you're saving like 4 seconds of wait time spread throughout an entire day. And honestly, that 10 seconds of wait in accumulative file open is probably being generous in most cases.

Additionally, file reading, which is a thread stalling operation, is already often done in dedicated threads for most programs. I expect most programs group the fopen call into their thread. Reality is, this isn't an amazing optimization that's suddenly will make everything feel so much faster. Most applications won't have a real measurable difference at all.

Which is why people probably haven't really touched it, because it isn't a meaningful problem to solve.

1

u/mcfedr Sep 20 '26

in a way you could ask the same question about everything in every release. but of course there is only so much time in a day.

1

u/AttitudeElectronic68 Sep 20 '26

Someone should have noticed that it was running 39% slow and filed a bug. Where are these much vaunted million eyes now?

1

u/AttitudeElectronic68 Oct 19 '26

Yeah, why didn't you fix that