1 |
Mick wrote: |
2 |
> On Sunday, 20 October 2019 16:03:42 BST Dale wrote: |
3 |
>> Here's the |
4 |
>> thing about using swap on my rig, once it does, the system gets |
5 |
>> extremely slow. Even switching desktops can take a minute or longer. |
6 |
>> Other than trying to get to what is eating up memory and killing it, the |
7 |
>> system is virtually useless. Even my video stops playing. |
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 |
|
50 |
What you describe in your first scenario, that is when it is so slow and |
51 |
virtually unresponsive. I don't generally run out of memory when |
52 |
compiling since I close other stuff, like Firefox, to free up memory, |
53 |
even in the 16GB days. What I run into is a tab, or tabs, in Firefox |
54 |
that are chewing through memory like a hungry junk yard dog on a crook. |
55 |
When Firefox does that, it is slow, extremely slow. When I get to where |
56 |
I can see what is going on, it is still slow to even close or kill that |
57 |
process. If I get to a Konsole, I usually run htop and kill it from |
58 |
there. Thing is, it may take a minute even for htop to start and show |
59 |
the problem. That's a fairly small program but it can take a minute or |
60 |
two to even load and show its screen. |
61 |
|
62 |
I have two sites in particular that does this. They run for days with |
63 |
no problem and I may not even be using that tab or that site. Then it's |
64 |
like it gets mad and starts using more and more memory. I have caught |
65 |
it in time to just refresh the tab and it go back to normal. Once it |
66 |
starts using swap tho, it's very slow. |
67 |
|
68 |
I wish Firefox had a way to fix that out of control memory usage. It |
69 |
may not be Firefox itself doing it but it would seem it can see |
70 |
something isn't right and put a stop to it. It's sad when a Linux |
71 |
desktop has 32GBs of memory eat up like that, usually by one program at |
72 |
that. |
73 |
|
74 |
Still, no swap at all would result in a crash or reset. It's better |
75 |
than nothing but I wish the root cause could be fixed. |
76 |
|
77 |
Dale |
78 |
|
79 |
:-) :-) |