LWN: Comments on "Multi-generational LRU: the next generation" https://lwn.net/Articles/856931/ This is a special feed containing comments posted to the individual LWN article titled "Multi-generational LRU: the next generation". en-us Sat, 30 Aug 2025 01:50:56 +0000 Sat, 30 Aug 2025 01:50:56 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Multi-generational LRU: the next generation https://lwn.net/Articles/858940/ https://lwn.net/Articles/858940/ Hi-Angel <div class="FormattedComment"> I have 2 comments for this thread, both regarding HDD and SSD.<br> <p> First, for HDD: I&#x27;m the guy who posted the testimonial that the v3 of the patches refers to, and I am using HDD. So, just in case anyone&#x27;s wondering about behavior on HDD specifically, here it is.<br> <p> Second, for SSD: I see here an attitude that once you create a SWAP on SSD, all problems are gone. So here&#x27;s my experience: this is not true.<br> <p> My gf has a Macbook 2013 with SSD, 4G RAM, ZSWAP. She always had swap-partition on the SSD. Before I went out to try the patches on her laptop, she have also had frequent SWAP-storms, her overall experience was pretty bad.<br> <p> After I configured her system to use the multi-LRU patches (v2), her experience improved a lot. Now the only moment when lags start appearing is when her SWAP usage goes to around 7-8G (Idk why exactly that size).<br> <p> So, for anyone out there thinking creating a SWAP on SSD will magically solve any need in the memory reclaim rework — that ain&#x27;t true.<br> <p> </div> Thu, 10 Jun 2021 11:46:23 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857603/ https://lwn.net/Articles/857603/ anton My recommendation is to have no swap if the backing device is a HDD. Why? If the system needs so much RAM that it starts swapping, it becomes unusable anyway. <p>With an SSD, swap may be more viable. And if you swap rarely, don't worry about the limited number of SSD writes possible. If you swap often, buy more RAM. Fri, 28 May 2021 18:17:22 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857422/ https://lwn.net/Articles/857422/ yuzhao@google.com <div class="FormattedComment"> The building blocks are similar: the access recency, the access frequency and shadows/ghosts.<br> <p> The fundamental arguments are different: the multigenerational lru argues that pages that have been used only once (if we are sure) are always the best choice, no matter how recent they were used, because 1) even some of them are not, they will be protected upon the second access; 2) the cost to ascertain whether the rest are better or not is higher (to do so we probably have to scan more than half a million pages on a 4GB laptop under moderate pressure, and there is no guarantee we&#x27;d make better choices after we have done it).<br> <p> Essentially, ZFS ARC is a *cache* replacement implementation, which discovers page accesses reactively by hooks. For *page* replacement, we have to scan page tables proactive, which is far more difficult and expensive in terms of discovering page accesses.<br> </div> Thu, 27 May 2021 07:29:20 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857401/ https://lwn.net/Articles/857401/ nybble41 <div class="FormattedComment"> I think the problem here is the &quot;number of accesses&quot; metric. All that matters for predicting how likely the page is to be needed in the future is whether the page *was* accessed (over some predetermined interval), not the number of read() calls or the number of bytes read.<br> <p> <font class="QuotedText">&gt; … is a 4096-byte read from a page the same number of accesses as 4096 1-byte reads from the page, or as 1 1-byte read from the page?</font><br> <p> In my opinion: both. A single 4096-byte read, 4096 separate 1-byte reads, and a single 1-byte read (all within a single sample interval) should all be weighted the same for determining whether to keep the page in RAM. Of course the final decision should be based on multiple sample intervals, not just one sample. A better metric might be how long the page has gone without any access vs. how many times the data has been faulted back into RAM after being discarded.<br> </div> Wed, 26 May 2021 21:43:09 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857385/ https://lwn.net/Articles/857385/ iabervon <div class="FormattedComment"> It&#x27;s a little hard to compare numbers of fd-based accesses with numbers of direct accesses; you generally read a bunch of data with one syscall and then do multiple reads out of anonymous memory, but you don&#x27;t generally bother to copy parts of a mmapped file into anonymous memory.<br> <p> How you perform your accesses kind of has to matter in order to make sense, regardless: is a 4096-byte read from a page the same number of accesses as 4096 1-byte reads from the page, or as 1 1-byte read from the page?<br> </div> Wed, 26 May 2021 18:48:25 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857274/ https://lwn.net/Articles/857274/ intelfx <div class="FormattedComment"> I may be ignorant (and quite likely am), but isn’t thia thing basically ZFS’ ARC with extra steps?<br> </div> Wed, 26 May 2021 12:36:37 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857267/ https://lwn.net/Articles/857267/ garloff <div class="FormattedComment"> Doesn&#x27;t x86 have an accessed bit in the PTE that the CPU sets on access?<br> Lazily scanning pages for this bit, counting and clearing it again would seem like a way to approximate non-fd page access.<br> Maybe the kernel already does this? <br> </div> Wed, 26 May 2021 06:56:10 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857255/ https://lwn.net/Articles/857255/ yuzhao@google.com <div class="FormattedComment"> There are lots of people who couldn&#x27;t afford high memory laptops. I implore you not to take your quality of life for granted for the rest of the world.<br> </div> Wed, 26 May 2021 04:01:30 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857253/ https://lwn.net/Articles/857253/ yuzhao@google.com <div class="FormattedComment"> In practice, there is no way to track how many times a page has been accessed via page tables mapping it.<br> <p> From: <a href="https://lwn.net/ml/linux-kernel/CAOUHufbz_f4EjtDsMkmEBbQphXj3ET+X6SM8JUPQ4b2jJmUzvA@mail.gmail.com/">https://lwn.net/ml/linux-kernel/CAOUHufbz_f4EjtDsMkmEBbQp...</a><br> <p> Remark 1: a refault, *a page fault* or a buffered read is exactly one<br> memory reference. A page table reference as how we count it, i.e., the<br> accessed bit is set, could be one or a thousand memory references. So<br> the accessed bit for a mapped page and PageReferenced() for an<br> unmapped page may carry different weights.<br> </div> Wed, 26 May 2021 03:40:13 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857227/ https://lwn.net/Articles/857227/ MattBBaker <div class="FormattedComment"> I would argue the opposite. With disk space as fast and cheap as it is now, why not have a 1:1 mapping between swap and RAM with /proc/sys/vm/swappiness set to 100? With a kernel that believes in over committing memory, being able to blow away the entire working set in an instant is a positive. My QoL has vastly improved on my linux workstation after I give it gobs of swap, since I no longer worry about it thrashing a tiny swap file as the OOM killer desperately looks for an alternative to firefox to knife.<br> </div> Tue, 25 May 2021 17:30:09 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857220/ https://lwn.net/Articles/857220/ mwsealey <div class="FormattedComment"> The kernel already does this on reclaim as a last resort, so...<br> </div> Tue, 25 May 2021 16:52:23 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857187/ https://lwn.net/Articles/857187/ comicfans <div class="FormattedComment"> <font class="QuotedText">&gt;Windows XP and spinning rust used to grind to a halt on heavy memory use</font><br> <p> maybe I&#x27;m lucky, I haven&#x27;t hit XP halt even once with celeron1.7 + 845G + 256RAM + HDD . IIRC, I&#x27;ve run many apps which definitely exceeds 256MB, it got slower, but never stop responding. <br> <p> <font class="QuotedText">&gt;and Win10 puts a device out of action for hours upgrading and patching itself if you still have a rotating hard disk.</font><br> <p> we all know windows update isn&#x27;t good, but we&#x27;re talking about high memory pressure, not a bad system update. <br> <p> <font class="QuotedText">&gt;I&#x27;ve disabled swap and bought large amounts of RAM so that apps can&#x27;t get stroppy about memory pressure. Only recently have I configured zswap but it&#x27;s not noticeably changed my experience.</font><br> <p> it doesn&#x27;t apply if laptop have none-replacable ram. and memory leak (maybe by accident) can eat as much ram as you have. of course better hardware can resolve many software problems, but should it stop kernel improve experience on old hardware ? while slower-bigger storage is still cheaper than faster-smaller storage, swap is always needed (that&#x27;s why bcache/lvm-cache exist)<br> </div> Tue, 25 May 2021 14:41:23 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857178/ https://lwn.net/Articles/857178/ k3ninho <div class="FormattedComment"> <font class="QuotedText">&gt;while using windows, I&#x27;ve never seen system hang due to high memory usage, but such problem can easily makes linux &quot;hang&quot;: gui/terminal not respond to any key in reasonable time/ ssh timeout ,you can&#x27;t kill bad app, anything you&#x27;re doing just makes it slower. you may wait it for hours (or forever) to restore, or just hard reset. I&#x27;ve hit such problems multi times.</font><br> Windows XP and spinning rust used to grind to a halt on heavy memory use, and Win10 puts a device out of action for hours upgrading and patching itself if you still have a rotating hard disk.<br> <p> That&#x27;s more about the latency of storage access. What is the current advice about RAM and swap? I ask because, since having NAND-based SSD&#x27;s with block overwriting concerns, I&#x27;ve disabled swap and bought large amounts of RAM so that apps can&#x27;t get stroppy about memory pressure. Only recently have I configured zswap but it&#x27;s not noticeably changed my experience.<br> <p> I think that this is something that should involve running user-experience items at elevated nice levels and using the alt-sysrq keys to safely OOM-kill and then unmount filesystems if you can&#x27;t recover the device.<br> <p> Are we still advocating for swap in 2021?<br> <p> K3n.<br> </div> Tue, 25 May 2021 12:05:17 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857171/ https://lwn.net/Articles/857171/ epa <div class="FormattedComment"> I guess the kernel could randomly sprinkle access restrictions over a selection of userspace pages, on architectures that support it. When a process tries to access that page, it gets a memory protection fault. The kernel updates a usage count for the page, removes the restriction, and lets the process continue. As long as only one in a million page requests gets faulted in this way, it might not noticeably affect performance. The question is whether it&#x27;s possible, and whether it would give high quality information on what pages are being used.<br> </div> Tue, 25 May 2021 07:32:37 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857169/ https://lwn.net/Articles/857169/ comicfans <div class="FormattedComment"> If you&#x27;re browsing lots of web page, you may easily hit swap storms problem(even on powerful laptop). this may be problem of (possible) memory leaked browser or bad oom killer, but kernel indeed needs improvement under such situation. <br> <p> while using windows, I&#x27;ve never seen system hang due to high memory usage, but such problem can easily makes linux &quot;hang&quot;: gui/terminal not respond to any key in reasonable time/ ssh timeout ,you can&#x27;t kill bad app, anything you&#x27;re doing just makes it slower. you may wait it for hours (or forever) to restore, or just hard reset. I&#x27;ve hit such problems multi times.<br> <p> taken from patch mail: <br> <p> ...8G RAM + zswap + swap... lots of apps opened ... LSP/chats/browsers...<br> gets quickly to a point of SWAP-storms...<br> system lags heavily and is barely usable.<br> ... migrated from 5.11.15 kernel to 5.12 + the LRU<br> patchset... Till now I had *not a<br> single SWAP-storm*, and mind you I got 3.4G in SWAP. I was never<br> getting to the point of 3G in SWAP before without a single<br> SWAP-storm.<br> <p> <p> <p> </div> Tue, 25 May 2021 03:50:26 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857163/ https://lwn.net/Articles/857163/ dxin <div class="FormattedComment"> I like the technical aspect of this work, but doesn&#x27;t it feel like users under tight memory constraint is steering the development? Yes, I know they are the majority now, e.g. Android phones and cloud providers, but what&#x27;s the frequency of page out on our laptops? One page per week?<br> <p> This is like the opposite of I/O scheduler situation, where users with very fast NVMEs drives it.<br> </div> Tue, 25 May 2021 01:56:46 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857145/ https://lwn.net/Articles/857145/ NYKevin <div class="FormattedComment"> The wording of the article suggests that this is not a policy decision so much as a &quot;we measure what we can measure&quot; decision. Nobody wants to fire an interrupt handler on every single (userspace) memory access. If it came in via a page fault, then that would imply that it was previously not in memory and did not have a frequency count in the first place. If it got refaulted, then it should be counted, and the article says that it is counted.<br> <p> Frankly, I&#x27;m not sure I understand the change you are proposing.<br> </div> Mon, 24 May 2021 18:58:03 +0000 Multi-generational LRU: the next generation https://lwn.net/Articles/857141/ https://lwn.net/Articles/857141/ dancol <div class="FormattedComment"> <font class="QuotedText">&gt; Specifically, tiers are a way of sorting the pages in a generation by the frequency of accesses — but only accesses made by way of file descriptors. </font><br> <p> [Twitch] Please, God, no! An access to a page should be an access to a page regardless of whether that access came from a file descriptor operation, from a page fault, from a kernel file server, or from any other source. The kernel should not be making policy decisions based on how an application chooses to spell its resource access!<br> </div> Mon, 24 May 2021 18:00:44 +0000