Skip to content

feat: Stim Host helper restarts a bloated fseventsd - #6602

Merged
janicduplessis merged 2 commits into
mainfrom
feat/6600-helper-restarts-fseventsd
Nov 28, 2026
Merged

janicduplessis merged 2 commits into
mainfrom
feat/6600-helper-restarts-fseventsd

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Stim Desktop showed "fseventsd uses 82.68 GB" and told the user to run sudo killall fseventsd. The opt-in root helper in Stim Host (#6256) already restarts runaway Apple services, but fseventsd was not on its allowlist. The maintainer asked for the helper to handle it (quotes in #6600 and LLP 0001).

Second problem: the helper measured memory with RSS (pti_resident_size), which leaves out compressed and swapped pages. On the maintainer's MacBook fseventsd had about 10 GB RSS against a 77 GiB footprint (67 GiB compressed). Once the machine swaps harder, RSS can fall under the 2 GiB limit while the footprint keeps growing. #5910 covers an earlier 52 GB case.

Solution

  • helper_paths gets fseventsd's exact path, /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/Support/fseventsd, checked with ps -o comm= on macOS 27.0 (26A428). It goes at the end of the list because log lines and restored cooldowns refer to a service by its index.
  • The helper reads ri_phys_footprint with proc_pid_rusage (it runs as root, so this works for root daemons) and compares the larger of RSS and footprint with the 2 GiB limit. This applies to all six services, not only fseventsd. Footprint can only raise the measured value, so every process that qualified before still qualifies. If the call fails, the footprint is 0 and RSS is used as before. Sample, restart and result log lines get a footprint field; the core reader ignores unknown fields.
  • LLP 0001 records the decision, the footprint rule, and that restarting fseventsd makes FSEvents clients (Metro, Watchman, Spotlight) rescan once.

This PR changes only the helper source. Macs get the new behavior only after a new host-v* release is pinned in packages/server/src/stim-host.ts, so the CLI still prints sudo killall fseventsd. Advising stim service install --helper now would install the 0.2.0 helper, which does not restart fseventsd. The pin PR switches the advice, the guides, the website and the Desktop copy, and handles helpers that are already registered: those keep running their old binary after the bundle is updated (#6604, #6601).

Risk: the helper will signal one more root daemon. The worst case is one extra rescan by file watchers, at most once an hour.

Test plan

  • pnpm test packages/server/__tests__/helper-policy.integration.test.ts on macOS: the policy fixture checks that the fseventsd path matches index 5 and that /usr/sbin/fseventsd does not match. The files and retry fixtures compile the real stim-host-helper.c with the new proc_pid_rusage call.
  • Compiled stim-host-helper.c universal with the release.sh flags (-Wall -Wextra -Werror -arch arm64 -arch x86_64).
  • A standalone libproc probe returned proc_pid_rusage footprint for its own pid. A non-root process cannot read fseventsd, so the helper's root read was not exercised, and fseventsd was not signalled.

Release after merge: tag host-v<next> on main so the Stim Host release workflow signs and notarizes it, then follow #6604 to pin it (see RELEASE.md "Stim Host releases").

Fixes #6600

The opt-in root helper now lists fseventsd and measures memory as the
larger of RSS and physical footprint, since RSS leaves out compressed and
swapped pages. The fseventsd memory culprit suggests the helper setup
command instead of sudo killall.

Fixes #6600
@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide area: server packages/server area: website website/ area: docs docs/ and root documents ci-full run the macOS, Windows, Desktop and license jobs on this pull request labels Nov 28, 2026
@janicduplessis janicduplessis removed area: cli packages/stim-cli, including its README and guide area: website website/ labels Nov 28, 2026
@janicduplessis
janicduplessis marked this pull request as ready for review November 28, 2026 00:48
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 28, 2026
@janicduplessis
janicduplessis enabled auto-merge (squash) November 28, 2026 00:48
@janicduplessis
janicduplessis merged commit ad81368 into main Nov 28, 2026
88 of 90 checks passed
@janicduplessis
janicduplessis deleted the feat/6600-helper-restarts-fseventsd branch November 28, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs docs/ and root documents area: server packages/server ci-full run the macOS, Windows, Desktop and license jobs on this pull request review: ai-approved A fresh AI review found nothing left to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stim Host helper: restart a bloated fseventsd automatically

1 participant