Performance Bottlenecks and Swap
#1
So, I've run into what I consider a concerning amount of CPU hogging due to kswap and running out of physical RAM/loading up the swap in the default Ubuntu MATE install.

2 gigs + 1 gig swap is a bit light to multitask anything in a GUI, especially if one of those tasks is Chromium.

So...

Anyone done anything to mitigate this?

It doesn't appear to be too terribly easy to fix this stuff live, which is not shocking as the default root fs is the one I would need to shrink.

I'm leaning toward grabbing a low-profile USB flash drive and using it as a lower priority swap than the default zram (which seems pretty zippy as it is supposed to be but is too small IMO for many things), but if anyone has a simple or elegant solution, I might try it.

Anyone try to use resize2fs from an SD card? Anyone try that+swap on the eMMC vs a USB drive and compared performance?
------
it doesn't get happy
it doesn't get sad
it just runs programs
#2
(06-30-2017, 02:04 AM)zer0sig Wrote: So, I've run into what I consider a concerning amount of CPU hogging due to kswap and running out of physical RAM/loading up the swap in the default Ubuntu MATE install.

2 gigs + 1 gig swap is a bit light to multitask anything in a GUI, especially if one of those tasks is Chromium.

So...

Anyone done anything to mitigate this?

It doesn't appear to be too terribly easy to fix this stuff live, which is not shocking as the default root fs is the one I would need to shrink.

I'm leaning toward grabbing a low-profile USB flash drive and using it as a lower priority swap than the default zram (which seems pretty zippy as it is supposed to be but is too small IMO for many things), but if anyone has a simple or elegant solution, I might try it.

Anyone try to use resize2fs from an SD card? Anyone try that+swap on the eMMC vs a USB drive and compared performance?

You are correct - I noticed it too. Also, performance in the desktop tanks after using Chromium. Hmmm...
You can find me on IRC, Discord and Twitter


#3
Well, Chrome/Chromium is known to be rather RAM-hungry, but I rarely see similar slowdowns on my chromebook, which has less CPU and the same amount of RAM. tweaking vm.swappiness in /etc/sysctl.conf might help but to be honest, with a 3GB total memory footprint I just don't see it.

There's a page over at Ask Ubuntu about the matter - https://askubuntu.com/questions/259739/k...lot-of-cpu

And while it may well help to
Code:
cat 1 > /proc/sys/vm/drop_caches
as suggested, I think the cron script shown is probably not the right solution on the Pinebook for the following reasons:
1> performance tanks and kswapd0 bogs down the system without getting anywhere near 90+% CPU and
2> aside from having to start a new process every minute, the script shown has to launch at least one or two more.

I would lean toward a very light daemon written in bourne/bash that compares the most recent run queue, as such:

Code:
awk '{print $1}' /proc/loadavg


against some minimum number that definitely indicates that the machine is struggling (probably 4 is a good number as there are 4 CPU cores and when kswapd0 is hogging CPU that number seems to easily spike above 10 despite seemingly modest CPU usage - however, you could adjust the aggressiveness of the script by lowering or raising this number) and if the awk-derived number is greater than it, then use that drop_caches command. Keep it resident and put it in a while loop with a sleep statement and I would think it would be more responsive and definitely more effective on our machines.
Still, I think such a script would have limited effectiveness if you are using RAM-heavy apps like Chromium. I will probably order a small USB thumb drive like the sandisk or samsung fit models, write a small script to be called from /etc/rc.local that fires up the swap on said drive only when connected and places it at a lower priority than the better optimized zram swap. make it 4 gigs or so and I'm pretty sure things will run better.
------
it doesn't get happy
it doesn't get sad
it just runs programs
#4
I've also noticed a severe performance drop when I launch Chromium. I purchased the larger 32GB eMMC but have not yet installed it. Could this help with the performance?
#5
I'd say it's unlikely as the limits we are running into are related to virtual memory, rather than storage.
------
it doesn't get happy
it doesn't get sad
it just runs programs
#6
So this is what happens after approx 15 min of using Chromium; doesnt happen when i use Firefox. edit: in case I didn't make it clear, look at swap. 

