Skip to content

companion: set JetsamProperties in overlay plist and drain autorelease pools - #158

Merged
henrikklee merged 1 commit into
OrchardLinux:mainfrom
grierj:fix/companion-jetsam-and-autoreleasepool
Dec 4, 2026
Merged

henrikklee merged 1 commit into
OrchardLinux:mainfrom
grierj:fix/companion-jetsam-and-autoreleasepool

Conversation

@grierj

@grierj grierj commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #156 (and addresses the underlying Jetsam kill noted in #45).

Changes

  • crates/runtime/src/overlay.rs: Add JetsamProperties (JetsamPriority: 160, JetsamMemoryLimit: 256) to job(), matching OrchardLinux/resize-apfs's overlay and Dopamine launchd plists so orchard-companion is not capped at iPadOS's default unlisted-daemon limit (~18 MB InactiveHard).
  • companion/Helper/main.swift: Wrap every iteration of Launcher.run(), the 1 Hz status rewrite loop, the 1 Hz engine.refresh() loop, and serve(fd) per-request handling in autoreleasepool { ... }.
  • ios-installer/Helper/main.swift: Wrap the 1 Hz Resizer.run() loop and serve(fd) per-request loop in autoreleasepool { ... } as well.
  • Add overlay::tests::the_helper_job_sets_jetsam_properties.

Pairs with OrchardLinux/resize-apfs#42.

Verification

  • cargo test -p orchard-runtime: 101 passed, 0 failed.

…e pools

Set JetsamPriority (160) and JetsamMemoryLimit (256 MB) in the palera1n
overlay launchd job (crates/runtime/src/overlay.rs) to match
resize-apfs's helper plist and Dopamine daemon plist, preventing iPadOS
Jetsam from killing orchard-companion at its default unlisted-daemon
limit (~18 MB InactiveHard) during long APFS shrinks.

Wrap the long-running background thread and socket-serving loops in
companion/Helper/main.swift and ios-installer/Helper/main.swift in
autoreleasepool so bridged Foundation objects from 1 Hz status writes,
refresh inspections, and keepalive/log RPCs are freed on every iteration
instead of accumulating across multi-hour shrinks.

Fixes OrchardLinux#156

Assisted-by: LLM
@grierj
grierj force-pushed the fix/companion-jetsam-and-autoreleasepool branch from a6fcffc to fc5c3a4 Compare December 4, 2026 16:53
@henrikklee
henrikklee merged commit 037e123 into OrchardLinux:main Dec 4, 2026
11 checks passed
henrikklee added a commit to brkosebay/tools that referenced this pull request Dec 4, 2026
resize-apfs#42 (grierj) frees the helper's autoreleased memory on every
shrink step and refresh, and tells a helper restart from a device restart
by kern.bootsessionuuid. Together with OrchardLinux#158's Jetsam limit for the
companion, a long APFS split no longer has its helper killed partway.

Assisted-by: LLM
@henrikklee henrikklee mentioned this pull request Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

orchard-companion killed by iPadOS Jetsam (18 MB limit) during long APFS shrinks

2 participants