Skip to content

feat: warn in measure when dyld shared cache is unshared - #78

Merged
Interlap01 merged 1 commit into
MobAI-App:mainfrom
kdbhalala:feat/measure-shared-cache-warning
Nov 30, 2026
Merged

Interlap01 merged 1 commit into
MobAI-App:mainfrom
kdbhalala:feat/measure-shared-cache-warning

Conversation

@kdbhalala

Copy link
Copy Markdown
Contributor

Refs #73.

On macOS 27.2.x hosts, every simulator process keeps a private dirty copy of the dyld shared cache's __DATA_CONST, so a fully slim simulator measures ~2.6 GB instead of ~0.4–0.9 GB. Slimming cannot fix that, but today users only see "slim isn't working". This makes measure say why.

What it does

  • Measure probes the simulator's own sharingd (never disabled) with footprint -p <pid> and reads the Dirty column of the __DATA_CONST row.
  • Above 16 MB it sets Measurement.SharedCacheUnshared. Measured values: ~848–884 KB on healthy hosts, ~88–89 MB on affected ones, so the threshold has wide margin on both sides.
  • simslim measure prints one warning line to stderr linking Slim simulators use ~4x memory on a macOS 27.2.1 / Xcode 27.2 host (per-process dirty __DATA_CONST, cryptexd-mounted runtime) #73. --json gains "sharedCacheUnshared": true, with omitempty, so existing consumers and the GUI are unaffected.
  • The probe is best-effort: if footprint fails or the row is missing, the field stays false and measure reports as before.

Not in this PR

  • Detection only; memory does not go down.
  • If sharingd is not running in the simulator (e.g. kept off via a custom setup), the probe is skipped.
  • top, MeasureMany and the macOS app are unchanged. Happy to surface it there too if you want.

Test plan

  • make check passes (go test, go vet, swift-format lint, zsh -n, plutil).
  • New parser tests in measure_test.go: affected sample (89 MB), healthy sample (848 KB), missing row.
  • Real run on macOS 27.2.1 / Xcode 27.3 / iOS 27.3 (affected host): the warning prints, and --json includes "sharedCacheUnshared": true.
  • Not run on a healthy host (I don't have one); the healthy case is covered by the parser test only.

@Interlap01
Interlap01 merged commit 7c52e89 into MobAI-App:main Nov 30, 2026
1 check passed
@Interlap01

Copy link
Copy Markdown
Contributor

Thank you!

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.

2 participants