Skip to content

DeviceEngine: drain autorelease pools and use kern.bootsessionuuid - #42

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

henrikklee merged 1 commit into
OrchardLinux:mainfrom
grierj:fix/autoreleasepool-and-boot-uuid

Conversation

@grierj

@grierj grierj commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #41.

Changes

  • Wrap long-lived thread loops in DeviceEngine (refresh(), perform(), shrinkAPFSInSteps()), ResizeHelper/main.swift (refresh and RPC loops), and AppOpener.swift in autoreleasepool { ... } so bridged Foundation/Obj-C objects are released on every iteration instead of accumulating over multi-hour APFS shrinks.
  • Use kern.bootsessionuuid (with kern.boottime fallback) in DeviceEngine.bootIdentity() so NTP clock adjustments during a long shrink do not cause a same-boot helper respawn to be misclassified as a device reboot (which also needlessly wrote restart-budget.json).
  • Add testBootIdentityUsesStableBootSessionUUID in Tests/ResizeCoreTests/OperationHistoryTests.swift.

Verification

  • python3 scripts/check-release.py: PASS (165 files)
  • python3 -m unittest discover -s Tests/ReleaseTests: 156 tests OK
  • swift test runs in GitHub Actions CI (macos-15-intel).

Wrap long-lived thread loops in DeviceEngine (refresh, perform,
shrinkAPFSInSteps), ResizeHelper (refresh and RPC loop), and AppOpener
in autoreleasepool so bridged Foundation objects are freed each step
instead of accumulating over multi-hour shrinks.

Switch DeviceEngine.bootIdentity() from kern.boottime (which shifts
when NTP adjusts the wall clock) to kern.bootsessionuuid, with
kern.boottime kept only as a fallback. This prevents a helper respawn
in the same boot from being misclassified as a device restart and
unnecessarily cutting the next shrink budget to a quarter.

Fixes OrchardLinux#41

Assisted-by: LLM
@grierj
grierj force-pushed the fix/autoreleasepool-and-boot-uuid branch from 240ddcb to 2538a35 Compare December 4, 2026 16:52
@henrikklee
henrikklee merged commit cd1f9db into OrchardLinux:main Dec 4, 2026
1 check passed
@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.

DeviceEngine: drain autorelease pools in long-lived threads and use kern.bootsessionuuid for bootIdentity

2 participants