Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a08909d
Add executor_cases.c.h dependency for ceval.o
gvanrossum Nov 15, 2023
4c2914b
Clean up flags.py
gvanrossum Nov 15, 2023
053a0a2
Clean up parsing.py
gvanrossum Nov 15, 2023
b838435
Add back printing optimized uops
gvanrossum Nov 15, 2023
b28effa
Hacky way to make FOR_ITER a viable uop
gvanrossum Nov 15, 2023
de8f199
_SPECIALIZE_UNPACK_SEQUENCE is TIER_ONE_ONLY
gvanrossum Nov 16, 2023
5c5d8bd
NEWS
gvanrossum Nov 16, 2023
36e9ada
Double max trace length to 256
gvanrossum Nov 16, 2023
def1830
Move stuff around to suit the JIT branch
gvanrossum Nov 16, 2023
ce19637
Merge remote-tracking branch 'origin/main' into for-iter-uop
gvanrossum Nov 17, 2023
7096818
Clean up _FOR_ITER_TIER_TWO using DEOPT_IF(true)
gvanrossum Nov 17, 2023
5852105
Add test
gvanrossum Nov 17, 2023
4ac68b3
Revert debug change to is_viable_uop()
gvanrossum Nov 17, 2023
95b1a01
Avoid debug-only local variable 'word'
gvanrossum Nov 17, 2023
4c72028
Revert changes to _EXIT_TRACE logic
gvanrossum Nov 17, 2023
14aea56
Merge remote-tracking branch 'origin/main' into for-iter-uop
gvanrossum Nov 17, 2023
88c1701
Merge branch 'main' into for-iter-uop
gvanrossum Nov 18, 2023
3f0df1a
Double max trace length to 512
gvanrossum Nov 19, 2023
b11b8ea
Faster uops: do away with 'operand' variable
gvanrossum Nov 19, 2023
a2c4f00
Do the same for 'oparg' -- another 4% speedup
gvanrossum Nov 19, 2023
ddba5ed
Use CURRENT_OPARG() and CURRENT_OPERAND() macros
gvanrossum Nov 20, 2023
0fae4e6
(Theoretically) improve 'Unknown uop' message
gvanrossum Nov 20, 2023
9ea707b
Merge branch 'main' into faster-uops
gvanrossum Nov 20, 2023
7c1f6d4
Add news
gvanrossum Nov 20, 2023
1d1f146
Fix backticks (as always)
gvanrossum Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_uops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

#include "pycore_frame.h" // _PyInterpreterFrame

#define _Py_UOP_MAX_TRACE_LENGTH 256
#define _Py_UOP_MAX_TRACE_LENGTH 512

typedef struct {
uint16_t opcode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Slightly optimize the Tier 2 (uop) interpreter by only loading ``oparg`` and
``operand`` when needed. Also double the trace size limit again, to 512 this
time.
16 changes: 7 additions & 9 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,21 +994,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int

OPT_STAT_INC(traces_executed);
_PyUOpInstruction *next_uop = current_executor->trace;
uint64_t operand;
#ifdef Py_STATS
uint64_t trace_uop_execution_counter = 0;
#endif

for (;;) {
opcode = next_uop->opcode;
oparg = next_uop->oparg;
operand = next_uop->operand;
DPRINTF(3,
"%4d: uop %s, oparg %d, operand %" PRIu64 ", target %d, stack_level %d\n",
(int)(next_uop - current_executor->trace),
_PyUopName(opcode),
oparg,
operand,
next_uop->oparg,
next_uop->operand,
next_uop->target,
(int)(stack_pointer - _PyFrame_Stackbase(frame)));
next_uop++;
Expand All @@ -1025,8 +1022,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
default:
#ifdef Py_DEBUG
{
fprintf(stderr, "Unknown uop %d, oparg %d, operand %" PRIu64 "\n",
opcode, oparg, operand);
fprintf(stderr, "Unknown uop %d, oparg %d, operand %" PRIu64 " @ %d\n",
opcode, next_uop[-1].oparg, next_uop[-1].operand,
(int)(next_uop - current_executor->trace - 1));
Py_FatalError("Unknown uop");
}
#else
Expand Down Expand Up @@ -1055,7 +1053,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
STACK_SHRINK(1);
error_tier_two:
DPRINTF(2, "Error: [Uop %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d]\n",
opcode, _PyUopName(opcode), oparg, operand, next_uop[-1].target,
opcode, _PyUopName(opcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
(int)(next_uop - current_executor->trace - 1));
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
frame->return_offset = 0; // Don't leave this random
Expand All @@ -1068,7 +1066,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
// On DEOPT_IF we just repeat the last instruction.
// This presumes nothing was popped from the stack (nor pushed).
DPRINTF(2, "DEOPT: [Uop %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d]\n",
opcode, _PyUopName(opcode), oparg, operand, next_uop[-1].target,
opcode, _PyUopName(opcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
(int)(next_uop - current_executor->trace - 1));
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(opcode, miss);
Expand Down
4 changes: 4 additions & 0 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,7 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
#define GOTO_TIER_TWO() goto enter_tier_two;

#define GOTO_TIER_ONE() goto exit_trace;

#define CURRENT_OPARG() (next_uop[-1].oparg)

#define CURRENT_OPERAND() (next_uop[-1].operand)
Loading