diff options
| author | Tobias Geerinckx-Rice <me@tobias.gr> | 2023-11-19 01:00:00 +0100 |
|---|---|---|
| committer | Tobias Geerinckx-Rice <me@tobias.gr> | 2023-12-10 01:00:00 +0100 |
| commit | d993ed43b2bae8717437aa27d9d33fd223a6411f (patch) | |
| tree | af1b699abfe93a7f1d6c6565c8cd0512f0763e32 /nix | |
| parent | 38035705ed29206eb9e9f774b9d1e98c9be53a16 (diff) | |
daemon: Sacrifice builders on OOM.
* nix/libstore/build.cc (DerivationGoal::runChild):
Maximise our OOM score adjustment.
Change-Id: I418c763b499ca16e1ffe3c6033319112b9744f51
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/libstore/build.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index e8259aa4e8c..54555b92d75 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc | |||
| @@ -2154,6 +2154,12 @@ void DerivationGoal::runChild() | |||
| 2154 | determinism. */ | 2154 | determinism. */ |
| 2155 | int cur = personality(0xffffffff); | 2155 | int cur = personality(0xffffffff); |
| 2156 | if (cur != -1) personality(cur | ADDR_NO_RANDOMIZE); | 2156 | if (cur != -1) personality(cur | ADDR_NO_RANDOMIZE); |
| 2157 | |||
| 2158 | /* Ask the kernel to eagerly kill us & our children if it runs out of | ||
| 2159 | memory, regardless of blame, to preserve ‘real’ user data & state. */ | ||
| 2160 | try { | ||
| 2161 | writeFile("/proc/self/oom_score_adj", "1000"); // 100% | ||
| 2162 | } catch (...) { ignoreException(); } | ||
| 2157 | #endif | 2163 | #endif |
| 2158 | 2164 | ||
| 2159 | /* Fill in the environment. */ | 2165 | /* Fill in the environment. */ |
