Paging out memory can be 'global' or 'local' these days

March 20, 2021

The traditional way that operating systems (Unix and others) have implemented swapping (really paging) is on a global, system wide basis. All processes (from all users on a multi-user system) are in contention for the same limited pool of RAM, and the operating system can pick on pages from any process to be evicted from RAM. Page eviction decisions are made using global page replacement algorithms that are generally blind to what process was using what RAM. There were (and are) good reasons for this, including that global paging is simpler and that pages of RAM can be shared widely, including between otherwise unrelated processes.

(This sharing of pages can complicate what we mean when we talk about something's memory usage. Also, the global page eviction can still wind up scanning process by process.)

However, modern versions of Unix are increasingly adding ways to limit memory usage on a more fine grained basis, where one process, a group of them, or a general container is only allowed to use so much RAM (and there are hierarchical systems). Often hitting such a RAM limit causes the operating system to start evicting pages from whatever is being limited without touching the memory of other processes on the system (assuming that they aren't hitting their own limits). We can call this 'local' swapping, in contrast to the traditional system-wide 'global' swapping.

(Naturally this gets complicated if a page of RAM is used both by a process that's hit its limit and a process that hasn't. It's not really useful to keep stealing the page table entry from the limited process if the process just accesses it again and the page never actually leaves RAM.)

Applying local memory limits and creating local swapping can have performance impacts on the affected programs. But if you impose such limits, presumably you've decided that the performance impacts on the relevant processes are less important than the potential system-wide effects if you let everyone get into global swapping.

In general, local swapping isn't guaranteed to be sufficient by itself, especially if people are allowed to set limits by hand and overcommit the machine's memory. Operating systems still need global swapping and still need to be able to do global eviction in some way. How well the two sorts of swapping cooperate with each under may vary.

PS: I don't know if non-Unix systems are also adding fine grained memory limiting, but it wouldn't surprise me. And one way to view virtual machines is that they're in part an extremely brute force way of limiting RAM (and CPU) usage.

Written on 20 March 2021.
« Remote X versus 'seamless windows' in remote desktop software
My experience with x2go is that it's okay but not compelling »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sat Mar 20 01:12:26 2021
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.