Skip to content

Commit c0e64ef

Browse files
committed
fix(diagnostics): report OS-truth RSS, not mimalloc's Linux commit counter
Both Linux soak-quick legs in the dry run failed with: FAIL: RSS 17592186044293MB > 200MB ceiling 17592186044293 MB is 2^44-123 -- a NEGATIVE ~123MB wrapped through size_t. The diagnostics snapshot reported mi_process_info()'s current_rss verbatim, and on Linux mimalloc never sets that field: it keeps mimalloc's internal committed-page counter, which this project deliberately tunes low (purge_decommits=1, purge_delay=0) and which can transiently go negative under purge. macOS and Windows are untouched -- mimalloc reports real RSS there -- which is exactly the observed split: both Linux legs red, both macOS legs green. mem.c already learned this lesson in full (its comment block documents the same trap for cbm_mem_over_budget): cbm_mem_rss() is /proc-statm-primary on Linux and mimalloc-correct elsewhere, and cbm_mem_peak_rss() reconciles peak >= current. The diagnostics writer now uses both instead of the raw mi fields, so the soak leak gates measure actual process RSS on every platform. Verified: diagnostics suite passes; compiles and formats clean. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent ad010b1 commit c0e64ef

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎src/foundation/diagnostics.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,16 @@ static void write_diagnostics(void) {
528528
size_t page_faults = 0;
529529
mi_process_info(&elapsed_ms, &user_ms, &sys_ms, &current_rss, &peak_rss, &current_commit,
530530
&peak_commit, &page_faults);
531-
if (current_rss == 0) {
532-
current_rss = cbm_mem_rss();
533-
}
531+
/* Do NOT report mi_process_info's rss fields: on Linux mimalloc never sets
532+
* current_rss, so the field keeps mimalloc's internal committed-page
533+
* counter — deliberately tuned low here (purge_decommits=1, purge_delay=0)
534+
* and able to go transiently NEGATIVE under purge, which wraps through
535+
* size_t and printed rss_bytes of ~2^64 (soak read it as a 17-exabyte
536+
* "leak"). cbm_mem_rss()/cbm_mem_peak_rss() already encode the whole
537+
* lesson: /proc statm is authoritative on Linux, mimalloc is correct on
538+
* macOS/Windows, and peak is reconciled to never undercut current. */
539+
current_rss = cbm_mem_rss();
540+
peak_rss = cbm_mem_peak_rss();
534541

535542
int fds = count_open_fds();
536543
time_t now = time(NULL);

0 commit comments

Comments
 (0)