-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adaptivemm: init at unstable-2023-01-16
There are proper release tags, but the latest one is from Feb 2022 and there are buffer overflow fixes since.
- Loading branch information
Michael Livshin
committed
Apr 14, 2023
1 parent
0662bd2
commit 6c3d98d
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.adaptivemm; | ||
in { | ||
options = { | ||
services.adaptivemm = { | ||
enable = mkEnableOption (lib.mdDoc "Proactively tune kernel free memory configuration"); | ||
|
||
package = mkOption { | ||
type = types.package; | ||
default = pkgs.adaptivemm; | ||
defaultText = literalExpression "pkgs.adaptivemm"; | ||
description = lib.mdDoc '' | ||
Which adaptivemm package to use. | ||
''; | ||
}; | ||
|
||
verbosity = mkOption { | ||
type = types.int; | ||
default = 0; | ||
defaultText = literalExpression "0"; | ||
description = lib.mdDoc '' | ||
Verbosity, from 0 to 5. | ||
''; | ||
}; | ||
|
||
maxWatermarkGap = mkOption { | ||
type = types.int; | ||
default = 5; | ||
defaultText = literalExpression "5"; | ||
description = lib.mdDoc '' | ||
Maximum allowed gap between high and low watermarks in GB. | ||
''; | ||
}; | ||
|
||
aggressiveness = mkOption { | ||
type = types.int; | ||
default = 2; | ||
defaultText = literalExpression "2"; | ||
description = lib.mdDoc '' | ||
Aggressiveness level (1=high, 2=normal, 3=low). | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment = { | ||
systemPackages = [ cfg.package ]; | ||
etc."sysconfig/adaptivemmd".source = "${cfg.package}/etc/sysconfig/adaptivemmd"; | ||
}; | ||
|
||
systemd.services.adaptivemmd = { | ||
serviceConfig = { | ||
Type = "forking"; | ||
EnvironmentFile = "/etc/sysconfig/adaptivemmd"; | ||
ExecStart = let | ||
verboseFlag = assert (cfg.verbosity >= 0 && cfg.verbosity <= 5); | ||
if cfg.verbosity == 0 then "" | ||
else lib.concatStrings (["-"] ++ (lib.replicate cfg.verbosity "v")); | ||
aggressivenessFlag = assert (cfg.aggressiveness >= 1 && cfg.aggressiveness <= 3); | ||
"-a ${builtins.toString cfg.aggressiveness}"; | ||
gapFlag = "-m ${builtins.toString cfg.maxWatermarkGap}"; | ||
in "${cfg.package}/bin/adaptivemmd ${verboseFlag} ${aggressivenessFlag} ${gapFlag}"; | ||
KillMode = "control-group"; | ||
Restart = "on-failure"; | ||
RestartSec = "10s"; | ||
}; | ||
|
||
unitConfig = { | ||
Description = "Adaptive free memory optimizer daemon"; | ||
Documentation = "man:adaptivemmd(8)"; | ||
After = [ "systemd-sysctl.service" "local-fs.target" ]; | ||
}; | ||
|
||
wantedBy = [ "multi-user.target" ]; | ||
}; | ||
}; | ||
|
||
meta = { | ||
maintainers = with maintainers; [ cmm ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ lib, stdenv, fetchFromGitHub }: | ||
|
||
let | ||
pname = "adaptivemm"; | ||
in stdenv.mkDerivation { | ||
inherit pname; | ||
version = "unstable-2023-01-16"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "oracle"; | ||
repo = pname; | ||
rev = "92f7d6e9155e153db884ebb7da25c0a9cbcb29fe"; | ||
hash = "sha256-3aRfHn0HV9CfcLulDimHsMJPs8/VAWRVDxPijKVhtDM="; | ||
}; | ||
|
||
CFLAGS = "-I. -Wall -O2"; | ||
|
||
installPhase = '' | ||
mkdir -p $out/bin $out/etc/sysconfig $out/share/man/man8 | ||
cp adaptivemmd $out/bin/ | ||
cp $src/adaptivemmd.cfg $out/etc/sysconfig/adaptivemmd | ||
cp $src/adaptivemmd.8 $out/share/man/man8/ | ||
''; | ||
|
||
meta = with lib; { | ||
description = "A userspace daemon for proactive free memory management"; | ||
license = licenses.gpl2; | ||
platforms = platforms.linux; | ||
maintainers = with maintainers; [ cmm ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters