Repository navigation
Memory screen: track the NE's disk writes against the daily budget - #240
Merged
Merged
Conversation
The iPhone 14 .ips reports that get the NE throttled/killed are diskwrites_resource breaches - 'limit of 12,137 KB over 86400 s' - which the memory chart could not show because the trace had no disk counter. Trace layout v2 (+8 B record): each record now carries the cumulative proc_pid_rusage ri_diskio_byteswritten at sample time, sampled alongside the footprint by the same 1 Hz loop and included on boot/stop markers so kill cards show the dead generation's total. proc_pid_rusage is not declared in the iOS SDK headers; resolve it via dlsym(RTLD_DEFAULT) - reading your own rusage needs no entitlement. ensureFile now drops a file whose size does not match this build's layout (a v1 ring from an older build) instead of interleaving two geometries. Analyzer derives per-point write rates (delta between consecutive plotted records within a generation - no live/bucket double counting) and per-event disk totals; the screen gains a cumulative-writes chart with the 11.9 MB/day budget line.
Contributor
[Medium impact] The change since the previous review appears safe to merge. SummaryThe PR adds disk-write counters to the Network Extension’s memory trace and shows write rates against the daily budget.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Network Extension samples disk writes] --> B[Trace layout v2]
B --> C[Analyzer computes rates and totals]
C --> D[Memory screen shows disk writes]
Reviews (7) · Last reviewed commit: "DiskIO: Darwin's RTLD_DEFAULT is (void*)..." · Reviewed by Greptile |
Owner
Author
|
@greptile review |
Greptile 5/5 review surfaced three real defects, all fixed: - Kill-card disk total: the counter is cumulative since process start, so the total is the LAST reading outright. The previous last-minus-first subtraction dropped a run's early writes once the ring overwrote its boot marker (>5.6 days). - A failed rusage probe now stores the diskWrittenUnavailable sentinel, never 0 - a zero between real readings would fake a counter reset and inflate the next interval's rate. The analyzer renders it as no data and does not bridge the gap. - The disk card plots the write RATE (KB/s) against the daily budget expressed as a rate (~0.14 KB/s) instead of cumulative-vs-fixed-line: a healthy multi-day run crossed a fixed daily line and read as a breach.
Owner
Author
|
All three P2s fixed in f04979e (+ chart nil-rate skip):
NEMemoryTraceTests 26/26 on the Mac sim. |
Owner
Author
|
@greptile review |
The first on-device run stored the sentinel on every record: the probe fails on the real device while succeeding on the sim. Diagnose which leg fails (symbol lookup vs syscall result + errno) with a single ext-diag.log line.
dlsym(NULL, …) fails on iOS (NULL is not RTLD_DEFAULT there — that is a glibc-ism), which is why the first on-device run stored the sentinel on every record while the sim worked. Pass RTLD_DEFAULT properly.
Owner
Author
|
@greptile review |
Owner
Author
|
Fixed: the once-only log is now guarded by a dedicated |
Owner
Author
|
@greptile review |
1 similar comment
Owner
Author
|
@greptile review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The iPhone 14
*.diskwrites_resource.ipsreports (limit of 12,137 KB over 86,400 s) are what get the background transport throttled and killed — and the Memory Usage screen had no way to show disk writes, because the NE memory trace carried no disk counter.Change
proc_pid_rusage→ri_diskio_byteswrittenat sample time, sampled by the existing 1 Hz loop alongside the footprint. Boot/stop markers carry it too, so kill cards can show a dead generation's total.proc_pid_rusageis not declared in the iOS SDK headers (libproc.h is macOS-only); resolved once viadlsym(RTLD_DEFAULT, …)— reading your own rusage needs no entitlement.ensureFilenow drops and recreates a file whose size does not match this build's layout (a v1 ring from an older build) instead of interleaving two geometries. The trace is diagnostics, not state — no migration.last − firstof the cumulative counter;nilfor pre-v2 rings)..ipsreports), plus a disk total line on the kill card.Testing
NEMemoryTraceTests: 24/24 on the Mac sim (layout round-trip incl. the new field, v1-file drop+recreate, kill disk total + per-point rate, counter reset across generations).ColumbaAppTestssuite running; device verification of the v2 ring + chart pending a device build.