Skip to content

Commit

Permalink
MJIT: Remove obsoleted MJIT counters
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Dec 7, 2022
1 parent 12916e2 commit 57cb4a8
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 77 deletions.
12 changes: 1 addition & 11 deletions debug_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ void
ruby_debug_counter_reset(void)
{
for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) {
switch (i) {
case RB_DEBUG_COUNTER_mjit_length_unit_queue:
case RB_DEBUG_COUNTER_mjit_length_active_units:
case RB_DEBUG_COUNTER_mjit_length_compact_units:
case RB_DEBUG_COUNTER_mjit_length_stale_units:
// These counters may be decreased and should not be reset.
break;
default:
rb_debug_counter[i] = 0;
break;
}
rb_debug_counter[i] = 0;
}
}

Expand Down
24 changes: 0 additions & 24 deletions debug_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,30 +346,6 @@ RB_DEBUG_COUNTER(vm_sync_lock_enter_nb)
RB_DEBUG_COUNTER(vm_sync_lock_enter_cr)
RB_DEBUG_COUNTER(vm_sync_barrier)

/* MJIT <-> VM frame push counts */
RB_DEBUG_COUNTER(mjit_frame_VM2VM)
RB_DEBUG_COUNTER(mjit_frame_VM2JT)
RB_DEBUG_COUNTER(mjit_frame_JT2JT)
RB_DEBUG_COUNTER(mjit_frame_JT2VM)

/* MJIT cancel counters */
RB_DEBUG_COUNTER(mjit_cancel)
RB_DEBUG_COUNTER(mjit_cancel_ivar_inline)
RB_DEBUG_COUNTER(mjit_cancel_exivar_inline)
RB_DEBUG_COUNTER(mjit_cancel_send_inline)
RB_DEBUG_COUNTER(mjit_cancel_opt_insn) /* CALL_SIMPLE_METHOD */
RB_DEBUG_COUNTER(mjit_cancel_invalidate_all)
RB_DEBUG_COUNTER(mjit_cancel_leave)

/* rb_mjit_unit_list length */
RB_DEBUG_COUNTER(mjit_length_unit_queue)
RB_DEBUG_COUNTER(mjit_length_active_units)
RB_DEBUG_COUNTER(mjit_length_compact_units)
RB_DEBUG_COUNTER(mjit_length_stale_units)

/* Other MJIT counters */
RB_DEBUG_COUNTER(mjit_compile_failures)

