Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Memory manager
Date: Sun, 20 Oct 2019 17:03:11
Message-Id: 3298809.Q0gCBeysPu@localhost
In Reply to: Re: [gentoo-user] Memory manager by Dale
1 On Sunday, 20 October 2019 16:03:42 BST Dale wrote:
2 > Here's the
3 > thing about using swap on my rig, once it does, the system gets
4 > extremely slow. Even switching desktops can take a minute or longer.
5 > Other than trying to get to what is eating up memory and killing it, the
6 > system is virtually useless. Even my video stops playing.
7
8 Swapping can bring the system to its knees, but only under certain operating
9 scenarios. This is how I understand it works:
10
11 Say you're browsing and keep opening tabs. The browser application will
12 preemptively allocate memory for more tabs, in case you carry on opening even
13 more tabs. Then you open yet another big application in terms of memory usage
14 and start running it. The kernel will reallocate some of the browser memory
15 not currently utilised to the other application and keep things working
16 smoothly. With more applications/tabs being opened you will eventually run
17 out of RAM and the kernel will swap some of the memory pages to disk. The
18 swapping is meant to be selective, i.e. things you haven't used in a while
19 will be taken out of RAM and saved onto your disk.
20
21 Under the above scenario you may notice a momentary latency on your desktop as
22 data is swapped onto the disk, but afterwards the desktop should be responsive
23 once more - unless more swapping is again demanded by your actions. If you
24 try to access an application which has had parts of its memory allocation
25 swapped out to disk you will notice a delay in its reactions.
26
27 Now, in a gentoo scenario, say a mammoth compile like Chromium, with a large
28 count of jobs specified for it, you could end up swapping part or all of one
29 or more jobs into memory, only to swap it out again in order to process it.
30 The compile keeps swapping in and out a job at a time in order to carry on
31 compiling. The disk thrashing is now continuous and indeed interacting with
32 your desktop will be painful - potentially waiting for minutes at a time
33 before an application responds. The way out of this bottleneck is to either
34 increase your RAM, or minimise the use of memory by reducing the job count in
35 MAKEOPTS. Shutting down desktop applications and login out of any desktop
36 sessions to release RAM will also help.
37
38 On a laptop with 4G RAM compiling Chromium is quite challenging when even a
39 single gcc job could grow to 3G or more. Swapping and a disk I/O bottleneck
40 becomes unavoidable and moving the compile of binaries to a bigger PC becomes
41 a rather wise solution.
42
43 Another occasion when swapping can cause havoc is when you have a memory leak
44 due to some buggy application and all your RAM followed by swap is chewed up
45 until an OOM ensues.
46
47 For these reasons I always set up swap on my gentoo systems.
48 --
49 Regards,
50
51 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Memory manager Dale <rdalek1967@×××××.com>
Re: [gentoo-user] Memory manager Neil Bothwick <neil@××××××××××.uk>