Add graceful cleanup of build tool daemons when removing worktrees #225
Labels
No labels
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#225
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When worktrees are removed (via
iw worktree removeor manual cleanup), build tool daemon processes spawned inside those worktrees are left running. These orphaned processes accumulate over time, consuming significant CPU and memory.Observed today: 14 orphaned Mill daemon and Bloop server processes from deleted/stale worktrees were consuming ~2775% CPU (on a 24-core machine) and ~50% RAM combined. The processes had been accumulating since Feb 18 without any cleanup.
Affected build tools (at minimum):
<project>/out/mill-daemon/sandbox~/.local/share/scalacli/bloopProposed Solution
Add a cleanup step to the worktree removal workflow that:
out/mill-daemon/for Mill)Possible approaches
mill --no-server shutdown(or equivalent) before removing the worktree directorybloop exitto stop Bloop servers tied to the worktreeEdge cases to consider
(deleted)CWD) — need to match by path substring in/proc/<pid>/cmdlineContext
This came up while working on the
medeca-modul-poptavkyproject (sbt-based), where stale Mill/Bloop processes from theunmz-evaluation-aiproject (Mill-based) were hogging the machine.Superseded by #382, which consolidates this (build-tool-daemon cleanup) with #147 (project-defined hook surface) into a single
CleanupActiondesign. The Mill/Bloop/docker-compose detection proposed here lives in #382 as a built-inBuildToolCleanupdefault hook so the "hogging CPU after rm" case is fixed with no per-project config. Implementation will land on #382.