/* load (not implemented yet) */
/*
RB_DEBUG_COUNTER(load_files)
Expand Down
9 changes: 0 additions & 9 deletions lib/mjit/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ def compile_send(insn, stack_size, sp_inc, local_stack_p, pos, next_pos, status,
if !pc_moved_p
src << " reg_cfp->pc = original_body_iseq + #{next_pos};\n"
end
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_invalidate_all);\n"
src << " goto cancel;\n"
src << " }\n"
end
Expand Down Expand Up @@ -496,7 +495,6 @@ def compile_insn_default(insn, stack_size, sp_inc, local_stack_p, pos, next_pos,
if !pc_moved_p
src << " reg_cfp->pc = original_body_iseq + #{next_pos};\n"
end
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_invalidate_all);\n"
src << " goto cancel;\n"
src << " }\n"
end
Expand Down Expand Up @@ -529,7 +527,6 @@ def compile_insn_body(src, insn, pos, next_pos, insn_len, local_stack_p, stack_s
src << " rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);\n"
src << " if (UNLIKELY(!mjit_call_p)) {\n"
src << " reg_cfp->sp = vm_base_ptr(reg_cfp) + #{stack_size};\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_invalidate_all);\n"
src << " goto cancel;\n"
src << " }\n"
src << " }\n"
Expand Down Expand Up @@ -567,7 +564,6 @@ def compile_insn_body(src, insn, pos, next_pos, insn_len, local_stack_p, stack_s
src << " reg_cfp->sp = vm_base_ptr(reg_cfp) + #{stack_size};\n"
end
src << " reg_cfp->pc = original_body_iseq + #{pos};\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_opt_insn);\n"
src << " goto cancel;\n"
when /\A(?<prefix>.+\b)INSN_LABEL\((?<name>[^)]+)\)(?<suffix>.+)\z/m
prefix, name, suffix = Regexp.last_match[:prefix], Regexp.last_match[:name], Regexp.last_match[:suffix]
Expand Down Expand Up @@ -636,7 +632,6 @@ def compile_pc_and_sp(src, insn, stack_size, sp_inc, local_stack_p, next_pos)
# Print the block to cancel inlined method call. It's supporting only `opt_send_without_block` for now.
def compile_inlined_cancel_handler(src, body, inline_context)
src << "\ncancel:\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel);\n"
src << " rb_mjit_recompile_inlining(original_iseq);\n"

# Swap pc/sp set on cancel with original pc/sp.
Expand Down Expand Up @@ -674,17 +669,14 @@ def compile_cancel_handler(src, body, status)
end

src << "\nsend_cancel:\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_send_inline);\n"
src << " rb_mjit_recompile_send(original_iseq);\n"
src << " goto cancel;\n"

src << "\nivar_cancel:\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_ivar_inline);\n"
src << " rb_mjit_recompile_ivar(original_iseq);\n"
src << " goto cancel;\n"

src << "\nexivar_cancel:\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel_exivar_inline);\n"
src << " rb_mjit_recompile_exivar(original_iseq);\n"
src << " goto cancel;\n"

Expand All @@ -693,7 +685,6 @@ def compile_cancel_handler(src, body, status)
src << " goto cancel;\n"

src << "\ncancel:\n"
src << " RB_DEBUG_COUNTER_INC(mjit_cancel);\n"
if status.local_stack_p
(0...body.stack_max).each do |i|
src << " *(vm_base_ptr(reg_cfp) + #{i}) = stack[#{i}];\n"
Expand Down
32 changes: 0 additions & 32 deletions mjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,25 +306,13 @@ mjit_warning(const char *format, ...)
static void
add_to_list(struct rb_mjit_unit *unit, struct rb_mjit_unit_list *list)
{
(void)RB_DEBUG_COUNTER_INC_IF(mjit_length_unit_queue, list == &unit_queue);
(void)RB_DEBUG_COUNTER_INC_IF(mjit_length_active_units, list == &active_units);
(void)RB_DEBUG_COUNTER_INC_IF(mjit_length_compact_units, list == &compact_units);
(void)RB_DEBUG_COUNTER_INC_IF(mjit_length_stale_units, list == &stale_units);

ccan_list_add_tail(&list->head, &unit->unode);
list->length++;
}

static void
remove_from_list(struct rb_mjit_unit *unit, struct rb_mjit_unit_list *list)
{
#if USE_DEBUG_COUNTER
rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_unit_queue, -1, list == &unit_queue);
rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_active_units, -1, list == &active_units);
rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_compact_units, -1, list == &compact_units);
rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_stale_units, -1, list == &stale_units);
#endif

ccan_list_del(&unit->unode);
list->length--;
}
Expand Down Expand Up @@ -1906,22 +1894,6 @@ mjit_child_after_fork(void)
start_worker();
}

// Edit 0 to 1 to enable this feature for investigating hot methods
#define MJIT_COUNTER 0
#if MJIT_COUNTER
static void
mjit_dump_total_calls(void)
{
struct rb_mjit_unit *unit;
fprintf(stderr, "[MJIT_COUNTER] total_calls of active_units:\n");
ccan_list_for_each(&active_units.head, unit, unode) {
const rb_iseq_t *iseq = unit->iseq;
fprintf(stderr, "%8ld: %s@%s:%d\n", ISEQ_BODY(iseq)->total_calls, RSTRING_PTR(ISEQ_BODY(iseq)->location.label),
RSTRING_PTR(rb_iseq_path(iseq)), ISEQ_BODY(iseq)->location.first_lineno);
}
}
#endif

// Finish the threads processing units and creating PCH, finalize
// and free MJIT data. It should be called last during MJIT
// life.
Expand All @@ -1944,10 +1916,6 @@ mjit_finish(bool close_handle_p)
rb_native_cond_destroy(&mjit_worker_wakeup);
rb_native_cond_destroy(&mjit_gc_wakeup);

#if MJIT_COUNTER
mjit_dump_total_calls();
#endif

if (!mjit_opts.save_temps && getpid() == pch_owner_pid && pch_status == PCH_SUCCESS && !mjit_opts.custom)
remove_file(pch_file);

Expand Down
1 change: 0 additions & 1 deletion mjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

# if USE_MJIT

#include "debug_counter.h"
#include "ruby.h"
#include "vm_core.h"

Expand Down

0 comments on commit 57cb4a8

Please sign in to comment.