Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6c97cb6
Add counter to RESUME
Fidget-Spinner Dec 29, 2025
5ce4d20
Fix dis, implement jit, broken for async for loops
Fidget-Spinner Dec 29, 2025
159601c
Fix all remaining bugs
Fidget-Spinner Dec 29, 2025
9f28e87
Up the resume value to 7918
Fidget-Spinner Dec 30, 2025
16205d7
remove control flow, allow RESUME_CHECK_JIT
Fidget-Spinner Dec 30, 2025
86f886b
fix broken tests, fix EXTENDED_ARG
Fidget-Spinner Dec 30, 2025
2304a2d
Fix another bug
Fidget-Spinner Dec 30, 2025
6b65f76
link everythihng
Fidget-Spinner Dec 30, 2025
d84384d
Revert "link everythihng"
Fidget-Spinner Dec 30, 2025
e29ced3
add back is_control_flow
Fidget-Spinner Dec 30, 2025
6bbd9cc
undo changes, turn off RESUME tracing for now
Fidget-Spinner Dec 30, 2025
a4e3e5f
temporary
Fidget-Spinner Dec 30, 2025
ff0e9f0
reduce diff
Fidget-Spinner Dec 30, 2025
90e76f8
add back _JIT (still off)
Fidget-Spinner Dec 30, 2025
81aa269
restore RESUME_CHECK_JIT jitting
Fidget-Spinner Dec 30, 2025
d52a106
only link up traces when they're backwards jumps
Fidget-Spinner Dec 30, 2025
3233423
stop tracing when we hit an ENTER_EXECUTOR
Fidget-Spinner Dec 30, 2025
e4e1cc0
re-enable old opt
Fidget-Spinner Dec 30, 2025
19f390a
partially disable opt
Fidget-Spinner Dec 30, 2025
be25244
formatting fix
Fidget-Spinner Dec 30, 2025
98c21be
fix an off-by-one
Fidget-Spinner Dec 30, 2025
dc0c71c
format
Fidget-Spinner Dec 30, 2025
73681af
up the resume initial value a little
Fidget-Spinner Dec 30, 2025
55cf943
fix RESUME slowness
Fidget-Spinner Dec 31, 2025
2e5e9e6
fix infinite deopt involving monitoring
Fidget-Spinner Dec 31, 2025
96ea93a
edit comment
Fidget-Spinner Dec 31, 2025
5cec130
trace over RESUME/RESUME_CHECK_JIT
Fidget-Spinner Dec 31, 2025
2373aee
trace over everything except backwards jumps
Fidget-Spinner Dec 31, 2025
fafd6c0
make RESUME tracing a single attempt
Fidget-Spinner Dec 31, 2025
564677c
fix recursive generators slowdown
Fidget-Spinner Dec 31, 2025
176e78b
Don't trace underflows for RESUMEs
Fidget-Spinner Dec 31, 2025
9cf52ff
Merge remote-tracking branch 'upstream/main' into resume_tracing
Fidget-Spinner Mar 13, 2026
cb15c9a
cleanup
Fidget-Spinner Mar 13, 2026
1e793f9
more cleanup
Fidget-Spinner Mar 13, 2026
bfb7d47
fix bugs and use opt config
Fidget-Spinner Mar 13, 2026
8472a93
fix test_dis
Fidget-Spinner Mar 13, 2026
e8a5867
bugfixes and cleanups
Fidget-Spinner Mar 13, 2026
400bdcb
trace over RESUME
Fidget-Spinner Mar 13, 2026
b044f13
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 13, 2026
5013a83
fix non-jit builds
Fidget-Spinner Mar 13, 2026
5032630
Merge branch 'resume_tracing' of github.com:Fidget-Spinner/cpython in…
Fidget-Spinner Mar 13, 2026
af09d44
fix test_opt
Fidget-Spinner Mar 13, 2026
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
14 changes: 14 additions & 0 deletions Include/internal/pycore_backoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ initial_jump_backoff_counter(_PyOptimizationConfig *opt_config)
opt_config->jump_backward_initial_backoff);
}

// This needs to be around 2-4x of JUMP_BACKWARD_INITIAL_VALUE
// The reasoning is that we always want loop traces to form and inline
// functions before functions themselves warm up and link to them instead
// of inlining.
#define RESUME_INITIAL_VALUE 8190
#define RESUME_INITIAL_BACKOFF 6
static inline _Py_BackoffCounter
initial_resume_backoff_counter(_PyOptimizationConfig *opt_config)
{
return make_backoff_counter(
opt_config->resume_initial_value,
opt_config->resume_initial_backoff);
}

/* Initial exit temperature.
* Must be larger than ADAPTIVE_COOLDOWN_VALUE,
* otherwise when a side exit warms up we may construct
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ PyAPI_FUNC(void) _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
PyAPI_FUNC(void) _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
PyAPI_FUNC(void) _Py_GatherStats_GetIter(_PyStackRef iterable);
PyAPI_FUNC(void) _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr);
PyAPI_FUNC(void) _Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate);

// Utility functions for reading/writing 32/64-bit values in the inline caches.
// Great care should be taken to ensure that these functions remain correct and
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ typedef struct _PyOptimizationConfig {
uint16_t jump_backward_initial_value;
uint16_t jump_backward_initial_backoff;

uint16_t resume_initial_value;
uint16_t resume_initial_backoff;

// JIT optimization thresholds
uint16_t side_exit_initial_value;
uint16_t side_exit_initial_backoff;
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ Known values:
Python 3.15a4 3659 (Add CALL_FUNCTION_EX specialization)
Python 3.15a4 3660 (Change generator preamble code)
Python 3.15a4 3661 (Lazy imports IMPORT_NAME opcode changes)
Python 3.15a6 3662 (Add counter to RESUME)


Python 3.16 will start with 3700
Expand All @@ -305,7 +306,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3661
#define PYC_MAGIC_NUMBER 3662
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
18 changes: 12 additions & 6 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_uop.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct _PyUOpInstruction{
} _PyUOpInstruction;

// This is the length of the trace we translate initially.
#ifdef Py_DEBUG
#if defined(Py_DEBUG) && defined(_Py_JIT)
// With asserts, the stencils are a lot larger
#define UOP_MAX_TRACE_LENGTH 1000
#else
Expand Down
Loading
Loading