Page 1 of 1

Systen gets very slow / IO wait time

Posted: 07 Dec 2013, 01:00
by Rava
My issue, on my single core non 64 bit Samsung Q40 sup notebook...

After a while, after days of suspend and working and suspend, and firing it up again, the system gets slower and slower, up to the point it seems not to react at all.
First it helps to just kill all Firefox'es, but later I need to kill and re-start X to get back it's initial performance. O__o


All I could figure out is, that it must be some IO issue. The 3rd line when running top, the one starting with Cpu(s), lists about 70 to 90% of wa, I googeled that, and it means the waiting time for IO is too long, one discussion thread meant that the system resources are to much used, and therefore the IO wait time got from, like factor 2 (when 50% of system resources are used), to 50 and up to 100... (when 95% are used)
It was about a server in that thread, and on that machine I not even run Thunderbird any more on that machine, cause it has a too weak CPU and not enough RAM for FFx and Thunderbird...

How can I figure out which process might be the one doing it?

Re: Systen gets very slow / IO wait time

Posted: 07 Dec 2013, 03:38
by fanthom
@Rava
please post the screenshot from 'top' showing all processes.
also - install 'iotop' (need python) and check if you can get something useful from it.

Re: Systen gets very slow / IO wait time

Posted: 07 Dec 2013, 15:47
by cttan
Hi Rava,

I do a lot of sleep and wake as well using my laptop.

I keep the system going by clearing the memory. I did swapoff and swapon.
Some program will tend to have memory leaks. I observed that Qbittorrent is one such program.
Just delete the downloaded files and do a swapoff and swapoff and you are OK.

If the system still felt slow, I will do a telinit 3 && telinit 4 from the terminal if you still can reach your script or terminal.
If system freeze use Ctrl-Alt-Bksp and re-login to X again.

Re: Systen gets very slow / IO wait time

Posted: 07 Dec 2013, 21:07
by fanthom
@cttan
good point. i would also add 'echo 3 > /proc/sys/vm/drop_caches' command to a script which runs before laptop goes sleep or wakes up (which ever works better). more info at Arch wiki:
https://wiki.archlinux.org/index.php/Pm ... _own_hooks

Re: Systen gets very slow / IO wait time

Posted: 08 Dec 2013, 05:25
by Rava
fanthom wrote:@cttan
good point. i would also add 'echo 3 > /proc/sys/vm/drop_caches' command to a script which runs before laptop goes sleep or wakes up (which ever works better)
Where do I place such a script?
cttan wrote:I keep the system going by clearing the memory. I did swapoff and swapoff.
This I will put in the same script. :)

Re: Systen gets very slow / IO wait time

Posted: 09 Dec 2013, 03:12
by cttan
Thanks fanthom. Great suggestion. Has been looking for such command that clears up the cache.

@Rava, typo error. Correction made. Should be swapoff and then swapon.

Re: Systen gets very slow / IO wait time

Posted: 09 Dec 2013, 05:42
by Rava
Thanks for the correction, cttan.

Do you know where to put such a script for suspend?

Re: Systen gets very slow / IO wait time

Posted: 09 Dec 2013, 07:04
by cttan
You run the command whenever your system feel sluggish.

Here is a one liner with fanthom suggestion as well:-
free && swapoff -a && swapon /mnt/<your swap drive>/<your swap file> && swapon -p 100 /dev/zram0 && echo 3 > /proc/sys/vm/drop_caches && free

Swap on the zram should be quite standard on x64 but maybe you need to adjust the size.

Re: Systen gets very slow / IO wait time

Posted: 09 Dec 2013, 21:35
by fanthom
Do you know where to put such a script for suspend?
see Arch wiki link i posted above and let us know if it worked for you (never tried myself).

Re: Systen gets very slow / IO wait time

Posted: 13 Dec 2013, 15:13
by Rava
cttan wrote:Swap on the zram should be quite standard on x64 but maybe you need to adjust the size.
How to calculate the size? Is there a rule of thumb? Like, 33% of physical RAM or such?
fanthom wrote:see Arch wiki link i posted above and let us know if it worked for you (never tried myself).
I sure will!

Re: Systen gets very slow / IO wait time

Posted: 14 Dec 2013, 14:41
by cttan
Hi Rava,

I am not sure of any rule around. Try to tweak your system to your liking.

I have 4GB RAM and I use copy2ram option. I am using ramsize=75% zram=25%

Re: Systen gets very slow / IO wait time

Posted: 15 Dec 2013, 15:32
by Rava
I created this script:

Code: Select all

