From 3eda2493ef00a684a1876309b1c1f95455e967fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Tue, 30 Sep 2025 17:35:32 +0200 Subject: [PATCH 1/4] [ruby/ipaddr] Remove warning by asserting its presence $ rake test >/dev/null /tmp/test/test_ipaddr.rb:202: warning: IPAddr#ipv4_compat is obsolete https://github.com/ruby/ipaddr/commit/31d62407c2 --- test/test_ipaddr.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb index ac8921e75c8e47..64927a1444d7cb 100644 --- a/test/test_ipaddr.rb +++ b/test/test_ipaddr.rb @@ -199,7 +199,9 @@ def test_ipv4_compat assert_equal(128, b.prefix) a = IPAddr.new("192.168.0.0/16") - b = a.ipv4_compat + assert_warning(/obsolete/) { + b = a.ipv4_compat + } assert_equal("::192.168.0.0", b.to_s) assert_equal(Socket::AF_INET6, b.family) assert_equal(112, b.prefix) From 400e150f00ebbd71b14c9c4a885b1eb23be4b4b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 02:03:58 +0000 Subject: [PATCH 2/4] Bump ossf/scorecard-action from 2.4.2 to 2.4.3 Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.2 to 2.4.3. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](https://github.com/ossf/scorecard-action/compare/05b42c624433fc40578a4040d5cf5e36ddca8cde...4eaacf0543bb3f2c246792bd56e8cdeffafb205a) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-version: 2.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index c997a6a453be76..99c563a25b3728 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -39,7 +39,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 + uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 with: results_file: results.sarif results_format: sarif From 56f777cedf1b9acc2fe74bda3d5dde351ba31951 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 30 Sep 2025 20:50:08 -0700 Subject: [PATCH 3/4] ZJIT: Add more *_send_count stats (#14689) --- zjit.rb | 21 +++++++++++++++++---- zjit/src/codegen.rs | 5 +++++ zjit/src/stats.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/zjit.rb b/zjit.rb index 2ff4cf2a5b2a6f..ab5bae719a333e 100644 --- a/zjit.rb +++ b/zjit.rb @@ -162,9 +162,16 @@ def stats_string print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20) print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20) - # Show the most important stats ratio_in_zjit at the end + # Show no-prefix counters, having the most important stat `ratio_in_zjit` at the end print_counters([ + :send_count, :dynamic_send_count, + :optimized_send_count, + :iseq_optimized_send_count, + :inline_cfunc_optimized_send_count, + :variadic_cfunc_optimized_send_count, + ], buf:, stats:, right_align: true, base: :send_count) + print_counters([ :dynamic_getivar_count, :dynamic_setivar_count, @@ -202,12 +209,18 @@ def assert_compiles # :nodoc: # :stopdoc: private - def print_counters(keys, buf:, stats:) - left_pad = keys.map { |key| key.to_s.sub(/_time_ns\z/, '_time').size }.max + 1 + def print_counters(keys, buf:, stats:, right_align: false, base: nil) + key_pad = keys.map { |key| key.to_s.sub(/_time_ns\z/, '_time').size }.max + 1 + key_align = '-' unless right_align + value_pad = keys.filter_map { |key| stats[key] }.map { |value| number_with_delimiter(value).size }.max + keys.each do |key| # Some stats like vm_insn_count and ratio_in_zjit are not supported on the release build next unless stats.key?(key) value = stats[key] + if base && key != base + ratio = " (%4.1f%%)" % (100.0 * value / stats[base]) + end case key when :ratio_in_zjit @@ -219,7 +232,7 @@ def print_counters(keys, buf:, stats:) value = number_with_delimiter(value) end - buf << "#{"%-#{left_pad}s" % "#{key}:"} #{value}\n" + buf << "%#{key_align}*s %*s%s\n" % [key_pad, "#{key}:", value_pad, value, ratio] end end diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index b8d527fb8d6494..23631ae6baf70b 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -661,6 +661,7 @@ fn gen_patch_point(jit: &mut JITState, asm: &mut Assembler, invariant: &Invarian /// Lowering for [`Insn::CCall`]. This is a low-level raw call that doesn't know /// anything about the callee, so handling for e.g. GC safety is dealt with elsewhere. fn gen_ccall(asm: &mut Assembler, cfun: *const u8, args: Vec) -> lir::Opnd { + gen_incr_counter(asm, Counter::inline_cfunc_optimized_send_count); asm.ccall(cfun, args) } @@ -675,6 +676,8 @@ fn gen_ccall_variadic( cme: *const rb_callable_method_entry_t, state: &FrameState, ) -> lir::Opnd { + gen_incr_counter(asm, Counter::variadic_cfunc_optimized_send_count); + gen_prepare_non_leaf_call(jit, asm, state); let stack_growth = state.stack_size(); @@ -1051,6 +1054,8 @@ fn gen_send_without_block_direct( args: Vec, state: &FrameState, ) -> lir::Opnd { + gen_incr_counter(asm, Counter::iseq_optimized_send_count); + let local_size = unsafe { get_iseq_body_local_table_size(iseq) }.as_usize(); let stack_growth = state.stack_size() + local_size + unsafe { get_iseq_body_stack_max(iseq) }.as_usize(); gen_stack_overflow_check(jit, asm, state, stack_growth); diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs index a9cf1bde7cd131..5c8333d01dc4b6 100644 --- a/zjit/src/stats.rs +++ b/zjit/src/stats.rs @@ -21,6 +21,9 @@ macro_rules! make_counters { dynamic_send { $($dynamic_send_counter_name:ident,)+ } + optimized_send { + $($optimized_send_counter_name:ident,)+ + } $($counter_name:ident,)+ ) => { /// Struct containing the counter values @@ -29,6 +32,7 @@ macro_rules! make_counters { $(pub $default_counter_name: u64,)+ $(pub $exit_counter_name: u64,)+ $(pub $dynamic_send_counter_name: u64,)+ + $(pub $optimized_send_counter_name: u64,)+ $(pub $counter_name: u64,)+ } @@ -39,6 +43,7 @@ macro_rules! make_counters { $($default_counter_name,)+ $($exit_counter_name,)+ $($dynamic_send_counter_name,)+ + $($optimized_send_counter_name,)+ $($counter_name,)+ } @@ -48,6 +53,7 @@ macro_rules! make_counters { $( Counter::$default_counter_name => stringify!($default_counter_name).to_string(), )+ $( Counter::$exit_counter_name => stringify!($exit_counter_name).to_string(), )+ $( Counter::$dynamic_send_counter_name => stringify!($dynamic_send_counter_name).to_string(), )+ + $( Counter::$optimized_send_counter_name => stringify!($optimized_send_counter_name).to_string(), )+ $( Counter::$counter_name => stringify!($counter_name).to_string(), )+ } } @@ -60,6 +66,7 @@ macro_rules! make_counters { $( Counter::$default_counter_name => std::ptr::addr_of_mut!(counters.$default_counter_name), )+ $( Counter::$exit_counter_name => std::ptr::addr_of_mut!(counters.$exit_counter_name), )+ $( Counter::$dynamic_send_counter_name => std::ptr::addr_of_mut!(counters.$dynamic_send_counter_name), )+ + $( Counter::$optimized_send_counter_name => std::ptr::addr_of_mut!(counters.$optimized_send_counter_name), )+ $( Counter::$counter_name => std::ptr::addr_of_mut!(counters.$counter_name), )+ } } @@ -80,6 +87,11 @@ macro_rules! make_counters { $( Counter::$dynamic_send_counter_name, )+ ]; + /// List of other counters that are summed as optimized_send_count. + pub const OPTIMIZED_SEND_COUNTERS: &'static [Counter] = &[ + $( Counter::$optimized_send_counter_name, )+ + ]; + /// List of other counters that are available only for --zjit-stats. pub const OTHER_COUNTERS: &'static [Counter] = &[ $( Counter::$counter_name, )+ @@ -140,6 +152,13 @@ make_counters! { send_fallback_not_optimized_instruction, } + // Optimized send counters that are summed as optimized_send_count + optimized_send { + iseq_optimized_send_count, + inline_cfunc_optimized_send_count, + variadic_cfunc_optimized_send_count, + } + // compile_error_: Compile error reasons compile_error_iseq_stack_too_large, compile_error_exception_handler, @@ -421,6 +440,16 @@ pub extern "C" fn rb_zjit_stats(_ec: EcPtr, _self: VALUE, target_key: VALUE) -> } set_stat_usize!(hash, "dynamic_send_count", dynamic_send_count); + // Set optimized send counters + let mut optimized_send_count = 0; + for &counter in OPTIMIZED_SEND_COUNTERS { + let count = unsafe { *counter_ptr(counter) }; + optimized_send_count += count; + set_stat_usize!(hash, &counter.name(), count); + } + set_stat_usize!(hash, "optimized_send_count", optimized_send_count); + set_stat_usize!(hash, "send_count", dynamic_send_count + optimized_send_count); + // Set send fallback counters for NotOptimizedInstruction let send_fallback_counters = ZJITState::get_send_fallback_counters(); for (op_idx, count) in send_fallback_counters.iter().enumerate().take(VM_INSTRUCTION_SIZE as usize) { From df90a645d41d831431bff97ca53c8b61585c40c8 Mon Sep 17 00:00:00 2001 From: Aiden Fox Ivey Date: Wed, 1 Oct 2025 00:20:26 -0400 Subject: [PATCH 4/4] ZJIT: Use Marshal.dump to handle large writes `File.binwrite` with a big string can exceed the `INT_MAX` limit of write(2) and fail with an exception. --- zjit.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zjit.rb b/zjit.rb index ab5bae719a333e..b84f2a4af63731 100644 --- a/zjit.rb +++ b/zjit.rb @@ -126,7 +126,9 @@ def dump_exit_locations(filename) raise ArgumentError, "--zjit-trace-exits must be enabled to use dump_exit_locations." end - File.binwrite(filename, Marshal.dump(RubyVM::ZJIT.exit_locations)) + File.open(filename, "wb") do |file| + Marshal.dump(RubyVM::ZJIT.exit_locations, file) + end end # Check if `--zjit-stats` is used