Skip to content

Commit bb3cbdf

Browse files
maximecbk0kubun
andauthored
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>
1 parent a8f902e commit bb3cbdf

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
999999

10001000
#if USE_YJIT
10011001
rb_yjit_live_iseq_count++;
1002+
rb_yjit_iseq_alloc_count++;
10021003
#endif
10031004

10041005
return COMPILE_OK;

yjit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
extern uint64_t rb_yjit_call_threshold;
2929
extern uint64_t rb_yjit_cold_threshold;
3030
extern uint64_t rb_yjit_live_iseq_count;
31+
extern uint64_t rb_yjit_iseq_alloc_count;
3132
extern bool rb_yjit_enabled_p;
3233
void rb_yjit_incr_counter(const char *counter_name);
3334
void rb_yjit_invalidate_all_method_lookup_assumptions(void);

yjit.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ def _print_stats(out: $stderr) # :nodoc:
346346
out.puts "bindings_set: " + format_number(13, stats[:binding_set])
347347
out.puts "compilation_failure: " + format_number(13, compilation_failure) if compilation_failure != 0
348348
out.puts "live_iseq_count: " + format_number(13, stats[:live_iseq_count])
349+
out.puts "iseq_alloc_count: " + format_number(13, stats[:iseq_alloc_count])
349350
out.puts "compiled_iseq_entry: " + format_number(13, stats[:compiled_iseq_entry])
350351
out.puts "cold_iseq_entry: " + format_number_pct(13, stats[:cold_iseq_entry], stats[:compiled_iseq_entry] + stats[:cold_iseq_entry])
351352
out.puts "compiled_iseq_count: " + format_number(13, stats[:compiled_iseq_count])

yjit/src/stats.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ use crate::cruby::*;
1515
use crate::options::*;
1616
use crate::yjit::yjit_enabled_p;
1717

18-
/// A running total of how many ISeqs are in the system.
18+
/// Running total of how many ISeqs are in the system.
1919
#[no_mangle]
2020
pub static mut rb_yjit_live_iseq_count: u64 = 0;
2121

22+
/// Monotonically increasing total of how many ISEQs were allocated
23+
#[no_mangle]
24+
pub static mut rb_yjit_iseq_alloc_count: u64 = 0;
25+
2226
/// A middleware to count Rust-allocated bytes as yjit_alloc_size.
2327
#[global_allocator]
2428
static GLOBAL_ALLOCATOR: StatsAlloc = StatsAlloc { alloc_size: AtomicUsize::new(0) };
@@ -748,6 +752,7 @@ fn rb_yjit_gen_stats_dict(context: bool) -> VALUE {
748752
hash_aset_usize!(hash, "vm_insns_count", rb_vm_insns_count as usize);
749753

750754
hash_aset_usize!(hash, "live_iseq_count", rb_yjit_live_iseq_count as usize);
755+
hash_aset_usize!(hash, "iseq_alloc_count", rb_yjit_iseq_alloc_count as usize);
751756
}
752757

753758
// If we're not generating stats, put only default counters

0 commit comments

Comments
 (0)