Skip to content

Commit 1f3d3cd

Browse files
Merge remote-tracking branch 'upstream/main' into call_function_ex_py
2 parents c735d4a + c99f766 commit 1f3d3cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1777
-1388
lines changed

Doc/library/profiling.sampling.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,9 @@ interesting functions that highlights:
878878

879879
Use :option:`--no-summary` to suppress both the legend and summary sections.
880880

881-
To save pstats output to a file instead of stdout::
881+
To save pstats output to a binary file instead of stdout::
882882

883-
python -m profiling.sampling run -o profile.txt script.py
883+
python -m profiling.sampling run -o profile.pstats script.py
884884

885885
The pstats format supports several options for controlling the display.
886886
The :option:`--sort` option determines the column used for ordering results::
@@ -1455,7 +1455,9 @@ Output options
14551455

14561456
.. option:: --pstats
14571457

1458-
Generate text statistics output. This is the default.
1458+
Generate pstats statistics. This is the default.
1459+
When written to stdout, the output is a text table; with :option:`-o`,
1460+
it is a binary pstats file.
14591461

14601462
.. option:: --collapsed
14611463

@@ -1486,8 +1488,9 @@ Output options
14861488
.. option:: -o <path>, --output <path>
14871489

14881490
Output file or directory path. Default behavior varies by format:
1489-
:option:`--pstats` writes to stdout, while other formats generate a file
1490-
named ``<format>_<PID>.<ext>`` (for example, ``flamegraph_12345.html``).
1491+
:option:`--pstats` prints a text table to stdout, while ``-o`` writes a
1492+
binary pstats file. Other formats generate a file named
1493+
``<format>_<PID>.<ext>`` (for example, ``flamegraph_12345.html``).
14911494
:option:`--heatmap` creates a directory named ``heatmap_<PID>``.
14921495

14931496
.. option:: --browser

Include/internal/pycore_backoff.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extern "C" {
1212
#include <assert.h>
1313
#include <stdbool.h>
1414
#include "pycore_structs.h" // _Py_BackoffCounter
15+
#include "pycore_tstate.h" // _PyPolicy
1516

1617
/* 16-bit countdown counters using exponential backoff.
1718
@@ -127,10 +128,11 @@ trigger_backoff_counter(void)
127128
#define JUMP_BACKWARD_INITIAL_VALUE 4000
128129
#define JUMP_BACKWARD_INITIAL_BACKOFF 6
129130
static inline _Py_BackoffCounter
130-
initial_jump_backoff_counter(void)
131+
initial_jump_backoff_counter(_PyPolicy *policy)
131132
{
132-
return make_backoff_counter(JUMP_BACKWARD_INITIAL_VALUE,
133-
JUMP_BACKWARD_INITIAL_BACKOFF);
133+
return make_backoff_counter(
134+
policy->interp.jump_backward_initial_value,
135+
policy->interp.jump_backward_initial_backoff);
134136
}
135137

136138
/* Initial exit temperature.
@@ -141,10 +143,11 @@ initial_jump_backoff_counter(void)
141143
#define SIDE_EXIT_INITIAL_BACKOFF 6
142144

143145
static inline _Py_BackoffCounter
144-
initial_temperature_backoff_counter(void)
146+
initial_temperature_backoff_counter(_PyPolicy *policy)
145147
{
146-
return make_backoff_counter(SIDE_EXIT_INITIAL_VALUE,
147-
SIDE_EXIT_INITIAL_BACKOFF);
148+
return make_backoff_counter(
149+
policy->jit.side_exit_initial_value,
150+
policy->jit.side_exit_initial_backoff);
148151
}
149152

150153
/* Unreachable backoff counter. */

Include/internal/pycore_magic_number.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ Known values:
286286
Python 3.15a1 3653 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST)
287287
Python 3.15a1 3654 (Fix missing exception handlers in logical expression)
288288
Python 3.15a1 3655 (Fix miscompilation of some module-level annotations)
289-
Python 3.15a1 3656 (Add TRACE_RECORD instruction, for platforms with switch based interpreter)
290-
Python 3.15a1 3657 (Add CALL_FUNCTION_EX specialization)
289+
Python 3.15a2 3656 (Add TRACE_RECORD instruction, for platforms with switch based interpreter)
290+
Python 3.15a4 3657 (Add BINARY_OP_SUBSCR_USTR_INT)
291+
Python 3.15a4 3658 (Add CALL_FUNCTION_EX specialization)
291292
292293
293294
Python 3.16 will start with 3700
@@ -301,7 +302,7 @@ PC/launcher.c must also be updated.
301302
302303
*/
303304

304-
#define PYC_MAGIC_NUMBER 3657
305+
#define PYC_MAGIC_NUMBER 3658
305306
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
306307
(little-endian) and then appending b'\r\n'. */
307308
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_tstate.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,24 @@ typedef struct _PyJitTracerState {
5252
_PyJitTracerInitialState initial_state;
5353
_PyJitTracerPreviousState prev_state;
5454
} _PyJitTracerState;
55+
5556
#endif
5657

58+
typedef struct _PyJitPolicy {
59+
uint16_t side_exit_initial_value;
60+
uint16_t side_exit_initial_backoff;
61+
} _PyJitPolicy;
62+
63+
typedef struct _PyInterpreterPolicy {
64+
uint16_t jump_backward_initial_value;
65+
uint16_t jump_backward_initial_backoff;
66+
} _PyInterpreterPolicy;
67+
68+
typedef struct _PyPolicy {
69+
_PyJitPolicy jit;
70+
_PyInterpreterPolicy interp;
71+
} _PyPolicy;
72+
5773
// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The
5874
// PyThreadState fields are exposed as part of the C API, although most fields
5975
// are intended to be private. The _PyThreadStateImpl fields not exposed.
@@ -132,6 +148,7 @@ typedef struct _PyThreadStateImpl {
132148
#if _Py_TIER2
133149
_PyJitTracerState jit_tracer_state;
134150
#endif
151+
_PyPolicy policy;
135152
} _PyThreadStateImpl;
136153

137154
#ifdef __cplusplus

0 commit comments

Comments
 (0)