[PATCH] gnu: Add earlyoom.

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Maxim Cournoyer
  • Pkill -9
Owner
unassigned
Submitted by
Pkill -9
Severity
normal

Debbugs page

Pkill -9 wrote 5 years ago
(address . bug-guix@gnu.org)(name . Pkill -9)(address . pkill9@runbox.com)
20200125212320.12134-1-pkill9@runbox.com
* gnu/packages/linux.scm (earlyoom): New variable.
---
gnu/packages/linux.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

Toggle diff (47 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index e5cc773ecc..892906cc70 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -6215,3 +6215,40 @@ the Linux kernel, C standard library, and libdl (for dynamic linking). While
ELL is designed to be efficient and compact enough for use on embedded Linux
platforms, it is not limited to resource-constrained systems.")
(license license:lgpl2.1+)))
+
+(define-public earlyoom
+ (package
+ (name "earlyoom")
+ (version "1.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/rfjakob/earlyoom.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0fwbx0y80nqgkxrc9kf9j3iwa0wbps2jmqir3pgqbc2cj0wjh0lr"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:make-flags `("CC=gcc"
+ ,(string-append "DESTDIR="
+ (assoc-ref %outputs "out"))
+ "PREFIX=")
+ #:tests? #f ;; no tests
+ #:phases (modify-phases
+ %standard-phases
+ (delete 'configure)
+ (add-after 'install 'remove-systemd-service
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (delete-file-recursively
+ (string-append out "/etc/systemd")))
+ #t)))))
+ (home-page "https://github.com/rfjakob/earlyoom")
+ (synopsis "Automatically kill processes in low-memory situations")
+ (description "Earlyoom checks the amount of available memory and free swap
+up to 10 times a second (less often if there is a lot of free memory). By
+default if both are below 10%, it will kill the largest process (highest
+oom_score). The percentage value is configurable via command line arguments.")
+ (license license:expat)))
--
2.25.0
Ludovic Courtès wrote 5 years ago
control message for bug #39283
(address . control@debbugs.gnu.org)
87sgk0fv85.fsf@gnu.org
reassign 39283 guix-patches
quit
Maxim Cournoyer wrote 5 years ago
Re: bug#39283: [PATCH] gnu: Add earlyoom.
(name . Pkill -9)(address . pkill9@runbox.com)(address . 39283@debbugs.gnu.org)
87a764rryn.fsf@gmail.com
Hello Pkill -9,

Pkill -9 <pkill9@runbox.com> writes:

Toggle quote (52 lines)
> * gnu/packages/linux.scm (earlyoom): New variable.
> ---
> gnu/packages/linux.scm | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> index e5cc773ecc..892906cc70 100644
> --- a/gnu/packages/linux.scm
> +++ b/gnu/packages/linux.scm
> @@ -6215,3 +6215,40 @@ the Linux kernel, C standard library, and libdl (for dynamic linking). While
> ELL is designed to be efficient and compact enough for use on embedded Linux
> platforms, it is not limited to resource-constrained systems.")
> (license license:lgpl2.1+)))
> +
> +(define-public earlyoom
> + (package
> + (name "earlyoom")
> + (version "1.3")
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/rfjakob/earlyoom.git")
> + (commit (string-append "v" version))))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "0fwbx0y80nqgkxrc9kf9j3iwa0wbps2jmqir3pgqbc2cj0wjh0lr"))))
> + (build-system gnu-build-system)
> + (arguments
> + `(#:make-flags `("CC=gcc"
> + ,(string-append "DESTDIR="
> + (assoc-ref %outputs "out"))
> + "PREFIX=")
> + #:tests? #f ;; no tests
> + #:phases (modify-phases
> + %standard-phases
> + (delete 'configure)
> + (add-after 'install 'remove-systemd-service
> + (lambda* (#:key outputs #:allow-other-keys)
> + (let ((out (assoc-ref outputs "out")))
> + (delete-file-recursively
> + (string-append out "/etc/systemd")))
> + #t)))))
> + (home-page "https://github.com/rfjakob/earlyoom")
> + (synopsis "Automatically kill processes in low-memory situations")
> + (description "Earlyoom checks the amount of available memory and free swap
> +up to 10 times a second (less often if there is a lot of free memory). By
> +default if both are below 10%, it will kill the largest process (highest
> +oom_score). The percentage value is configurable via command line arguments.")
> + (license license:expat)))


I happened to have prepared earlyoom recently, but delayed its inclusion
due to finishing a service for it (only the doc remains).

I'm attaching it. My version seems slightly more complete (I generate
the doc and run the tests). If you don't have an objection I could push
it to master.
From 3692937bb2eb0659493dfb59c43a83b2ae094214 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Sun, 5 Jan 2020 00:44:48 -0500
Subject: [PATCH 1/2] gnu: Add earlyoom.

* gnu/packages/linux.scm (earlyoom): New variable.
---
gnu/packages/linux.scm | 47 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)

Toggle diff (74 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index cc3455b52b..7b0241ff4b 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -33,7 +33,7 @@
;;; Copyright © 2018 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2018 Vasile Dumitrascu <va511e@yahoo.com>
;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
-;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2019, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Stefan Stefanović <stefanx2ovic@gmail.com>
;;; Copyright © 2019 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2019 Brice Waegeneire <brice@waegenei.re>
@@ -86,6 +86,7 @@
#:use-module (gnu packages gperf)
#:use-module (gnu packages gstreamer)
#:use-module (gnu packages gtk)
+ #:use-module (gnu packages haskell-xyz)
#:use-module (gnu packages libunwind)
#:use-module (gnu packages libusb)
#:use-module (gnu packages man)
@@ -2640,6 +2641,50 @@ kmod. The aim is to be compatible with tools, configurations and indices
from the module-init-tools project.")
(license license:gpl2+))) ; library under lgpl2.1+
+(define-public earlyoom
+ (package
+ (name "earlyoom")
+ (version "1.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/rfjakob/earlyoom.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0fwbx0y80nqgkxrc9kf9j3iwa0wbps2jmqir3pgqbc2cj0wjh0lr"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases (modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'check 'set-home
+ (lambda _
+ (setenv "HOME" (getcwd))
+ #t))
+ (add-after 'build 'install-contribs
+ ;; Install what seems useful from the contrib directory.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (contrib (string-append
+ out "/share/earlyoom/contrib")))
+ (install-file "contrib/notify_all_users.py" contrib)
+ #t))))
+ #:make-flags (let* ((prefix (assoc-ref %outputs "out")))
+ (list "CC=gcc"
+ (string-append "VERSION=v" ,version)
+ (string-append "PREFIX=" prefix)
+ (string-append "SYSCONFDIR=" prefix "/etc")))
+ #:test-target "test"))
+ (native-inputs `(("go" ,go) ;for the test suite
+ ("pandoc" ,ghc-pandoc))) ;to generate the manpage
+ (home-page "https://github.com/rfjakob/earlyoom")
+ (synopsis "Simple out of memory (OOM) daemon for the Linux kernel")
+ (description "Early OOM is a minimalist out of memory (OOM) daemon that
+runs in user space and provides a more responsive and configurable alternative
+to the in-kernel OOM killer.")
+ (license license:expat)))
+
(define-public eudev
;; The post-systemd fork, maintained by Gentoo.
(package
--
2.24.1
Then there is a Shepherd service for convenience. I haven't tried all
the switches, but I presume it'd work, given that they seem to be
translated correctly into earyloom's command line options (there's a
unit test for it).
And then enjoy your hang free system :-)

Thank you,

Maxim
pkill9 wrote 5 years ago
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 39283@debbugs.gnu.org)
20200131123139.7117b0de@runbox.com
Hi Maxim,

Toggle quote (7 lines)
> I happened to have prepared earlyoom recently, but delayed its
> inclusion due to finishing a service for it (only the doc remains).
>
> I'm attaching it. My version seems slightly more complete (I generate
> the doc and run the tests). If you don't have an objection I could
> push it to master.

I have no objection, go for it :)
Maxim Cournoyer wrote 5 years ago
Re: [bug#39283] [PATCH] gnu: Add earlyoom.
(name . pkill9)(address . pkill9@runbox.com)(address . 39283-done@debbugs.gnu.org)
87sgjurkeq.fsf@gmail.com
pkill9 <pkill9@runbox.com> writes:

Toggle quote (11 lines)
> Hi Maxim,
>
>> I happened to have prepared earlyoom recently, but delayed its
>> inclusion due to finishing a service for it (only the doc remains).
>>
>> I'm attaching it. My version seems slightly more complete (I generate
>> the doc and run the tests). If you don't have an objection I could
>> push it to master.
>
> I have no objection, go for it :)

Merged (with the service) with commit d3e439e355. Thank you!

Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 39283@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 39283
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help