Snakemake version
9.19.0
Operating system
Windows 10/11 (tested with micromamba-managed environment)
Describe the bug
The benchmark: directive records only wall-clock time (s, h:m:s). All other
columns (max_rss, max_vms, max_uss, max_pss, io_in, io_out,
mean_load, cpu_time) are written as NA on Windows.
Root cause
In snakemake/benchmark.py, BenchmarkTimer._update_record() accesses
meminfo.pss unconditionally (line ~240):
On Windows, psutil.Process.memory_full_info() does not return a pss
field (Proportional Set Size is a Linux-only metric). This raises
AttributeError, which is caught by BenchmarkTimer.work():
except AttributeError:
pass # skip, process died in flight
The exception is silently swallowed every polling cycle, so
data_collected never becomes True and all metrics remain None → NA.
Confirmation
I verified that psutil works correctly inside a Snakemake run: block on
the same machine:
PID: 13148
memory_info OK -> RSS=101478400, VMS=82669568
memory_full_info OK -> USS=76996608
io_counters OK -> read=28964767, write=1707
children OK -> count=0
parent process OK -> PID=12860, name=snakemake.exe
parent.children OK -> count=1
All psutil calls succeed — the only failure point is the missing pss
attribute.
Minimal example
# Snakefile
rule test_benchmark:
output: "test_flag.txt"
benchmark: "benchmark.txt"
run:
import time
data = [0] * (50 * 1024 * 1024) # allocate ~400 MB
time.sleep(60)
with open(output[0], "w") as f:
f.write("done")
snakemake --cores 1 test_flag.txt
type benchmark.txt
Expected output: Filled values for at least max_rss, max_vms, max_uss, io_in, io_out.
Actual output:
s h:m:s max_rss max_vms max_uss max_pss io_in io_out mean_load cpu_time
60.27 0:01:00 NA NA NA NA NA NA NA NA
Suggested fix
Replace the direct attribute access with getattr:
pss += getattr(meminfo, "pss", 0)
This is a one-line change in snakemake/benchmark.py inside
_update_record(). On Linux nothing changes (the attribute exists). On
Windows/macOS, pss will report 0 but all other metrics will work
correctly.
I am happy to submit a PR with this fix and a corresponding test case if
desired.
Snakemake version
9.19.0
Operating system
Windows 10/11 (tested with micromamba-managed environment)
Describe the bug
The
benchmark:directive records only wall-clock time (s,h:m:s). All othercolumns (
max_rss,max_vms,max_uss,max_pss,io_in,io_out,mean_load,cpu_time) are written asNAon Windows.Root cause
In
snakemake/benchmark.py,BenchmarkTimer._update_record()accessesmeminfo.pssunconditionally (line ~240):On Windows,
psutil.Process.memory_full_info()does not return apssfield (Proportional Set Size is a Linux-only metric). This raises
AttributeError, which is caught byBenchmarkTimer.work():The exception is silently swallowed every polling cycle, so
data_collectednever becomesTrueand all metrics remainNone→NA.Confirmation
I verified that
psutilworks correctly inside a Snakemakerun:block onthe same machine:
All
psutilcalls succeed — the only failure point is the missingpssattribute.
Minimal example
snakemake --cores 1 test_flag.txt type benchmark.txtExpected output: Filled values for at least
max_rss,max_vms,max_uss,io_in,io_out.Actual output:
Suggested fix
Replace the direct attribute access with
getattr:This is a one-line change in
snakemake/benchmark.pyinside_update_record(). On Linux nothing changes (the attribute exists). OnWindows/macOS,
psswill report0but all other metrics will workcorrectly.
I am happy to submit a PR with this fix and a corresponding test case if
desired.