Skip to content

Commit 3bd4752

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 7456d96 commit 3bd4752

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎lib/harness.rb‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,23 @@ module WindowsMemoryCounters
179179
warn "Failed to get memory counters: #{$!.message}"
180180
end
181181

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

186-
# PROCESS_MEMORY_COUNTERS: two DWORDs followed by eight SIZE_Ts, the first two being PeakWorkingSetSize and WorkingSetSize.
187+
# PROCESS_MEMORY_COUNTERS: two DWORDs followed by eight SIZE_Ts.
187188
buffer = "\0".b * (8 + 8 * Fiddle::SIZEOF_SIZE_T)
188189
buffer[0, 4] = [buffer.bytesize].pack('L')
189190
return nil if @get_info.call(@process, buffer, buffer.bytesize).zero?
190191

191-
peak_working_set, working_set = buffer.unpack('x8J2')
192-
{ working_set: working_set, peak_working_set: peak_working_set }
192+
peak_working_set, working_set, _, _, _, _, commit_charge, peak_commit_charge = buffer.unpack('x8J8')
193+
{
194+
working_set: working_set,
195+
peak_working_set: peak_working_set,
196+
commit_charge: commit_charge,
197+
peak_commit_charge: peak_commit_charge,
198+
}
193199
end
194200
end
195201
end
@@ -254,6 +260,10 @@ def return_results(warmup_iterations, bench_iterations, **extra)
254260
if maxrss = get_maxrss
255261
ruby_bench_results["maxrss"] = maxrss
256262
end
263+
if defined?(WindowsMemoryCounters) && (counters = WindowsMemoryCounters.read)
264+
ruby_bench_results["commit_charge"] = counters[:commit_charge]
265+
ruby_bench_results["peak_commit_charge"] = counters[:peak_commit_charge]
266+
end
257267

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

0 commit comments

Comments
 (0)