Skip to content

Commit 8b568e7

Browse files
r17xclaude
andcommitted
perf(darwin): reduce CPU spike during rebuild with launchd tuning
Optimize service startup to reduce CPU contention during nix-darwin rebuild: Linux Builder (heaviest service - 6 cores, 8GB RAM): - Disable auto-start: RunAtLoad = false, KeepAlive = false - Start on-demand with: universe service start linux-builder User services (sketchybar, jankyborders): - ProcessType = "Background" for lower scheduling priority - Nice = 5 for reduced CPU priority - LowPriorityIO = true for less I/O contention - ThrottleInterval = 10 for minimum restart interval Result: Load average dropped from 3.76 to 1.94 after rebuild. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 149dff6 commit 8b568e7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

nix/modules/darwin/linux-builder.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ in
1919
"root"
2020
];
2121
nix.settings.builders-use-substitutes = cfg.enable;
22+
23+
# Disable auto-start to reduce CPU spike during rebuild
24+
# Start manually with: universe service start linux-builder
25+
launchd.daemons.linux-builder.serviceConfig = mkIf cfg.enable {
26+
RunAtLoad = mkForce false;
27+
KeepAlive = mkForce false;
28+
};
29+
2230
nix.linux-builder = {
2331
ephemeral = true;
2432
maxJobs = 4;

nix/modules/darwin/mouseless.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,5 +257,24 @@ in
257257
${leader} - r : yabai -m space --rotate 90
258258
'';
259259
};
260+
261+
# Reduce CPU spike during rebuild by lowering service priority
262+
# ProcessType=Background: lower scheduling priority
263+
# Nice=5: lower CPU priority (positive = less priority)
264+
# LowPriorityIO=true: reduce I/O contention
265+
# ThrottleInterval=10: minimum 10 seconds between restarts
266+
launchd.user.agents.sketchybar.serviceConfig = {
267+
ProcessType = "Background";
268+
Nice = 5;
269+
LowPriorityIO = true;
270+
ThrottleInterval = 10;
271+
};
272+
273+
launchd.user.agents.jankyborders.serviceConfig = {
274+
ProcessType = "Background";
275+
Nice = 5;
276+
LowPriorityIO = true;
277+
ThrottleInterval = 10;
278+
};
260279
};
261280
}

0 commit comments

Comments
 (0)