From 4c467ebd377f17aac62cb8c861b1f162f1d76383 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 7 Oct 2026 21:15:50 +0900 Subject: [PATCH] Record the build and run conditions on Windows RUBY_DESCRIPTION is the same for MSVC and clang-cl builds of one revision and for builds with different flags, and ruby-bench does not control the power settings on Windows. The result JSON now keeps the compiler flags from RbConfig, the applied affinity mask and priority class, and the power scheme with the power mode overlay that Windows 11 applies on top of it. Co-Authored-By: Claude Opus 5.5 --- harness/harness-common.rb | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/harness/harness-common.rb b/harness/harness-common.rb index 073edb04..4d5510fb 100644 --- a/harness/harness-common.rb +++ b/harness/harness-common.rb @@ -176,6 +176,61 @@ def self.function(name, args, ret) end end +WINDOWS_POWER_MODES = { + "961cc777-2547-4f9d-8174-7d86181b8a7a" => "best power efficiency", + "00000000-0000-0000-0000-000000000000" => "balanced", + "3af9b8d9-7c97-431d-ad78-34a8bfea439f" => "better performance", + "ded574b5-45a0-4f42-8737-46345c09c238" => "best performance", +} + +def windows_guid_string(bytes) + data1, data2, data3 = bytes.unpack('L "0x%x" % process_mask.unpack1('J'), + "priority_class" => "0x%x" % get_priority_class.call(process), + "power_scheme" => { "guid" => scheme_guid, "name" => name.force_encoding('UTF-16LE').encode('UTF-8').delete("\0") }, + "power_mode" => { "guid" => overlay_guid, "name" => WINDOWS_POWER_MODES[overlay_guid] }, + } +rescue LoadError, StandardError + warn "Failed to get run conditions: #{$!.message}" + nil +end + def pin_to_cpu(cpu) load_fiddle # Etc.nprocessors counts the CPUs of every processor group, but the mask holds those of one group only. @@ -267,6 +322,12 @@ def return_results(warmup_iterations, bench_iterations, **extra) if maxrss = get_maxrss ruby_bench_results["maxrss"] = maxrss end + if is_windows + # RUBY_DESCRIPTION does not tell MSVC from clang-cl builds or builds with different flags. + # mswin has no optflags in RbConfig and folds them into CFLAGS. + ruby_bench_results["build_config"] = RbConfig::CONFIG.slice("CC", "CFLAGS", "CPPFLAGS", "optflags") + ruby_bench_results["run_conditions"] = get_windows_run_conditions + end # If YJIT or ZJIT is enabled, show some of its stats unless it does by itself. if yjit_stats