Repository navigation
GH-112354: Initial implementation of warm up on exits and trace-stitching #114142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1975b4c
9fb97f7
f9aa235
1288258
7c6267a
55c48e8
8b3c2e0
92a3b61
e3def48
87e544b
2172d68
4448793
c70f12f
d73fe0a
5c8f0bd
140486b
3362c93
63fe653
b0991a7
625bce2
e191fd7
941a14c
cfd3285
1025495
171dad7
e6ca3fe
308b2a7
518143e
9d8cab8
bf07dad
19b6b84
c959e8f
f393ba5
bd66b01
fe75484
3d0110c
de93130
77a6740
0a61d29
b3e306d
8f3aa33
7c84967
8ee6710
f37d7fc
1f8967d
8e4c601
4eb2cfc
ebe804f
c38d4e8
830eb4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4087,11 +4087,11 @@ dummy_func( | |
| TIER_TWO_ONLY | ||
| assert(current_executor->trace[0].opcode != _COLD_EXIT); | ||
| _PyExitData *exit = ¤t_executor->exits[oparg]; | ||
|
markshannon marked this conversation as resolved.
Outdated
|
||
| exit->hotness++; | ||
| exit->temperature++; | ||
| assert(exit->executor->trace[0].opcode == _COLD_EXIT); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you assert here that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, |
||
| PyCodeObject *code = _PyFrame_GetCode(frame); | ||
| _Py_CODEUNIT *target = _PyCode_CODE(code) + exit->target; | ||
| if (exit->hotness < 0) { | ||
| if (exit->temperature < 0) { | ||
| next_instr = target; | ||
| Py_DECREF(current_executor); | ||
| current_executor = NULL; | ||
|
|
@@ -4104,7 +4104,7 @@ dummy_func( | |
| } else { | ||
| int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor); | ||
| if (optimized <= 0) { | ||
| exit->hotness = -10000; /* Choose a better number */ | ||
| exit->temperature = -10000; /* Choose a better number */ | ||
| Py_DECREF(current_executor); | ||
| current_executor = NULL; | ||
| next_instr = target; | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -812,7 +812,7 @@ PyTypeObject _ColdExit_Type = { | |
| .tp_methods = executor_methods, | ||
| }; | ||
|
|
||
| static _PyColdExitObject COLD_EXITS[UOP_MAX_TRACE_LENGTH]; | ||
| static const _PyColdExitObject COLD_EXITS[UOP_MAX_TRACE_LENGTH]; | ||
|
|
||
| static _PyExecutorObject * | ||
| allocate_executor(int exit_count, int length) | ||
|
|
@@ -855,38 +855,38 @@ make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies) | |
| /* Initialize exits */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe note that |
||
| for (int i = 0; i < exit_count; i++) { | ||
| executor->exits[i].executor = (_PyExecutorObject *)&COLD_EXITS[i]; | ||
| executor->exits[i].hotness = -67; | ||
| executor->exits[i].temperature = -67; | ||
| } | ||
| int next_exit = exit_count-1; | ||
| int dest = length; | ||
| _PyUOpInstruction *dest = (_PyUOpInstruction *)&executor->trace[length]; | ||
| /* Scan backwards, so that we see the destinations of jumps before the jumps themselves. */ | ||
|
markshannon marked this conversation as resolved.
|
||
| for (int i = UOP_MAX_TRACE_LENGTH-1; i >= 0; i--) { | ||
| if (!BIT_IS_SET(used, i)) { | ||
| continue; | ||
| } | ||
| executor->trace[dest] = buffer[i]; | ||
| *dest = buffer[i]; | ||
| int opcode = buffer[i].opcode; | ||
| if (opcode == _POP_JUMP_IF_FALSE || | ||
| opcode == _POP_JUMP_IF_TRUE) | ||
| { | ||
| /* The oparg of the target will already have been set to its new offset */ | ||
| int oparg = executor->trace[dest].oparg; | ||
| executor->trace[dest].oparg = buffer[oparg].oparg; | ||
| int oparg = dest->oparg; | ||
| dest->oparg = buffer[oparg].oparg; | ||
| } | ||
| if (_PyUop_Flags[opcode] & HAS_EXIT_FLAG) { | ||
| executor->exits[next_exit].target = buffer[i].target; | ||
| executor->trace[dest].target = next_exit; | ||
| dest->target = next_exit; | ||
| next_exit--; | ||
| } | ||
| /* Set the oparg to be the destination offset, | ||
| * so that we can set the oparg of earlier jumps correctly. */ | ||
| buffer[i].oparg = dest; | ||
| buffer[i].oparg = dest - executor->trace; | ||
|
markshannon marked this conversation as resolved.
Outdated
|
||
| dest--; | ||
| } | ||
| assert(next_exit == -1); | ||
| assert(dest == 0); | ||
| executor->trace[0].opcode = _START_EXECUTOR; | ||
| executor->trace[0].operand = (uintptr_t)executor; | ||
| assert(dest == executor->trace); | ||
| dest->opcode = _START_EXECUTOR; | ||
| dest->operand = (uintptr_t)executor; | ||
| _Py_ExecutorInit(executor, dependencies); | ||
| #ifdef Py_DEBUG | ||
| char *python_lltrace = Py_GETENV("PYTHON_LLTRACE"); | ||
|
|
@@ -1247,7 +1247,7 @@ print("};") | |
|
|
||
| static_assert(UOP_MAX_TRACE_LENGTH == 512, "COLD_EXITS must be regenerated"); | ||
|
|
||
| static _PyColdExitObject COLD_EXITS[] = { | ||
| static const _PyColdExitObject COLD_EXITS[] = { | ||
| [0] = { .base = { PyVarObject_HEAD_INIT(&_ColdExit_Type, 0) .vm_data = { 0 }, .trace = &COLD_EXITS[0].uop }, .uop.opcode = _COLD_EXIT, .uop.oparg = 0 }, | ||
| [1] = { .base = { PyVarObject_HEAD_INIT(&_ColdExit_Type, 0) .vm_data = { 0 }, .trace = &COLD_EXITS[1].uop }, .uop.opcode = _COLD_EXIT, .uop.oparg = 1 }, | ||
| [2] = { .base = { PyVarObject_HEAD_INIT(&_ColdExit_Type, 0) .vm_data = { 0 }, .trace = &COLD_EXITS[2].uop }, .uop.opcode = _COLD_EXIT, .uop.oparg = 2 }, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.