Skip to content

Commit a4c594d

Browse files
hsbtclaude
andcommitted
Record the commit charge on Windows
Changes in private memory on Windows show up in the commit charge (PagefileUsage of GetProcessMemoryInfo) more than in the working set. The result JSON keeps it and its peak as commit_charge and peak_commit_charge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 448b3aa commit a4c594d

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎lib/harness.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ def return_results(warmup_iterations, bench_iterations, **extra)
228228
if maxrss = get_maxrss
229229
ruby_bench_results["maxrss"] = maxrss
230230
end
231+
if defined?(WindowsMemoryCounters) && (counters = WindowsMemoryCounters.read)
232+
ruby_bench_results["commit_charge"] = counters[:commit_charge]
233+
ruby_bench_results["peak_commit_charge"] = counters[:peak_commit_charge]
234+
end
231235

232236
# If YJIT or ZJIT is enabled, show some of its stats unless it does by itself.
233237
if yjit_stats

‎lib/harness/windows_memory_counters.rb‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ module WindowsMemoryCounters
1313
warn "Failed to get memory counters: #{$!.message}"
1414
end
1515

16-
# The working set of this process and its peak in bytes, the Windows counterparts of RSS and max RSS.
16+
# Memory counters of this process in bytes. The working set is the Windows counterpart of RSS,
17+
# and the commit charge (PagefileUsage) is the private memory the process has committed.
1718
def self.read
1819
return nil unless @get_info
1920

20-
# PROCESS_MEMORY_COUNTERS: two DWORDs followed by eight SIZE_Ts, the first two being PeakWorkingSetSize and WorkingSetSize.
21+
# PROCESS_MEMORY_COUNTERS: two DWORDs followed by eight SIZE_Ts.
2122
buffer = "\0".b * (8 + 8 * Fiddle::SIZEOF_SIZE_T)
2223
buffer[0, 4] = [buffer.bytesize].pack('L')
2324
return nil if @get_info.call(@process, buffer, buffer.bytesize).zero?
2425

25-
peak_working_set, working_set = buffer.unpack('x8J2')
26-
{ working_set: working_set, peak_working_set: peak_working_set }
26+
peak_working_set, working_set, _, _, _, _, commit_charge, peak_commit_charge = buffer.unpack('x8J8')
27+
{
28+
working_set: working_set,
29+
peak_working_set: peak_working_set,
30+
commit_charge: commit_charge,
31+
peak_commit_charge: peak_commit_charge,
32+
}
2733
end
2834
end

0 commit comments

Comments
 (0)