Skip to content

Measure peak memory on Linux without the script's own - #117

Merged
mvassilev merged 1 commit into
developfrom
fix/bench-linux-memory
Oct 18, 2026
Merged

mvassilev merged 1 commit into
developfrom
fix/bench-linux-memory

Conversation

@mvassilev

Copy link
Copy Markdown
Collaborator

On Linux the kernel keeps a process's RSS high-water mark across exec, so a command forked from the benchmark script counted the script's own memory in its peak: every command under 20 to 30 MB showed the size of the Python process. On the workstation, samtools idxstats on the BAM showed 22 MB in one run and 30 MB in another; it takes 10 MB.

On Linux the script now compiles a small C helper into WORK/tools, which forks the command from its own 1.4 MB process and reports its wall time, CPU time, peak RSS and exit status, as GNU time does. macOS keeps the peak physical footprint, which was not affected. PROTOCOL becomes 2, because memory in Linux reports of protocol 1 is not comparable.

Output of a command that is not valid UTF-8 no longer stops the script: sh() and check_call() replace the bytesh() y cannot decode. The table of sizes by field shows "new" or "gone" for a field under 1% of its size on the other side, where it printed +113495.9% for qualblock.

Checked on the workstation (Xeon E5-2690 v4, Ubuntu 24.04, --pin 0) with --input small between acb8904 and 5b61106: all checks pass, and samtools idxstats and flagstat on the BAM now peak at 10 MB, samtools view -h at 12 MB. On macOS the measuring path gives the same numbers as before.

On Linux the kernel keeps a process's RSS high-water mark across exec, so a
command forked from the benchmark script counted the script's own memory in
its peak: every command under 20 to 30 MB showed the size of the Python
process. On the workstation, samtools idxstats on the BAM showed 22 MB in
one run and 30 MB in another; it takes 10 MB.

On Linux the script now compiles a small C helper into WORK/tools, which
forks the command from its own 1.4 MB process and reports its wall time,
CPU time, peak RSS and exit status, as GNU time does. macOS keeps the peak
physical footprint, which was not affected. PROTOCOL becomes 2, because
memory in Linux reports of protocol 1 is not comparable.

Output of a command that is not valid UTF-8 no longer stops the script:
sh() and check_call() replace the bytesh() y cannot decode. The table of
sizes by field shows "new" or "gone" for a field under 1% of its size on the
other side, where it printed +113495.9% for qualblock.

Checked on the workstation (Xeon E5-2690 v4, Ubuntu 24.04, --pin 0) with
--input small between acb8904 and 5b61106: all checks pass, and samtools
idxstats and flagstat on the BAM now peak at 10 MB, samtools view -h at
12 MB. On macOS the measuring path gives the same numbers as before.
@mvassilev
mvassilev merged commit 0313c07 into develop Oct 18, 2026
2 checks passed
@mvassilev
mvassilev deleted the fix/bench-linux-memory branch October 18, 2026 12:29
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.69%. Comparing base (629b2b4) to head (7387ae1).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #117   +/-   ##
========================================
  Coverage    88.69%   88.69%           
========================================
  Files           25       25           
  Lines         3220     3220           
  Branches      1103     1103           
========================================
  Hits          2856     2856           
  Misses         194      194           
  Partials       170      170           
Flag Coverage Δ
unittests 88.69% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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