Skip to content

Commit

Permalink
YJIT: Remove all compilation events other than block compilation to s…
Browse files Browse the repository at this point in the history
…lim down the log.
  • Loading branch information
nirvdrum committed Oct 9, 2024
1 parent 59eb8fd commit 8b5e2bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 57 deletions.
7 changes: 2 additions & 5 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -9081,7 +9078,7 @@ fn get_class_name(class: Option<VALUE>) -> String {
}

/// Assemble "{class_name}#{method_name}" from a class pointer and a method ID
pub fn get_method_name(class: Option<VALUE>, mid: u64) -> String {
fn get_method_name(class: Option<VALUE>, mid: u64) -> String {
let class_name = get_class_name(class);
let method_name = if mid != 0 {
unsafe { cstr_to_rust_string(rb_id2name(mid)) }
Expand All @@ -9092,7 +9089,7 @@ pub fn get_method_name(class: Option<VALUE>, 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();
Expand Down
54 changes: 9 additions & 45 deletions yjit/src/compilation_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,37 +18,6 @@ pub struct CompilationLogEntry {
pub message: String,
}

#[derive(Clone, Debug)]
pub enum CompilationLogPayload {
BlockWithChain(BlockId, u8),
CFunc(Option<VALUE>, 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, "<cfunc> {}", get_method_name(*class, *method_id))
}

CompilationLogPayload::EntryPoint(block_id) => {
write!(f, "<entry> {}", 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)
Expand Down Expand Up @@ -78,31 +46,27 @@ 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<VALUE>, method_id: ID) {
Self::add_payload(CompilationLogPayload::CFunc(class, method_id))
}

fn add_payload(payload: CompilationLogPayload) {
if !Self::has_instance() {
return;
}

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 => {
Expand Down
7 changes: 0 additions & 7 deletions yjit/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 8b5e2bf

Please sign in to comment.