#!/bin/bash
# info and swap clearing script for hibernate / suspend 
# put this file into  /etc/pm/sleep.d/
# by Rava, V0.0
# sources:	https://wiki.archlinux.org/index.php/Pm-utils#Creating_your_own_hooks
# other:	cttan / fanthom: http://forum.porteus.org/viewtopic.php?f=117&t=2895&p=20208#p20075
SWAPFILE=/mnt/sda1/.MYLINUXSWAPFILE
case $1 in
    hibernate)
		free && swapoff -a && swapon $SWAPFILE && swapon -p 100 /dev/zram0 && echo 3 > /proc/sys/vm/drop_caches && free
        echo "/etc/pm/sleep.d/77_pm-hibernate.suspend : Going to suspend to disk!"
    ;;
    suspend)
		free && swapoff -a && swapon $SWAPFILE && swapon -p 100 /dev/zram0 && echo 3 > /proc/sys/vm/drop_caches && free
        echo "/etc/pm/sleep.d/77_pm-hibernate.suspend : Going to suspend to RAM!"
    ;;
    thaw)
        echo "/etc/pm/sleep.d/77_pm-hibernate.suspend : Suspend to disk is over, we are resuming..."
    ;;
    resume)
        echo "/etc/pm/sleep.d/77_pm-hibernate.suspend : Suspend to RAM is over, we are resuming..."
    ;;
    *)  echo "/etc/pm/sleep.d/77_pm-hibernate.suspend : A script or user is calling me totally wrong. The given parameter was: $1"
    ;;
esac
but, unlike what it says on the wiki page, I don't find any info if it is really run when going into suspend or hibernate...

I called it 77_pm-hibernate.suspend ... I am free to name it how I like, yes?
And it's rwx for root...

How to check if it's really run? Do I need to tweak another linux system file to actually run my script on suspend/hibernate/wakeup? O___o

Re: Systen gets very slow / IO wait time

Posted: 17 Dec 2013, 05:32
by Rava
Update

I did a minor change to the script, changing the 'echo "' parts into 'logger "':

Code: Select all

#!/bin/bash
# info and swap clearing script for hibernate / suspend 
# put this file into  /etc/pm/sleep.d/
# by Rava, V0.1
# sources:	https://wiki.archlinux.org/index.php/Pm-utils#Creating_your_own_hooks
# other:	cttan / fanthom: http://forum.porteus.org/viewtopic.php?f=117&t=2895&p=20208#p20075
SWAPFILE=/mnt/sda1/.MYLINUXSWAPFILE
case $1 in
    hibernate)
		free && swapoff -a && swapon $SWAPFILE && swapon -p 100 /dev/zram0 && echo 3 > /proc/sys/vm/drop_caches && free
        logger "/etc/pm/sleep.d/77_pm-hibernate.suspend : Going to suspend to disk!"
    ;;
    suspend)
		free && swapoff -a && swapon $SWAPFILE && swapon -p 100 /dev/zram0 && echo 3 > /proc/sys/vm/drop_caches && free
        logger "/etc/pm/sleep.d/77_pm-hibernate.suspend : Going to suspend to RAM!"
    ;;
    thaw)
        logger "/etc/pm/sleep.d/77_pm-hibernate.suspend : Suspend to disk is over, we are resuming..."
    ;;
    resume)
        logger "/etc/pm/sleep.d/77_pm-hibernate.suspend : Suspend to RAM is over, we are resuming..."
    ;;
    *)  logger "/etc/pm/sleep.d/77_pm-hibernate.suspend : A script or user is calling me totally wrong. The given parameter was: $1"
    ;;
esac
It logs just OK, so I presume it did it's on liner as well, as seen by the log info about the swap space:

Code: Select all

Dec 16 07:09:25 porteus -- MARK --
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> sleep requested (sleeping:
no  enabled: yes)
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> sleeping or disabling...
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> (eth0): device state change: activated -> unmanaged (reason 'sleeping') [100 10 37]
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> (eth0): deactivating device (reason 'sleeping') [37]
Dec 16 07:20:04 porteus dhcpcd[20357]: received SIGTERM, stopping
Dec 16 07:20:04 porteus dhcpcd[20357]: eth0: removing interface
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> (eth0): canceled DHCP transaction, DHCP client pid 20357
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> (eth0): cleaning up...
Dec 16 07:20:04 porteus NetworkManager[1742]: <info> (eth0): taking down device.Dec 16 07:20:04 porteus dbus[1238]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
Dec 16 07:20:04 porteus dbus[1238]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 16 07:20:13 porteus kernel: [37867.006879] Adding 740308k swap on /mnt/sda1/.MYLINUXSWAPFILE.  Priority:-1 extents:2 across:745824k
Dec 16 07:20:13 porteus kernel: [37867.009077] Adding 617524k swap on /dev/zram0.  Priority:100 extents:1 across:617524k SS
Dec 16 07:20:13 porteus logger: /etc/pm/sleep.d/77_pm-hibernate.suspend : Going to suspend to RAM!
and when reuming, it also logs just OK:

Code: Select all

Dec 17 05:12:18 porteus logger: /etc/pm/sleep.d/77_pm-hibernate.suspend : Suspend to RAM is over, we are resuming...
So, seems all is well now, my script works, thanks to you cttan & fanthom, and thanks for the ones who wrote the wiki article...

It now takes a little while longer to shut down for suspend to RAM, but not annoyingly so...