Hacker News new | ask | show | jobs
by lstodd 986 days ago
The whole point is that pagecache does not cause any swap hits.

Oh my god, it's 2023 and we're still discussing this idea from 1970s.

Is that so hard to grasp? No, stuff gets evicted from the cache long before you hit the swap, which is by the way measured by page swap-out/in rate and not by how much swap space is used, which is by itself a totally useless metric.

2 comments

> stuff gets evicted from the cache long before you hit the swap

No...?

I'm looking at a machine right now that has 3.7GB not swapped out and 1.2GB swapped out. Meanwhile the page cache has 26GB in it.

Swapping can happen regardless of how big your page cache is. And how much you want swap to be used depends on use case. Sometimes you want to tune it up or down. In general the system will be good about dropping cache first, but it's not a guarantee.

> measured by page swap-out/in rate and not by how much swap space is used

Eh? I mean, the data got there somewhere. The rate was nonzero at some point despite a huge page cache.

And usually when you want to specifically talk about the swap-out/in rate being too high, the term is "thrashing".

cached disk pages are not going to be swapped out, they're just freed (because these pages are already "out" in the same place swapland is)

if your cached disk pages keep getting hit and are "recent", they're going to stay in, and your old untouched working pages are going to be swapped out, to make room either for new working pages because you've just loaded new programs or data, or to make room for more disk pages to be cached because your page cache accesses are "busier" than some of your working pages.

you will swap out pages to make room for disk cache, but your cached disk pages will never be swapped out, they are just tossed (of course, after any dirty pages are written)

> The whole point is that pagecache does not cause any swap hits.

> Oh my god, it's 2023 and we're still discussing this idea from 1970s.

> Is that so hard to grasp? No, stuff gets evicted from the cache long before you hit the swap, which is by the way measured by page swap-out/in rate and not by how much swap space is used, which is by itself a totally useless metric.

Not everyone has been alive and into this stuff since the 1970s. That you and I know about this is irrelevant for the new people discovering it for the first time. There is always going to be a constant trickle in from new sources, for as long as it takes for the tech to go away. See relevant xkcd: https://xkcd.com/1053/

But it's also worth pointing out that RAM/swap/page cache isn't always as simple as page cache out, RAM in. For example, this question[1] seems to indicate that things aren't as simple as you suggest.

[1]: https://unix.stackexchange.com/questions/756990/why-does-my-...

The page cache mechanism is very much alive. That's what we were discussing, is it not? I only lamented the fact that over 50 years the basics of how it works should have become common knowledge but did not.

As for the link you provided, I do think I can get a system in a state like that, and that isn't even untrivial. To push firefox into swap, esp if you have just 8 gigs of it is.. simple. But it is not in any way a normal state of a system. Idk how the author got it in that state.