News: 1738175411

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Tiny Linux kernel tweak could cut datacenter power use by 30%, boffins say

(2025/01/29)


Hardware keeps getting faster, but it's still worth taking a step back periodically and revisiting your code. You might just uncover a little tweak that wrings out more efficiency or extra throughput than you'd expect.

That's exactly what researchers at Cheriton School of Computer Science at the University of Waterloo have managed to do. Just around 30 lines of [1]code — to the Linux kernel's network stack, and [2]they say you could curb datacenter power consumption by up to 30 percent.

These changes have now been published as part of the 6.13 kernel release, making their way to the public.

[3]

The project was born out of a desire to explain how it was possible that user-level networking approaches could achieve such grandiose performance compared to kernel-level approaches, Professor Martin Karsten told El Reg .

[4]

[5]

Traditionally, he explained, Linux networking has been interrupt driven. As new data came across the network, a system interrupt was triggered, and the CPU core would pause its current task so it could process packets. This made it well-suited to environments where multiple users might run jobs simultaneously.

"In the old school system the operating system was a facilitator of multi-user activities," Karsten said. "You have a server; you have lots of people logged in doing all sorts of little things; and the operating system constantly needs to look after everybody and establish fairness."

[6]

A lot has changed since then. Many modern throughput-oriented workloads — think reverse proxies or caching — can consume resources equivalent to multiple traditional systems. For these kinds of apps, Karsten tells us, it can be more efficient for the application to poll the network when it's ready to take on more work.

"My application either has work or it doesn't have work. If it does have work, why would I bother looking at the network? I'm already busy," Karsten explained. "I do the work that I have, and then I'll look at the network."

By reducing the number of interrupt requests, or IRQs, the host CPU can spend more time crunching numbers and less time waiting on packets that aren't ready to process.

[7]

This is already possible in user space, but it does take some work. You need to know whether your application will benefit from this approach and then implement it, Karsten added.

Constantly polling the network also comes with overheads of its own. "When traffic is low, you're still burning through your core, which is extremely inefficient with respect to power consumption," he added.

With this insight, the research team looked for a way to accomplish both. What they came up with was a kernel patch introducing adaptive polling. During periods of heavy traffic, this allowed the host to poll the network for a new chunk of data as soon as it was finished processing the last. If traffic died down and there were no new numbers to crunch, the system could then revert back to an interrupt-based approach, saving energy in the process. More importantly, because all of this is handled in the kernel, it's essentially automatic.

Researchers first demonstrated a rudimentary implementation of this capability in a paper [8]published in 2023. At this point, Karsten realized that this work could have implications beyond a research paper and began working with Linux kernel dev and Fastly CTO Joe Damato to integrate the functionality.

[9]What happens when we can't just build bigger AI datacenters anymore?

[10]Tech stocks tank as US AI dominance no longer a sure bet

[11]AMD's Victor Peng: AI thirst for power underscores the need for efficient silicon

[12]Real datacenter emissions are a dirty secret

According to Karsten, the performance implications of the patch could be quite significant. Early testing showed it could boost throughput by up to 45 percent without compromising tail latency. Meanwhile, for the same load, he said the reduction in resources previously wasted on interrupting heavy network overheads could curb power consumption by as much as 30 percent.

Of course, those are the best case scenarios. Not every application is going to see this level of performance improvement. Karsten tells us that throughput heavy apps should benefit the most. "There are applications out there such as Memcached… that don't do much else but network communication."

Even if the savings are much lower on average, he argues that's still a considerable amount of power across all the Linux boxes in the wild.

Speaking of which, these savings won't be realized overnight as it could take a while before a kernel sporting the modifications make its way into the kind of long-term-support (LTS) releases favored by enterprise customers.

Unfortunately, it appears that even when the kernel does see widespread adoption in the datacenter, it may not do much for the AI clusters. This is because in AI and HPC applications a technology called remote direct memory access or RDMA has long been preferred.

