YJIT: add iseq_alloc_count to stats (#10398)

* YJIT: add iseq_alloc_count to stats

* Remove an empty line

---------

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
This commit is contained in:
Maxime Chevalier-Boisvert 2024-03-28 15:21:09 -04:00 committed by GitHub
parent a8f902ea8e
commit bb3cbdfe2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -999,6 +999,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
#if USE_YJIT
rb_yjit_live_iseq_count++;
rb_yjit_iseq_alloc_count++;
#endif
return COMPILE_OK;

1
yjit.h
View File

@ -28,6 +28,7 @@
extern uint64_t rb_yjit_call_threshold;
extern uint64_t rb_yjit_cold_threshold;
extern uint64_t rb_yjit_live_iseq_count;
extern uint64_t rb_yjit_iseq_alloc_count;
extern bool rb_yjit_enabled_p;
void rb_yjit_incr_counter(const char *counter_name);
void rb_yjit_invalidate_all_method_lookup_assumptions(void);

View File

@ -346,6 +346,7 @@ module RubyVM::YJIT
out.puts "bindings_set: " + format_number(13, stats[:binding_set])
out.puts "compilation_failure: " + format_number(13, compilation_failure) if compilation_failure != 0
out.puts "live_iseq_count: " + format_number(13, stats[:live_iseq_count])
out.puts "iseq_alloc_count: " + format_number(13, stats[:iseq_alloc_count])
out.puts "compiled_iseq_entry: " + format_number(13, stats[:compiled_iseq_entry])
out.puts "cold_iseq_entry: " + format_number_pct(13, stats[:cold_iseq_entry], stats[:compiled_iseq_entry] + stats[:cold_iseq_entry])
out.puts "compiled_iseq_count: " + format_number(13, stats[:compiled_iseq_count])

View File

@ -15,10 +15,14 @@ use crate::cruby::*;
use crate::options::*;
use crate::yjit::yjit_enabled_p;
/// A running total of how many ISeqs are in the system.
/// Running total of how many ISeqs are in the system.
#[no_mangle]
pub static mut rb_yjit_live_iseq_count: u64 = 0;
/// Monotonically increasing total of how many ISEQs were allocated
#[no_mangle]
pub static mut rb_yjit_iseq_alloc_count: u64 = 0;
/// A middleware to count Rust-allocated bytes as yjit_alloc_size.
#[global_allocator]
static GLOBAL_ALLOCATOR: StatsAlloc = StatsAlloc { alloc_size: AtomicUsize::new(0) };
@ -748,6 +752,7 @@ fn rb_yjit_gen_stats_dict(context: bool) -> VALUE {
hash_aset_usize!(hash, "vm_insns_count", rb_vm_insns_count as usize);
hash_aset_usize!(hash, "live_iseq_count", rb_yjit_live_iseq_count as usize);
hash_aset_usize!(hash, "iseq_alloc_count", rb_yjit_iseq_alloc_count as usize);
}
// If we're not generating stats, put only default counters