diff --git a/nohang b/nohang index 1e71b4a..4c0e90c 100755 --- a/nohang +++ b/nohang @@ -27,7 +27,7 @@ else: wait_time = 14 max_sleep_time = 1 -min_sleep_time = 0.05 +min_sleep_time = 0.02 notify_helper_path = '/usr/bin/nohang_notify_helper' @@ -38,8 +38,10 @@ debug = False stop_cont = True +print_states_debug = False -SC_CLK_TCK = os.sysconf(os.sysconf_names['SC_CLK_TCK']) + +# SC_CLK_TCK = os.sysconf(os.sysconf_names['SC_CLK_TCK']) ########################################################################## @@ -488,27 +490,28 @@ def cont(stopped_list): def print_states(): - print() - t1 = time() - print('non-S states:') - for pid in os.listdir('/proc'): - # only directories whose names consist only of numbers, except /proc/1/ - if pid[0].isdecimal() is False or pid is '1' or pid == self_pid: - continue - try: - s = pid_to_state(pid) - if s == 'S': + if print_states_debug: + print() + t1 = time() + print('non-S states:') + for pid in os.listdir('/proc'): + # only directories whose names consist only of numbers, except /proc/1/ + if pid[0].isdecimal() is False or pid is '1' or pid == self_pid: continue - else: - print('State: {}, [{}], {}, {}...'.format( - s, pid, pid_to_name(pid), pid_to_cmdline(pid)[:40])) - except FileNotFoundError: - continue - except ProcessLookupError: - continue - t2 = time() - print('print state time:', t2 - t1) - print() + try: + s = pid_to_state(pid) + if s == 'S': + continue + else: + print('State: {}, [{}], {}, {}...'.format( + s, pid, pid_to_name(pid), pid_to_cmdline(pid)[:40])) + except FileNotFoundError: + continue + except ProcessLookupError: + continue + t2 = time() + print('print state time:', t2 - t1) + print() diff --git a/nohang.conf b/nohang.conf index 0a9c651..0ecdf87 100644 --- a/nohang.conf +++ b/nohang.conf @@ -42,13 +42,13 @@ MemAvailable levels. -mem_min_sigterm = 10% -mem_min_sigkill = 5% +mem_min_sigterm = 200M +mem_min_sigkill = 100M SwapFree levels. -swap_min_sigterm = 10% -swap_min_sigkill = 5% +swap_min_sigterm = 200M +swap_min_sigkill = 100M Specifying the total share of zram in memory, if exceeded the corresponding signals are sent. As the share of zram in memory @@ -118,7 +118,7 @@ min_badness = 30 Valid values are non-negative floating-point numbers. min_delay_after_sigterm = 0.2 -min_delay_after_sigkill = 0.8 +min_delay_after_sigkill = 1 Процессы браузера chromium обычно имеют oom_score_adj 200 или 300. Это приводит к тому, что процессы хрома умирают @@ -132,7 +132,7 @@ min_delay_after_sigkill = 0.8 Valid values are True and False. Values are case sensitive. -decrease_oom_score_adj = False +decrease_oom_score_adj = True Valid values are integers from the range [0; 1000]. @@ -160,7 +160,7 @@ oom_score_adj_max = 30 Valid values are True and False. -regex_matching = False +regex_matching = True Syntax: @@ -184,7 +184,7 @@ regex_matching = False A good option that allows fine adjustment. -re_match_cmdline = False +re_match_cmdline = True @CMDLINE_RE 300 /// -childID|--type=renderer @@ -195,7 +195,7 @@ re_match_cmdline = False The most slow option -re_match_uid = False +re_match_uid = True @UID_RE -100 /// ^0$ @@ -215,7 +215,7 @@ re_match_uid = False Valid values are True and False. -execute_the_command = False +execute_the_command = True The length of the process name can't exceed 15 characters. The syntax is as follows: lines starting with keyword $ETC are @@ -258,7 +258,7 @@ $ETC firefox-esr /// kill -SEGV $PID See also wiki.archlinux.org/index.php/Desktop_notifications Valid values are True and False. -gui_notifications = False +gui_notifications = True Enable GUI notifications about the low level of available memory. Valid values are True and False. @@ -268,7 +268,7 @@ gui_low_memory_warnings = False Минимальное время между отправками уведомлений в секундах. Valid values are floating-point numbers from the range [1; 300]. -min_time_between_warnings = 10 +min_time_between_warnings = 15 Если значения MemAvailable и SwapFree одновременно будут ниже соотвестствующих значений, то будут отправлены уведомления. @@ -301,7 +301,7 @@ print_config = False Print memory check results. Valid values are True and False. -print_mem_check_results = True +print_mem_check_results = False Print sleep periods between memory checks. Valid values are True and False. diff --git a/nohang.service b/nohang.service index 2897f1f..0a59b8d 100644 --- a/nohang.service +++ b/nohang.service @@ -5,19 +5,18 @@ Documentation=man:nohang(1) https://github.com/hakavlad/nohang [Service] ExecStart=/usr/sbin/nohang +Slice=nohang.slice Restart=always -RestartSec=1 -IOSchedulingClass=1 -IOSchedulingPriority=0 -Nice=-20 -CPUSchedulingPolicy=rr -CPUSchedulingPriority=99 -CPUSchedulingResetOnFork=true ProtectSystem=strict MemoryMax=100M TasksMax=100 -OOMScoreAdjust=-20 -Slice=nohang.slice +OOMScoreAdjust=-10 +Nice=-20 +IOSchedulingClass=1 +IOSchedulingPriority=0 +CPUSchedulingPolicy=fifo +CPUSchedulingPriority=99 +CPUSchedulingResetOnFork=true [Install] WantedBy=multi-user.target