"This approach eliminates the need for CPU cycles in network data processing, forming the foundation of high-performance interconnect technologies," Gilad Shainer, SVP of Networking at NVIDIA, told The Register .

Even still, for Karsten, the patch underscores the importance of revisiting software stacks not just at the kernel or application level, but middleware, libraries, and everything else. "I think there are so many inefficiencies that we can eradicate and I think the time is soon," he said.

"Nobody spent any money on this in the past because why worry if hardware is twice as fast next year," he added. "But if that party ever stops, then we better look at the software."

And this is exactly where Karsten is planning to focus his research going forward. ®

Get our [13]Tech Resources



[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80b6f094756f

[2] https://cs.uwaterloo.ca/news/cheriton-school-computer-science-researchers-update-linux

[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/systems&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2Z5qzEgrroCZoV3csRxfmnwAAAIY&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/systems&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z5qzEgrroCZoV3csRxfmnwAAAIY&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/systems&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z5qzEgrroCZoV3csRxfmnwAAAIY&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[6] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/systems&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z5qzEgrroCZoV3csRxfmnwAAAIY&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[7] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_onprem/systems&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z5qzEgrroCZoV3csRxfmnwAAAIY&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[8] https://dl.acm.org/doi/abs/10.1145/3626780

[9] https://www.theregister.com/2025/01/24/build_bigger_ai_datacenters/

[10] https://www.theregister.com/2025/01/27/tech_stocks_tank_as_us/

[11] https://www.theregister.com/2024/08/29/ai_thirst_for_power/

[12] https://www.theregister.com/2025/01/22/datacenter_emissions_not_accurate/

[13] https://whitepapers.theregister.com/



if hardware is twice as fast next year

Mage

That was very true 1975 to 1995, a bit less 1996 to 2006. Generally not true at all now. The party is over if you care about power and cooling. An SSD vs HDD for the OS has now more impact for laptop users for new vs 5 year old model.

Re: if hardware is twice as fast next year

An_Old_Dog

I'd find it humorous if designers hit an previously-unknown hardware-speed ceiling, and everyone went back to assembler and optimised FORTRAN to achieve further effective-speed increases.

Re: if hardware is twice as fast next year

Herring`

I feel old in that I have spent a lot of time getting C++ code to run faster - execution profilers, custom heap management, that sort of stuff. These days even assembler is a high-level language - the processor is performing all sorts of shenanigans with register renaming, out-of-order execution, speculative execution, contributing to the climate breakdown that may kill us all ...

Re: if hardware is twice as fast next year

navidier

>I feel old in that I have spent a lot of time getting C++ code to run faster - execution profilers, custom heap management, that sort of stuff. These days even assembler is a high-level language - the processor is performing all sorts of shenanigans with register renaming, out-of-order execution, speculative execution, contributing to the climate breakdown that may kill us all ...

Have you ever looked at your memory map? I find many people don't recognise that a C++ object is basically just a C struct with added subroutines (methods). This means that the memory layout is *forcibly* constrained by the order of member declarations. The compiler *must* add padding between members of different sizes where needed to maintain "natural" memory alignment. So, e.g. on a modern computer, if you first declare a _char_ object followed by a _double_ the compiler must add 7 bytes of unused padding so that the double is naturally aligned.

Unfortunately, at least in the software I've had the pleasure/pain to investigate, developers tend to declare object members in order of perceived functionality rather than memory size. I recall one instance where I went through a fairly complex object, re-ordering declarations so that all methods (presumed to be 64 bit pointers) came first, then all doubles. then all ints/floats, and finally byte-sized members (manually adding dummy members where necessary to maintain element alignment). I was staggered at the performance improvement that one change had on the overall performance of a fairly complex programme. It was in the tens of percents!

I'm not aware if such refactoring is available in modern toolchains. I hope it is, because the compiler itself is handicapped to follow what is laid out in the object definition.

Re: re-ordering declarations

Mage

That is something that could be done automatically by a compiler. However while it might "waste" a bit of RAM it would have a negligible effect on performance.

Actually the early C++ compilers for Xenix, MS DOS, Atari, Amiga etc in 1987 by Glockenspiel in Dublin simply converted the source to C and then used a pre-existing C compiler for that platform.

Re: re-ordering declarations

Brewster's Angle Grinder

"However while it might "waste" a bit of RAM it would have a negligible effect on performance."

Two words, my friend: "cache lines."

Although normal methods don't appear in the structure so their location doesn't matter. And IIRC there are compilers switches and pragmas to deal with efficient packing and ordering of members because mucking about with some structure will cause ABI issues so the compiler can't do it by default. (These days you even have _Alignof/alignof to query the alignment.)

Re: re-ordering declarations

bazza

I remember C++ compilers of that style. Alas I didn't get into C++ until long after "real" c++ compilers came along, and thought it a pity that I didn't pay attention earlier. Seeing how C++ renders down to C is probably an excellent way for C developers to thoroughly understand what C++ is actually all about. Just what is a v-table and why would I iterate over it? Well, here it is!

Possibly the same would be true of Rust. It could be interesting in the C vs Rust debate if Rust could be illustrated as "here's the equivalent C", and see what people make of it.

Re: re-ordering declarations

navidier

> That is something that could be done automatically by a compiler. However while it might "waste" a bit of RAM it would have a negligible effect on performance.

It can't, it *MUSTN'T*! Otherwise libraries written on disparate systems would not be able to intercommunicate.

My awareness of this goes back to the days of the Atari ST. People complained that hand-crafted assembler code crashed when accessing a particular C struct. It turned out that the particular struct was defined as something like (simplified)

{byte, b,int i ;}

The 68000 processor could not access odd-numbered memory. The C compiler correctly added a byte padding between *b and *i, but naive assembler implementations tried to access i as (*b)+1.

Re: went back to assembler

Mage

No, that would be worse. Since late 1980s or early '90s it's been possible to write video games and drivers in a HLL that runs as fast as assembler. Then there is the debugging and maintenance. And Fortran is 1956 technology. Language design and compiler development made that obsolete by the late 1970s. It's just some legacy scientific programs not worth re-writing that has kept Fortran alive.

Re: if hardware is twice as fast next year

Mage

Actually for cost, reliability and capacity I have Linux on the laptop PCIe SSD, but /var and /home are two partitions on a 2T 2.5″ SATA laptop drive added (one small and the other the balance as the laptop isn't running a humongous web site from /var). A bootable USB stick Linux makes it easy to configure that after the OS is installed on the SSD.

Doctor Syntax

The server would have had to have been spending an awful lot of time in kernel to get that sort of advantage.

Kernel

diodesign

Well, it is the network stack. Not exactly the device tree parser O:-)

C.

Anonymous Coward

Something like quad 10Gbe (40gb?) network interfaces with an intel atom synchronizing things.

TReko

This research smells of academic theoretical BS to me.

The typical interrupt service routine and kernel context-switch overhead is tiny. Parsing a few lines of json strings in user-space probably has more instructions.

Besides, this, all network hardware in the last 15 years has had buffer coalescing, so interrupts come through at variable rates depending on the load.

If you're pushing data out 100 GbE ethernet interfaces

DS999

You're already well past what a single core can accomplish just in the kernel - and that's despite all the stuff like checksumming that's offloaded to the NIC in such high end devices.

So I would readily believe a 30% speedup for the kind of loads where you have dozens of cores spending 100% of their time in kernel/interrupt processing.

Solviva

Wonder how this compares to good old interrupt moderation? Sounds like a similar idea - instead of interrupting on every interrupt, wait for either X interrupts before the application is interrupted (heavy traffic) else if Y time has passed since it was last interrupted (light traffic) fire an interrupt.

bazza

The patch docs talk about NICs coalescing interrupts anyway, and explain that as the NIC knows nothing about the application's behaviour it's "guessing", and therefore suboptimal.

The mechanism that's been introduced in effect allows an application to give a firm hint as to what degree of coalescing does make sense from the application's point of view, with the side effect that (if judged well) the application will always be asking for data just as the NIC / kernel was beginning to think about raising an interrupt.

Economy's kernel

Anonymous Coward

Similar or larger gains are achievable in the economy, if the tax code etc were properly reviewed and cleaned up.

Somehow the status quo has been maintained in the countries' governance, as if the actual policies are the wisdom itself. But so much has changed and the changes are accelerating. So maybe the Elon's Dept of Efficiency is not such a bad idea.

Confused

Rich 2

I’m confused about how this works in the kennel. Surely your application needs to do the switching between interrupt and polling because (a) only the application knows when it wants to read more data and (b) it is the application that needs to implement the interrupt handler or polling calls

So how is this made “automatic” in the kernel? What am I missing?

Or does this switching only relate to feeding data into the internet buffers for the application to read later? If yes then it still doesn’t answer point (a)

Re: Confused

Mage

The application doesn't know it wants to read more data till the device driver (in the kernel?) tells it. The application only knows when it wants to send data.

A simplification

Obviously a Web server can't know when network requests happen, and then later responds by sending. A Web browser issues requests (on the whim of the user) which is a small amount sent (unless a form post or upload) and then is waiting for a response. So a server (any kind of protocol) in a data centre (like a telephone exchange) can only roughly know when busy period are, but can't anticipate exactly the instant of demand, or the density of it. It's quite a different network load & traffic to a workstation/Laptop with a single user on a GUI.

Re: Confused

Brewster's Angle Grinder

Wild guess: the kernel knows whether a process is actively waiting on the socket or busy eating processor cycles. That's probably enough of a clue.

Re: Confused

containerizer

Applications indicate they want to read more data by notifying the operating system via select()/poll()/epoll(). These mean "stop me, then wake me up when more data is available". The details of how to discover whether or not data is available are hidden by the kernel so the application doesn't need to care, it just needs to correctly use the proper API. Note that the poll(), epoll() calls are not a direction to the kernel to use polling instead of interrupts.

Imagine it's a web browser waiting for a response from a server. Simplified, the application opens a socket and sends data to the server and waits for the response by calling poll() on the socket.

When that happens, the kernel kicks in. If there is no data on the socket, the kernel won't reschedule the application. Later, the server responds - an interrupt occurs, the kernel reads the data and then places it in the application's socket buffer. The application is then rescheduled and can immediately read the data as soon as it is resumed.

In the alternative world with polling, the application does not change. Instead of waiting for an interrupt, a timer inside the kernel periodically wakes up and checks for data. If it is there, it follows the same series of steps that it did when it got an interrupt. The application does not have to change.

Some network cards, typically the higher-end ones, already effectively support this with a feature called "interrupt coalescing" where they will wait for their buffers to fill up, or for a timer to expire, before notifying the CPU.

The approach mentioned in the article is likely to be beneficial in high throughput scenarios, but not all. There is a crossover point; if your I/O is frequent and regular, polling is more efficient than interrupts due to the extra interrupt servicing overhead. If the I/O is more patchy, polling may waste CPU cycles through doing polling work which rarely finds available data, and it may also introduce latency as a packet will have to wait for the next polling interval before being serviced. According to the article they're adopting a hybrid approach to switch between polling and interrupts depending on the conditions, which is clever. Tune that right and I'd say this feature will end up being enabled by default for most deployments.

Interrupts are great if your I/O comes and goes at random, relatively infrequent intervals, which might be the case for compute-bound workloads

Have They Measured the Whole Problem?

bazza

It's an interesting idea, but I do wonder.

One of the reasons to respond to NIC IRQs is to get that packet in, in memory somewhere, fast, so that more packets arriving on the network can all make their way through the limited buffers within the NIC. If the traffic load is such that the application isn't really keeping up, and one is now polling for available packets, it seems to me that there's the potential for network packets to get dropped. There is a parameter irq_suspend_timeout involved, which seems to be a timeout to ensure that the OS will start paying attention to the NIC if the application has taken too long to ask for more data. The suggestion is that this is tuned by the app developer "to cover the processing of an entire application batch" ; but, what about the NIC's ability to continue to absorb packets in the meantime?

The patch documentation doesn't mention packet loss, drop, etc at all, so I'm presuming that actually that's covered off somehow, hence no need to explain the risk of it.

The thing is, dropped network packets will start having a big impact on the amount of energy consumed by the network itself. It costs quite a lot of power to fire bits down lengths of fibre or UTP, and the energy cost of dropped packets starts being more than a doubling of that power (because there's more network traffic than just re-sending the dropped ones). So that's why I'm interested in whether or not they have got packet dropping covered off somehow.

However, on the whole, a clever idea and well worthwhile!

Tuning Architectures?

Ultimately, if more network traffic is being fired at a host than the host can consume, then the architecture is perhaps wrong, or wrongly scaled. Our networks effectively implement Actor Model systems, which are notable in that a lack of performance gets hidden in increased system latency, because it muddles through the data backlog eventually (or at least, that's the hope). Thus, it's tempting to write off the increased latency as "who cares", and move on. That is often entirely acceptable (which is why all networking and nearly all software kinda works that way).

However, if one adopts a more Communicating Sequential Processes view of networking (think Golang's go routines / channels, but across networks instead, or a http put), this has the trait that if a recipient of data isn't keeping up, the sender knows all about it (send / receive block until the transfer is complete - an execution rendezvous). There's no hiding a lack of performance in buffers in NICs, networks, because there aren't any (not ones that count, anyway). It sounds like a nightmare, but actually it's quite refreshing; inadequate performance is never hidden, and you know for sure what you have to do to address it. However, if you do get the balance of data / processing right, all the "reading" is started just as the next "send" happens, and the intervening data transport shouldn't find a need to buffer or interrupt anything.

This new mechanism brings the opportunity to kinda blend both Actor and CSP. It's "Actor", in that data could build up in buffers, but if an application / system developer did tune their architecture scale just right in relation to processing performance, the packets would just keep rolling in and be consumed immediately with barely an interrupt in sight, as if it were a CSP system but without any explicit network transfer to ensure the synchronisation of sending and receiving.

Of course, achieving that in real life is hard for many applications. There are some where there's constant data rates, e.g. I/Q data streaming from a software defined radio (well, the ADC part of it anyway). This new mechanism paired with the fact that PREEMPT_RT has just become a 1st rank kernel component (another hooray for that!) does some interesting things to the performance that could be achieved.

Hmm

Chris Gray 1

My experience here is from long ago, but...

It may matter as to how long the polling takes. If control registers/whatever have to be used to enable access to whatever can report that work is ready, you have to include that cost (plus the cost of putting the system back to normal operating state, even if that ends up being done in a quite different context) in the cost of polling.

In a very low-end old-style system, you could have a UART/whatever that makes it status available to the CPU with one access (likely a longer access than to RAM, but still). Polling will be cheap.

On the other end of the scale, perhaps your device is smart enough that you can give it a bunch of memory resources that it can fill up without needing the host CPU to do anything other than handle whatever is ready, when asked. Streaming right along with few needed interrupts and little overhead. I thought ethernet chips started doing this decades ago. What am I missing?

Stuff in the middle might need more host attention, so the tradeoffs will differ.

Given the reported improvements, clearly I'm missing something.

My direct experience was made a bit simpler by having a CPU with only one core, so full/empty flags in memory were enough. Incoming messages went directly into buffers, all within one interrupt (the hardware wasn't quite smart enough to properly clear the "empty" flag, if I recall correctly). The further-processing thread could take buffers that the interrupt code had marked ready, and could return buffers to that code similarly, all without anything waiting. Only when there was no more work to do in the in-memory buffers from the interrupt code would the thread go to sleep (after setting the "wake me up" flag of course!) Another variant for different hardware had a Linux device driver and my code in our hardware use similar conventions between them. These are essentially combinations of interrupts and polling, which is of course what you likely want.

15% gratuity added for parties over 8.