From ceda5f18b739f5bf67f752ddf45ecb1adac7e382 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Tue, 12 Nov 2024 14:42:18 -0500 Subject: [PATCH 1/2] Fix value reported by get_maxrss on macos The value of ru_maxrss is in bytes on macos, which contradicts what the manpage says at: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getrusage.2.html Apparently, the manppage is wrong, but this information has never been corrected. I can't seem to get the Apple bug reporting software to work and so am unable to report this issue to Apple. --- harness/harness-common.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/harness/harness-common.rb b/harness/harness-common.rb index 7f747a91..2ba8c228 100644 --- a/harness/harness-common.rb +++ b/harness/harness-common.rb @@ -51,6 +51,10 @@ def get_rss end end +def is_macos + RbConfig::CONFIG['host_os'].match(/darwin/) != nil +end + def get_maxrss require 'fiddle' require 'rbconfig/sizeof' @@ -70,7 +74,14 @@ def get_maxrss result = getrusage.call(rusage_self, buffer) raise unless result.zero? maxrss_kb = buffer[offset, Fiddle::SIZEOF_LONG].unpack1('q') - 1024 * maxrss_kb + + # On macos, this value is already in bytes + # (and the manpage is wrong) + if is_macos + maxrss_kb + else + 1024 * maxrss_kb + end rescue LoadError warn "Failed to get max RSS: #{$!.message}" nil From f8a11811a9fb2bd11859acb8fc3e04bcd98c8ce5 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Tue, 12 Nov 2024 15:11:22 -0500 Subject: [PATCH 2/2] Update harness/harness-common.rb Co-authored-by: Takashi Kokubun --- harness/harness-common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harness/harness-common.rb b/harness/harness-common.rb index 2ba8c228..454dbede 100644 --- a/harness/harness-common.rb +++ b/harness/harness-common.rb @@ -52,7 +52,7 @@ def get_rss end def is_macos - RbConfig::CONFIG['host_os'].match(/darwin/) != nil + RUBY_PLATFORM.match?(/darwin/) end def get_maxrss