File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -389,7 +389,9 @@ def _print_stats(out: $stderr) # :nodoc:
389389 end
390390 out . puts "max_inline_versions: " + format_number ( 13 , stats [ :max_inline_versions ] )
391391 out . puts "compiled_branch_count: " + format_number ( 13 , stats [ :compiled_branch_count ] )
392- out . puts "compile_time_ms: " + format_number ( 13 , stats [ :compile_time_ns ] / ( 1000 * 1000 ) )
392+
393+ out . puts "yjit_active_ms: " + format_number ( 13 , stats [ :yjit_active_ns ] / 10 **6 )
394+ out . puts "compile_time_ms: " + format_number_pct ( 13 , stats [ :compile_time_ns ] / 10 **6 , stats [ :yjit_active_ns ] / 10 **6 )
393395 out . puts "block_next_count: " + format_number ( 13 , stats [ :block_next_count ] )
394396 out . puts "defer_count: " + format_number ( 13 , stats [ :defer_count ] )
395397 out . puts "defer_empty_count: " + format_number ( 13 , stats [ :defer_empty_count ] )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use std::collections::HashMap;
1212use crate :: codegen:: CodegenGlobals ;
1313use crate :: cruby:: * ;
1414use crate :: options:: * ;
15- use crate :: yjit:: yjit_enabled_p;
15+ use crate :: yjit:: { yjit_enabled_p, YJIT_INIT_TIME } ;
1616
1717/// Running total of how many ISeqs are in the system.
1818#[ no_mangle]
@@ -797,6 +797,10 @@ fn rb_yjit_gen_stats_dict(key: VALUE) -> VALUE {
797797 set_stat_usize ! ( hash, "iseq_alloc_count" , rb_yjit_iseq_alloc_count as usize ) ;
798798
799799 set_stat ! ( hash, "object_shape_count" , rb_object_shape_count( ) ) ;
800+
801+ // Time since YJIT init in nanoseconds
802+ let time_nanos = Instant :: now ( ) . duration_since ( YJIT_INIT_TIME . unwrap ( ) ) . as_nanos ( ) ;
803+ set_stat_usize ! ( hash, "yjit_active_ns" , time_nanos as usize ) ;
800804 }
801805
802806 // If we're not generating stats, put only default counters
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use crate::stats::incr_counter;
88use crate :: stats:: with_compile_time;
99
1010use std:: os:: raw:: { c_char, c_int} ;
11+ use std:: time:: Instant ;
1112use crate :: log:: Log ;
1213
1314/// Is YJIT on? The interpreter uses this variable to decide whether to trigger
@@ -16,6 +17,9 @@ use crate::log::Log;
1617#[ no_mangle]
1718pub static mut rb_yjit_enabled_p: bool = false ;
1819
20+ // Time when YJIT was yjit was initialized (see yjit_init)
21+ pub static mut YJIT_INIT_TIME : Option < Instant > = None ;
22+
1923/// Parse one command-line option.
2024/// This is called from ruby.c
2125#[ no_mangle]
@@ -76,6 +80,11 @@ fn yjit_init() {
7680 let _ = std:: fs:: remove_file ( & perf_map) ;
7781 println ! ( "YJIT perf map: {perf_map}" ) ;
7882 }
83+
84+ // Note the time when YJIT was initialized
85+ unsafe {
86+ YJIT_INIT_TIME = Some ( Instant :: now ( ) ) ;
87+ }
7988}
8089
8190#[ no_mangle]
You can’t perform that action at this time.
0 commit comments