hakavlad / nohang

A sophisticated low memory handler for Linux
MIT License
1.07k stars 48 forks source link

What correct configuration to nohang work only related with zram ? #138

Open Augusto7743 opened 9 months ago

Augusto7743 commented 9 months ago

Hello. Thanks for reading my topic. Thanks hakavlad for creating nohang.

Ubuntu 20.04.6 and nohang_0.2.0-1 installed using PPA deb file. I want nohang work only using zram values and when zram is in 10 % free start closing the software using more memory avoiding system freeze. Thus the configuration are : nohang.conf zram_checking_enabled = True

and in nohang-desktop.conf zram_checking_enabled = True

The section and setting to only using zram values is the information below ?

  1. Poll rate fill_rate_zram = 4000

I want nohang working when reach zram 10 % free. The setting fill_rate_zram information is Valid values: >= 100 and default value 4000 is confusing. That valid value is percentage ?

Have an nice day.

hakavlad commented 9 months ago

Hello! Sorry for the bad documentation. I have added many options, but have not described their meaning.

Set

zram_checking_enabled = True

if the size of your ZRAM devices exceeds the total memory size (MemTotal in /proc/meminfo). You don't need zram_checking_enabled = True with small ZRAM. You need zram_checking_enabled = True only with large zram (maybe even with zram_size*2 >= MemTotal).

If you use swap only for ZRAM, then you should use soft_threshold_min_swap and hard_threshold_min_swap.

I want nohang working when reach zram 10 % free.

Use soft_threshold_min_swap and hard_threshold_min_swap. Swap on ZRAM is still swap devices.

fill_rate_zram = 4000
##  Type: float; valid values: >= 100

This is measured in MiB/s. It's not a threshold.

I want nohang work only using zram values and when zram is in 10 % free

You use the swap only on ZRAM, and you want nohang to take effect when the free swap space is less than 10%, right?

Thus the configuration are :
nohang.conf
zram_checking_enabled = True

and in
nohang-desktop.conf
zram_checking_enabled = True

Did you enable one of them (nohang.service or nohang-desktop.service), not both at the same time?

The section and setting to only using zram values

You can't use only zram values. nohang checks MemAvilable and SwapFree in any case (if swap is in use).

Augusto7743 commented 9 months ago

Thanks hakavlad for replying. You not need say excuse because your software not have much detail about information.

I have used the setting below as you has replied

zram_checking_enabled = True

Here ZRAM size is 40 % RAM

I has used the setting below in both nohang.service and nohang-desktop.service. zram_checking_enabled = True soft_threshold_min_swap 10 hard_threshold_min_swap 10

However only is active nohang-desktop.service. Not is correct use that setting in both nohang.conf and nohang-desktop.conf ?

If not is possible configure nohang for only use zram values the solution is use an low value setting for MemAvailable and SwapFree being 10 %.

Have an nice week.

hakavlad commented 9 months ago

nohang-desktop.service starts with nohang-desktop.conf

Not is correct use that setting in both nohang.conf and nohang-desktop.conf ?

nohang-desktop.conf is enough if you started only nohang-desktop.service

Augusto7743 commented 9 months ago

Thanks. I will try only using nohang-desktop.service. Have an nice day.

Augusto7743 commented 9 months ago

The setting "Poll rate" use an minimum value of 100 of each setting. If that value is MiB please in nohang next version allow use any value for example 10 MiB.

What memory area is related with "max_sleep" ?

Have an nice day.

hakavlad commented 9 months ago

What problem do you want to solve?

The setting "Poll rate" use an minimum value of 100 of each setting.

And why do you want to set lower value?

for example 10 MiB

This is a factor that influences the polling frequency. This is measured in MiB/s.

What memory area is related with "max_sleep" ?

min_sleep is not related to memory area. This is the minimum interval between checks of available memory.

Augusto7743 commented 8 months ago

Why that setting "fill_rate_zram" use value in MiB/s ?

You sad replied "You can't use only zram values. nohang checks MemAvilable and SwapFree in any case (if swap is in use)."

I have used settings for swap and zram.


Some times the OS was prone to out of memory hang with high disk read activity for several minutes before nohang had closed the bigger software. Have an wrong setting used.

RAM is 4 GB and was used zram "disksize" setting 1792 MB so is as the zram disk size will be 1792 MB ? Not. zram disksize settings means the maximum data will be compressed inside zram buffer.

Comparing in /proc/meminfo and zramctl status values about zram swap usage not are the same value.

Now in /proc/meminfo SwapTotal: 2883580 kB SwapFree: 2150652 kB Htop report swap usage being 714 MB However zramctl report swap (uncompressed data) is 714 MB and total buffer used for compressed data is 257,8M

In /proc/meminfo show swap free, but not is the correct free size of zram buffer. Thus being configuring nohang with zram 10 or 20 % not will work. The value need to be more high.

The solution is try configure to nohang work analyzing size of free memory, but is as if has another issue. Had happened an oom hang with high disk read activity, but the swap used was only 1.5 GB and not any warning about swap was done by nohang. I had used the settings below and in /proc/meminfo in MemFree was 140 MB, but even so had happened the oom hang.

zram_checking_enabled = True fill_rate_zram = 100 max_sleep = 3 soft_threshold_min_mem = 2 % soft_threshold_min_swap = 5 % soft_threshold_max_zram = 20 % hard_threshold_min_mem = 1 % hard_threshold_min_swap = 4 % hard_threshold_max_zram = 10 %

MemFree value is an mix between real memory free and cache ? If yes will be more hard configure an correct value for "soft_threshold_min_mem"

In moment is better go to configure nohang to work related with memory free and not using high value for avoid waste memory. I want working when memory free reach 1 % , but that setting work randomly or happen oom. I have disable nohang.service and only enabled nohang-desktop.service. Settings was done in /etc/nohang/nohang-desktop.conf Not are being simple configure and test.

Have an nice week.

PamAllay commented 2 weeks ago

@Augusto7743 Hi, could you share your final config? i want to do the similar configuration where OOM should occur only when ZRAM < 10% remaining. @hakavlad any help?

hakavlad commented 1 week ago

when ZRAM < 10% remaining

10% what? That's not how it works. I recommend just using the default %.

you even don't need zram_checking_enabled = True if your zram disksize is not large.

PamAllay commented 1 week ago

@hakavlad hmm, but it sometimes OOM kills programs even when there is much memory left free in zram, i use 50% of my 8gb as zram swap, i get notification of low memory - "save your documents"(or something) even when >2gb zram swap is free.