[Image: JBPkw4c.png]
You can find me on IRC, Discord and Twitter


#7
New thumbdrive came in today! 64GB and no bigger than the little wireless attachment for my mouse. Will attach pics so you can see the size and then show you what the configuration looks like live (can provide some instructions for step-by-step but I suspect that most folks really interested in this may need only minimal guidance at most.

       

So i installed the drive, and as usual it was formatted for Windows. I actually don't mind this for now as I'm just putting backups on it and can use it to more easily transfer certain files back and forth from a win host (and Linux has no trouble with the Win FAT32 (LBA) filesystem), but I deleted it and set a new one up of 53GB size (total disk was 59.8 using full binary gigs) and the rest in swap.

added this line in fstab so it will only try to mount if Linux sees it and runs at a lower priority than the zram swap volumes:


Code:
/dev/sda2   swap   swap   sw,nofail,pri=1 0 0

Now, /proc/swaps shows this:

Code:
root@pinebook:~# cat /proc/swaps
Filename                Type        Size    Used    Priority
/dev/zram0                              partition    254540    0    5
/dev/zram1                              partition    254540    0    5
/dev/zram2                              partition    254540    0    5
/dev/zram3                              partition    254540    0    5
/dev/sda2                               partition    7093244    0    1

and in top it shows a total of just over 8 gigs swap. Will fiddle around and see what happens when virtual memory is pushed past 3GB - I would expect some slowing but probably not nearly as bad.
------
it doesn't get happy
it doesn't get sad
it just runs programs
#8
So, FYI, using about 3.5G of memory space right now and while it's a bit slower, the machine is still quite usable, kswapd0 is not hogging CPU, loadavg is not super high and this is a dramatic difference from what happened previously once the 3G mark was met.

Here's a paste from top:

Code:
top - 18:32:26 up 23:21,  2 users,  load average: 1.68, 1.83, 1.78
Tasks: 188 total,   2 running, 186 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.1 us,  1.8 sy,  0.0 ni, 89.4 id,  0.7 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem :  2036344 total,    44104 free,  1786848 used,   205392 buff/cache
KiB Swap:  8111404 total,  6519720 free,  1591684 used.   150457 avail Mem

This is a major improvement over the 10+ loadavg spikes I was seeing when the VM ran p to 3G before adding swap.
------
it doesn't get happy
it doesn't get sad
it just runs programs
#9
(07-07-2017, 04:37 PM)zer0sig Wrote: Here's a paste from top:

Code:
top - 18:32:26 up 23:21,  2 users,  load average: 1.68, 1.83, 1.78
Tasks: 188 total,   2 running, 186 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.1 us,  1.8 sy,  0.0 ni, 89.4 id,  0.7 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem :  2036344 total,    44104 free,  1786848 used,   205392 buff/cache
KiB Swap:  8111404 total,  6519720 free,  1591684 used.   150457 avail Mem
Ubuntu Mate does use many Ressources - also like Chromium....
So I installed Q4OS v1806
I like it very much because it is so light in using Memory. When I had Chromium open there are 1.3GB cached memory "availabe" and Chromium or Firefox is real useable:

Code:
top - 13:32:41 up  3:19,  2 users,  load average: 1,50, 1,01, 1,08
Tasks: 203 total,   3 running, 182 sleeping,   0 stopped,  18 zombie
%Cpu(s): 22,7 us,  7,2 sy,  0,0 ni, 69,9 id,  0,1 wa,  0,0 hi,  0,2 si,  0,0 st
KiB Mem:   2037388 total,  1953212 used,    84176 free,    35604 buffers
KiB Swap:        0 total,        0 used,        0 free.  1315240 cached Mem
And - I think - this is a good result without additional SWAP-Memory :-)

Only Video-playing with VLC works only with the slow X11 Video-driver and not VDPAU like in the SM Player in Ubuntu
#10
You can set VLC to use VDPAU in settings.
You can find me on IRC, Discord and Twitter




Forum Jump:


Users browsing this thread: 1 Guest(s)