From d4b89e27e9b8b99cbb214cbb1b42e6a49898f669 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Sat, 21 Jul 2018 18:53:59 +0900 Subject: [PATCH] update readme --- README.md | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index eb46847..311ab66 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ OOM killer doesn't prevent OOM conditions. And OOM conditions may cause [freezes](https://en.wikipedia.org/wiki/Hang_(computing)), [livelocks](https://en.wikipedia.org/wiki/Deadlock#Livelock), loss disk cache and killing multiple processes. -Here are the words of some users: +Here are the statements of some users: > "How do I prevent Linux from freezing when out of memory? Today I (accidentally) ran some program on my Linux box that quickly used a lot of memory. My system froze, became unresponsive and thus I was unable to kill the offender. @@ -15,7 +15,6 @@ How can I prevent this in the future? Can't it at least keep a responsive core o ([serverfault](https://serverfault.com/questions/390623/how-do-i-prevent-linux-from-freezing-when-out-of-memory)) - > "With or without swap it still freezes before the OOM killer gets run automatically. This is really a kernel bug that should be fixed (i.e. run OOM killer earlier, before dropping all disk cache). Unfortunately kernel developers and a lot of other folk fail to see the problem. Common suggestions such as disable/enable swap, buy more RAM, run less processes, set limits etc. do not address the underlying problem that the kernel's low memory handling sucks camel's balls." ([serverfault](https://serverfault.com/questions/390623/how-do-i-prevent-linux-from-freezing-when-out-of-memory#comment417508_390625)) @@ -23,7 +22,7 @@ How can I prevent this in the future? Can't it at least keep a responsive core o Also look at [Why are low memory conditions handled so badly?](https://www.reddit.com/r/linux/comments/56r4xj/why_are_low_memory_conditions_handled_so_badly/) (discussion with 480+ posts on r/linux). -## Solutions +## Solution - Use of [earlyoom](https://github.com/rfjakob/earlyoom). This is a simple and lightweight OOM preventer written in C. - Use of [oomd](https://github.com/facebookincubator/oomd). This is a userspace OOM killer for linux systems whitten in C++ and developed by Facebook. @@ -44,36 +43,6 @@ Also look at [Why are low memory conditions handled so badly?](https://www.reddi [Video](https://youtu.be/DefJBaKD7C8): nohang prevents OOM after the command `while true; do tail /dev/zero; done` has been executed. - -### An example of output -...if command `while true; do stress -m 9 --vm-bytes 3G; done` has been executed with `rate_mem` = 9: -``` -MemAvail: 2515 M, 42.8 % -MemAvail: 1510 M, 25.7 % -MemAvail: 909 M, 15.5 % -MemAvail: 520 M, 8.9 % -* MemAvailable (520 MiB, 8.9 %) < mem_min_sigterm (529 MiB, 9.0 %) - SwapFree (0 MiB, 0.0 %) < swap_min_sigterm (0 MiB, - %) - Preventing OOM: trying to send the SIGTERM signal to stress, - Pid: 9828, Badness: 82, VmRSS: 485 MiB, VmSwap: 0 MiB - Success; reaction time: 11 ms -MemAvail: 4114 M, 70.0 % -MemAvail: 2532 M, 43.1 % -MemAvail: 1495 M, 25.4 % -MemAvail: 927 M, 15.8 % -MemAvail: 553 M, 9.4 % -MemAvail: 342 M, 5.8 % -* MemAvailable (342 MiB, 5.8 %) < mem_min_sigkill (353 MiB, 6.0 %) - SwapFree (0 MiB, 0.0 %) < swap_min_sigkill (0 MiB, - %) - Preventing OOM: trying to send the SIGKILL signal to stress, - Pid: 9841, Badness: 87, VmRSS: 513 MiB, VmSwap: 0 MiB - Success; reaction time: 11 ms -MemAvail: 4084 M, 69.5 % -MemAvail: 2543 M, 43.3 % -MemAvail: 1535 M, 26.1 % -``` -And demo: https://youtu.be/5d6UovJzK8k - ## Requirements - `Linux 3.14+` (because the MemAvailable parameter appeared in /proc/meminfo since kernel version 3.14) and `Python 3.4+` (compatibility with earlier versions was not tested) for basic usage