GH-117457: Correct pystats uop "miss" counts (GH-117477)

This commit is contained in:
Michael Droettboom 2024-04-04 18:49:18 -04:00 committed by GitHub
parent b5e60918af
commit 0edde64a41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 548 additions and 144 deletions

View file

@ -1083,7 +1083,6 @@ exit_to_tier1:
} }
#endif #endif
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist); OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(uopcode, miss);
Py_DECREF(current_executor); Py_DECREF(current_executor);
tstate->previous_executor = NULL; tstate->previous_executor = NULL;
DISPATCH(); DISPATCH();
@ -1091,7 +1090,6 @@ exit_to_tier1:
exit_to_trace: exit_to_trace:
assert(next_uop[-1].format == UOP_FORMAT_EXIT); assert(next_uop[-1].format == UOP_FORMAT_EXIT);
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist); OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(uopcode, miss);
uint32_t exit_index = next_uop[-1].exit_index; uint32_t exit_index = next_uop[-1].exit_index;
assert(exit_index < current_executor->exit_count); assert(exit_index < current_executor->exit_count);
_PyExitData *exit = &current_executor->exits[exit_index]; _PyExitData *exit = &current_executor->exits[exit_index];

File diff suppressed because it is too large Load diff

View file

@ -100,7 +100,10 @@ def tier2_replace_deopt(
out.emit(next(tkn_iter)) out.emit(next(tkn_iter))
emit_to(out, tkn_iter, "RPAREN") emit_to(out, tkn_iter, "RPAREN")
next(tkn_iter) # Semi colon next(tkn_iter) # Semi colon
out.emit(") JUMP_TO_JUMP_TARGET();\n") out.emit(") {\n")
out.emit("UOP_STAT_INC(uopcode, miss);\n")
out.emit("JUMP_TO_JUMP_TARGET();\n");
out.emit("}\n")
def tier2_replace_exit_if( def tier2_replace_exit_if(
@ -115,7 +118,10 @@ def tier2_replace_exit_if(
out.emit(next(tkn_iter)) out.emit(next(tkn_iter))
emit_to(out, tkn_iter, "RPAREN") emit_to(out, tkn_iter, "RPAREN")
next(tkn_iter) # Semi colon next(tkn_iter) # Semi colon
out.emit(") JUMP_TO_JUMP_TARGET();\n") out.emit(") {\n")
out.emit("UOP_STAT_INC(uopcode, miss);\n")
out.emit("JUMP_TO_JUMP_TARGET();\n")
out.emit("}\n")
def tier2_replace_oparg( def tier2_replace_oparg(

View file

@ -85,7 +85,7 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
// Locals that the instruction implementations expect to exist: // Locals that the instruction implementations expect to exist:
PATCH_VALUE(_PyExecutorObject *, current_executor, _JIT_EXECUTOR) PATCH_VALUE(_PyExecutorObject *, current_executor, _JIT_EXECUTOR)
int oparg; int oparg;
int opcode = _JIT_OPCODE; int uopcode = _JIT_OPCODE;
// Other stuff we need handy: // Other stuff we need handy:
PATCH_VALUE(uint16_t, _oparg, _JIT_OPARG) PATCH_VALUE(uint16_t, _oparg, _JIT_OPARG)
PATCH_VALUE(uint64_t, _operand, _JIT_OPERAND) PATCH_VALUE(uint64_t, _operand, _JIT_OPERAND)
@ -93,14 +93,14 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
PATCH_VALUE(uint16_t, _exit_index, _JIT_EXIT_INDEX) PATCH_VALUE(uint16_t, _exit_index, _JIT_EXIT_INDEX)
OPT_STAT_INC(uops_executed); OPT_STAT_INC(uops_executed);
UOP_STAT_INC(opcode, execution_count); UOP_STAT_INC(uopcode, execution_count);
// The actual instruction definitions (only one will be used): // The actual instruction definitions (only one will be used):
if (opcode == _JUMP_TO_TOP) { if (uopcode == _JUMP_TO_TOP) {
CHECK_EVAL_BREAKER(); CHECK_EVAL_BREAKER();
PATCH_JUMP(_JIT_TOP); PATCH_JUMP(_JIT_TOP);
} }
switch (opcode) { switch (uopcode) {
#include "executor_cases.c.h" #include "executor_cases.c.h"
default: default:
Py_UNREACHABLE(); Py_UNREACHABLE();
@ -113,11 +113,9 @@ error_tier_two:
GOTO_TIER_ONE(NULL); GOTO_TIER_ONE(NULL);
exit_to_tier1: exit_to_tier1:
tstate->previous_executor = (PyObject *)current_executor; tstate->previous_executor = (PyObject *)current_executor;
UOP_STAT_INC(opcode, miss);
GOTO_TIER_ONE(_PyCode_CODE(_PyFrame_GetCode(frame)) + _target); GOTO_TIER_ONE(_PyCode_CODE(_PyFrame_GetCode(frame)) + _target);
exit_to_trace: exit_to_trace:
{ {
UOP_STAT_INC(opcode, miss);
_PyExitData *exit = &current_executor->exits[_exit_index]; _PyExitData *exit = &current_executor->exits[_exit_index];
Py_INCREF(exit->executor); Py_INCREF(exit->executor);
tstate->previous_executor = (PyObject *)current_executor; tstate->previous_executor = (PyObject *)current_executor;