You are not logged in.

#1 2019-03-27 15:04:07

Dreezy
Member
Registered: 2016-06-21
Posts: 14

RAM swapping.

I love Bunsen labs, It is a very light distro.
But with that said today while using Android studio, on my PC 4GB RAM i5, it started swapping... I was okay with it, since it seemed okay and responsive, but later on everything froze, I could move only mouse, nothing else, I had some music playing in the background, it was just going on playing, but nothing was clickable, and no keyboard keys were recognized as input, it's like if it swapped xorg ;D

It migh be my laptop, but then I never experience such funny freezing even on ubuntu gnome...
so I am just looking for help and assistance here please.

Offline

#2 2019-03-27 15:37:30

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2015-09-29
Posts: 649

Re: RAM swapping.

Start 'htop' in terminal, and examine what is occupying the RAM.

From my experience, Android studio and java will take most of it (unless you have Chrome browser installed, then it will take some significant amount of memory). Try to kill (switch off) stuff you don't need. Change WM from OpenBox to 'smaller' one (i3wm? fluxbox? dwm?).

As for the RAM swap ... I'm not quite sure how you think it's gonna help? I mean, for example you have 4GB RAM and certain application causes that part of the RAM goes to swap ... imagine now you reserve 1 GB RAM (of your 4GB) for swap. You still have 4GB overall RAM, and 3GB normal (non-swap) memory, which means RAM-swap will be activated earlier than before. And at certain point RAM-swap will fill up, and then again it will swap to disk. It may speed things up in certain (corner?) cases, but with RAM-swap you will not gain additional RAM - you still have 4GB RAM, and that's it.


Postpone all your duties; if you die, you won't have to do them ..

Offline

#3 2019-03-27 15:42:16

Dreezy
Member
Registered: 2016-06-21
Posts: 14

Re: RAM swapping.

I keep wondering how windows is 20x heavier than any linux distro, but when swapping it's smooth, never does a mistake and swaps a display manager or critical system processes, was wondering if there is a way to mark a process never to be swapped?

Offline

#4 2019-03-27 16:07:03

earlybird
ほやほや
Registered: 2015-12-16
Posts: 727
Website

Re: RAM swapping.

Dreezy wrote:

I keep wondering how windows is 20x heavier than any linux distro, but when swapping it's smooth, never does a mistake and swaps a display manager or critical system processes, was wondering if there is a way to mark a process never to be swapped?

Windows has had superior memory management and scheduling to Linux since forever. It's commonly known that Linux memory management sucks, esp. swapping.

And the answer on recent systems with recent versions of cgroups/systemd is YES. You can specify the option MemorySwapMax=0 for a systemd unit which will impose an absolute maximum size on swap space used by that unit, in this case 0 (=disable swapping). You can run Android Studio as a so-called transient systemd unit on-the-fly using the systemd-run command:

systemd-run -p MemorySwapMax=0 COMMAND

IDK if this is available in Hydrogen's systemd version yet. If not, it'll be in BL Lithium/Debian Buster or later. Alternatively, you can set the memory.swap.max property of a cgroup the Android Studio process is in manually.

Since Android Studio is a Java application, research if it supports locking memory using mlockall as a configuration option somewhere, like ElasticSearch does (https://www.elastic.co/guide/en/elastic … emory_lock). It's a common feature in Java land.

Any process can lock itself into RAM my calling mlockall(), so to address this problem effectively either the cgroup/systemd feature is needed, or cooperation from the software.

The easiest option is to set swappiness to 0 OR disable SWAP OR to use a trick: Create an in-memory compressed block device using zram, create then enable a swap device on it. This way, Linux will use your RAM as swap space but compress pages on-the-fly. Using the LZ4 compression method, depending on the data, for such a swap RAM-Disk for any 50M of actual RAM used you may be able to squeeze 100M+ of swapped data in. Using this compressed RAM-disk swap space will be much faster than swapping to disk or even SSD.

Personally, I just swap to my SSD, on my 8G RAM laptop. When I still had a hard disk this was impossible and I disabled swap entirely, but now with a SSD, it sometimes has its hickups but that I can live with.

That being said, 4G RAM is not what present-day desktop applications written in Java are designed for. 8G are barely enough.

Offline

#5 2019-03-27 16:16:51

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2015-09-29
Posts: 649

Re: RAM swapping.

Really? You base your opinion on research, or on your own feeling?

Personally, I have experienced system hogs with MSWindows more than once, and with simple tasks ....

As for the selective marking, perhaps 'nice' and 'ionice' can help a bit, but I wouldn't bet on it. Java jdk, and in partucular java IDE on top, takes huuuuge amount of memory just to start it. Development environment may take more than 4GB, so if you really need it, I suggest buying more RAM.

My 2 cents ....

Last edited by iMBeCil (2019-03-27 16:18:16)


Postpone all your duties; if you die, you won't have to do them ..

Offline

#6 2019-03-27 19:52:45

hathor
Member
From: Barcelona
Registered: 2017-09-30
Posts: 59
Website

Re: RAM swapping.

I also remove the swap by zram, you also remove the swap writes on the SSD.


lenovo thinkpad t420s

Offline

#7 2019-03-27 21:52:49

twoion
ほやほや
Registered: 2015-08-10
Posts: 2,534

Re: RAM swapping.

iMBeCil wrote:

Really? You base your opinion on research, or on your own feeling?

There was a technical, insightful article on it on HackerNews a while (months-year) back. In particular, the issue of Linux becoming unresponsive could be reproduced reliably and at will on current Linux kernels. What happens IIRC is that RAM gets saturated and one process gets trapped between getting swapped out and getting swapped in when getting scheduled for execution by the CPU, consuming all I/O in the process causing other processes to wait for I/O in turn. Windows may be sluggish at times, but it doesn't get trapped that hard and that easily (in the swapping domain) (that's the NT kernel though – who knows what the Windows system is doing).

I'll see if I can find it.


New Horizons

Offline

#8 2019-03-27 22:06:57

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2015-09-29
Posts: 649

Re: RAM swapping.

^Hm ... please, find it. I have at home pretty good desktop computer with MSWin, with plenty of ram (16GB), and ssd, and good NVidia GFX - one could say a gamer PC for my male kid big_smile - and it often stalls for some seemingly simple actions. (I don't believe my kid was able to get so much malware ... it mainly plays regular paid steam games.)

(No, I don't play games on it ... actually avoid working on it devil )

Thanks in advance.


Postpone all your duties; if you die, you won't have to do them ..

Offline

#9 2019-03-28 07:35:23

ohnonot
...again
Registered: 2015-09-29
Posts: 4,103
Website

Re: RAM swapping.

Dreezy wrote:

I love Bunsen labs, It is a very light distro.
But with that said today while using Android studio, on my PC 4GB RAM i5, it started swapping... I was okay with it, since it seemed okay and responsive, but later on everything froze, I could move only mouse, nothing else, I had some music playing in the background, it was just going on playing, but nothing was clickable, and no keyboard keys were recognized as input, it's like if it swapped xorg ;D

It migh be my laptop, but then I never experience such funny freezing even on ubuntu gnome...
so I am just looking for help and assistance here please.

are you sure it's actually swap?
android studio is a behemoth in any case, but esp. if you compile a large project, you'll also need temporary file somewhere, and that can grow to many, many gigabytes.

if it IS swap, do you have enough of it?
it's probably possible to enlarge it temporarily with a swap file.

Offline

Board footer

Powered by FluxBB