From 8b5e2bfe14e141770f221f10c30f22cac9ace78c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 9 Oct 2024 01:43:07 -0400 Subject: [PATCH] YJIT: Remove all compilation events other than block compilation to slim down the log. --- yjit/src/codegen.rs | 7 ++--- yjit/src/compilation_log.rs | 54 +++++++------------------------------ yjit/src/core.rs | 7 ----- 3 files changed, 11 insertions(+), 57 deletions(-) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 43574eb678c47f..f1ac7958132830 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -6570,9 +6570,6 @@ fn gen_send_cfunc( perf_call!("gen_send_cfunc: ", known_cfunc_codegen(jit, asm, ci, cme, block, argc, recv_known_class)) }; - let method_id = unsafe { (*cme).called_id }; - CompilationLog::add_cfunc(recv_known_class, method_id); - if cfunc_codegen { assert_eq!(expected_stack_after, asm.ctx.get_stack_size() as i32); gen_counter_incr(jit, asm, Counter::num_send_cfunc_inline); @@ -9081,7 +9078,7 @@ fn get_class_name(class: Option) -> String { } /// Assemble "{class_name}#{method_name}" from a class pointer and a method ID -pub fn get_method_name(class: Option, mid: u64) -> String { +fn get_method_name(class: Option, mid: u64) -> String { let class_name = get_class_name(class); let method_name = if mid != 0 { unsafe { cstr_to_rust_string(rb_id2name(mid)) } @@ -9092,7 +9089,7 @@ pub fn get_method_name(class: Option, mid: u64) -> String { } /// Assemble "{label}@{iseq_path}:{lineno}" (iseq_inspect() format) from an ISEQ -pub fn get_iseq_name(iseq: IseqPtr) -> String { +fn get_iseq_name(iseq: IseqPtr) -> String { let c_string = unsafe { rb_yjit_iseq_inspect(iseq) }; let string = unsafe { CStr::from_ptr(c_string) }.to_str() .unwrap_or_else(|_| "not UTF-8").to_string(); diff --git a/yjit/src/compilation_log.rs b/yjit/src/compilation_log.rs index 61835b7fb83d16..e9845c3804aee6 100644 --- a/yjit/src/compilation_log.rs +++ b/yjit/src/compilation_log.rs @@ -2,7 +2,6 @@ use crate::core::BlockId; use crate::cruby::*; use crate::options::*; use crate::yjit::yjit_enabled_p; -use crate::codegen::get_method_name; use std::fmt::{Display, Formatter}; use std::os::raw::c_long; @@ -19,37 +18,6 @@ pub struct CompilationLogEntry { pub message: String, } -#[derive(Clone, Debug)] -pub enum CompilationLogPayload { - BlockWithChain(BlockId, u8), - CFunc(Option, ID), - EntryPoint(BlockId) -} - -impl Display for CompilationLogPayload { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - CompilationLogPayload::BlockWithChain(block_id, chain_depth) => { - let location = iseq_get_location(block_id.iseq, block_id.idx); - - if *chain_depth > 0 { - write!(f, "{} (chain_depth: {})", location, chain_depth) - } else { - write!(f, "{}", location) - } - } - - CompilationLogPayload::CFunc(class, method_id) => { - write!(f, " {}", get_method_name(*class, *method_id)) - } - - CompilationLogPayload::EntryPoint(block_id) => { - write!(f, " {}", block_id.iseq_name()) - } - } - } -} - impl Display for CompilationLogEntry { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{:15.6}: {}", self.timestamp, self.message) @@ -78,19 +46,7 @@ impl CompilationLog { } } - pub fn add_entry_point(block_id: BlockId) { - Self::add_payload(CompilationLogPayload::EntryPoint(block_id)) - } - pub fn add_block_with_chain_depth(block_id: BlockId, chain_depth: u8) { - Self::add_payload(CompilationLogPayload::BlockWithChain(block_id, chain_depth)) - } - - pub fn add_cfunc(class: Option, method_id: ID) { - Self::add_payload(CompilationLogPayload::CFunc(class, method_id)) - } - - fn add_payload(payload: CompilationLogPayload) { if !Self::has_instance() { return; } @@ -98,11 +54,19 @@ impl CompilationLog { let print_compilation_log = get_option!(print_compilation_log); let timestamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs_f64(); + let location = iseq_get_location(block_id.iseq, block_id.idx); + let message = if chain_depth > 0 { + format!("{} (chain_depth: {})", location, chain_depth) + } else { + format!("{}", location) + }; + let entry = CompilationLogEntry { timestamp, - message: payload.to_string() + message }; + if let Some(output) = print_compilation_log { match output { CompilationLogOutput::Stderr => { diff --git a/yjit/src/core.rs b/yjit/src/core.rs index a650f93fc0b6eb..8fb514da385c10 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -28,7 +28,6 @@ use std::ptr; use ptr::NonNull; use YARVOpnd::*; use TempMapping::*; -use crate::compilation_log::CompilationLog; use crate::invariants::*; // Maximum number of temp value types or registers we keep track of @@ -3049,10 +3048,6 @@ impl BlockId { pub fn dump_src_loc(&self) { unsafe { rb_yjit_dump_iseq_loc(self.iseq, self.idx as u32) } } - - pub fn iseq_name(&self) -> String { - get_iseq_name(self.iseq) - } } /// See [gen_block_series_body]. This simply counts compilation failures. @@ -3234,8 +3229,6 @@ pub fn gen_entry_point(iseq: IseqPtr, ec: EcPtr, jit_exception: bool) -> Option< // Count the number of entry points we compile incr_counter!(compiled_iseq_entry); - CompilationLog::add_entry_point(blockid); - // Compilation successful and block not empty code_ptr.map(|ptr| ptr.raw_ptr(cb)) }