mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add counters for version invalidation reasons
I noticed that there were two st_table iterators that do exactly the same thing so I merged them into one.
This commit is contained in:
parent
e48fc07d11
commit
0a108601ef
4 changed files with 36 additions and 11 deletions
1
yjit.rb
1
yjit.rb
|
@ -160,6 +160,7 @@ module YJIT
|
||||||
print_counters(stats, prefix: 'oaref_', prompt: 'opt_aref exit reasons: ')
|
print_counters(stats, prefix: 'oaref_', prompt: 'opt_aref exit reasons: ')
|
||||||
print_counters(stats, prefix: 'expandarray_', prompt: 'expandarray exit reasons: ')
|
print_counters(stats, prefix: 'expandarray_', prompt: 'expandarray exit reasons: ')
|
||||||
print_counters(stats, prefix: 'opt_getinlinecache_', prompt: 'opt_getinlinecache exit reasons: ')
|
print_counters(stats, prefix: 'opt_getinlinecache_', prompt: 'opt_getinlinecache exit reasons: ')
|
||||||
|
print_counters(stats, prefix: 'invalidate_', prompt: 'invalidation reasons: ')
|
||||||
|
|
||||||
side_exits = total_exit_count(stats)
|
side_exits = total_exit_count(stats)
|
||||||
total_exits = side_exits + stats[:leave_interp_return]
|
total_exits = side_exits + stats[:leave_interp_return]
|
||||||
|
|
|
@ -4079,7 +4079,7 @@ gen_opt_getinlinecache(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
|
||||||
// Cache is keyed on a certain lexical scope. Use the interpreter's cache.
|
// Cache is keyed on a certain lexical scope. Use the interpreter's cache.
|
||||||
uint8_t *side_exit = yjit_side_exit(jit, ctx);
|
uint8_t *side_exit = yjit_side_exit(jit, ctx);
|
||||||
|
|
||||||
// Call function to verify the cache
|
// Call function to verify the cache. It doesn't allocate or call methods.
|
||||||
bool rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep);
|
bool rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep);
|
||||||
mov(cb, C_ARG_REGS[0], const_ptr_opnd((void *)ic));
|
mov(cb, C_ARG_REGS[0], const_ptr_opnd((void *)ic));
|
||||||
mov(cb, C_ARG_REGS[1], member_opnd(REG_CFP, rb_control_frame_t, ep));
|
mov(cb, C_ARG_REGS[1], member_opnd(REG_CFP, rb_control_frame_t, ep));
|
||||||
|
|
37
yjit_iface.c
37
yjit_iface.c
|
@ -318,11 +318,13 @@ static const rb_data_type_t yjit_root_type = {
|
||||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// st_table iterator for invalidating blocks that are keys to the table.
|
||||||
static int
|
static int
|
||||||
block_set_invalidate_i(st_data_t key, st_data_t v, st_data_t ignore)
|
block_set_invalidate_i(st_data_t key, st_data_t v, st_data_t ignore)
|
||||||
{
|
{
|
||||||
block_t *version = (block_t *)key;
|
block_t *version = (block_t *)key;
|
||||||
|
|
||||||
|
// Thankfully, st_table supports deleting while iterating.
|
||||||
invalidate_block_version(version);
|
invalidate_block_version(version);
|
||||||
|
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
|
@ -348,6 +350,11 @@ rb_yjit_method_lookup_change(VALUE klass, ID mid)
|
||||||
rb_id_table_delete(id2blocks, mid);
|
rb_id_table_delete(id2blocks, mid);
|
||||||
|
|
||||||
st_table *block_set = (st_table *)blocks;
|
st_table *block_set = (st_table *)blocks;
|
||||||
|
|
||||||
|
#if YJIT_STATS
|
||||||
|
yjit_runtime_counters.invalidate_method_lookup += block_set->num_entries;
|
||||||
|
#endif
|
||||||
|
|
||||||
st_foreach(block_set, block_set_invalidate_i, 0);
|
st_foreach(block_set, block_set_invalidate_i, 0);
|
||||||
|
|
||||||
st_free_table(block_set);
|
st_free_table(block_set);
|
||||||
|
@ -374,6 +381,10 @@ rb_yjit_cme_invalidate(VALUE cme)
|
||||||
if (st_delete(cme_validity_dependency, &cme_as_st_data, &blocks)) {
|
if (st_delete(cme_validity_dependency, &cme_as_st_data, &blocks)) {
|
||||||
st_table *block_set = (st_table *)blocks;
|
st_table *block_set = (st_table *)blocks;
|
||||||
|
|
||||||
|
#if YJIT_STATS
|
||||||
|
yjit_runtime_counters.invalidate_method_lookup += block_set->num_entries;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Invalidate each block
|
// Invalidate each block
|
||||||
st_foreach(block_set, block_set_invalidate_i, 0);
|
st_foreach(block_set, block_set_invalidate_i, 0);
|
||||||
|
|
||||||
|
@ -569,19 +580,16 @@ iseq_end_index(VALUE self)
|
||||||
return INT2NUM(block->end_idx);
|
return INT2NUM(block->end_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
block_invalidation_iterator(st_data_t key, st_data_t value, st_data_t data) {
|
|
||||||
block_t *block = (block_t *)key;
|
|
||||||
invalidate_block_version(block); // Thankfully, st_table supports deleteing while iterating
|
|
||||||
return ST_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Called when a basic operation is redefined */
|
/* Called when a basic operation is redefined */
|
||||||
void
|
void
|
||||||
rb_yjit_bop_redefined(VALUE klass, const rb_method_entry_t *me, enum ruby_basic_operators bop)
|
rb_yjit_bop_redefined(VALUE klass, const rb_method_entry_t *me, enum ruby_basic_operators bop)
|
||||||
{
|
{
|
||||||
if (blocks_assuming_bops) {
|
if (blocks_assuming_bops) {
|
||||||
st_foreach(blocks_assuming_bops, block_invalidation_iterator, 0);
|
#if YJIT_STATS
|
||||||
|
yjit_runtime_counters.invalidate_bop_redefined += blocks_assuming_bops->num_entries;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
st_foreach(blocks_assuming_bops, block_set_invalidate_i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,10 +598,12 @@ void
|
||||||
rb_yjit_constant_state_changed(void)
|
rb_yjit_constant_state_changed(void)
|
||||||
{
|
{
|
||||||
if (blocks_assuming_stable_global_constant_state) {
|
if (blocks_assuming_stable_global_constant_state) {
|
||||||
st_foreach(blocks_assuming_stable_global_constant_state, block_invalidation_iterator, 0);
|
|
||||||
#if YJIT_STATS
|
#if YJIT_STATS
|
||||||
yjit_runtime_counters.constant_state_bumps++;
|
yjit_runtime_counters.constant_state_bumps++;
|
||||||
|
yjit_runtime_counters.invalidate_constant_state_bump += blocks_assuming_stable_global_constant_state->num_entries;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
st_foreach(blocks_assuming_stable_global_constant_state, block_set_invalidate_i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,6 +639,9 @@ yjit_constant_ic_update(const rb_iseq_t *iseq, IC ic)
|
||||||
rb_darray_for(getinlinecache_blocks, i) {
|
rb_darray_for(getinlinecache_blocks, i) {
|
||||||
block_t *block = rb_darray_get(getinlinecache_blocks, i);
|
block_t *block = rb_darray_get(getinlinecache_blocks, i);
|
||||||
invalidate_block_version(block);
|
invalidate_block_version(block);
|
||||||
|
#if YJIT_STATS
|
||||||
|
yjit_runtime_counters.invalidate_constant_ic_fill++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -642,7 +655,11 @@ void
|
||||||
rb_yjit_before_ractor_spawn(void)
|
rb_yjit_before_ractor_spawn(void)
|
||||||
{
|
{
|
||||||
if (blocks_assuming_single_ractor_mode) {
|
if (blocks_assuming_single_ractor_mode) {
|
||||||
st_foreach(blocks_assuming_single_ractor_mode, block_invalidation_iterator, 0);
|
#if YJIT_STATS
|
||||||
|
yjit_runtime_counters.invalidate_ractor_spawn += blocks_assuming_single_ractor_mode->num_entries;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
st_foreach(blocks_assuming_single_ractor_mode, block_set_invalidate_i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,14 @@ YJIT_DECLARE_COUNTERS(
|
||||||
vm_insns_count,
|
vm_insns_count,
|
||||||
compiled_iseq_count,
|
compiled_iseq_count,
|
||||||
compiled_block_count,
|
compiled_block_count,
|
||||||
|
|
||||||
invalidation_count,
|
invalidation_count,
|
||||||
|
invalidate_method_lookup,
|
||||||
|
invalidate_bop_redefined,
|
||||||
|
invalidate_ractor_spawn,
|
||||||
|
invalidate_constant_state_bump,
|
||||||
|
invalidate_constant_ic_fill,
|
||||||
|
|
||||||
constant_state_bumps,
|
constant_state_bumps,
|
||||||
|
|
||||||
expandarray_splat,
|
expandarray_splat,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue