Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit276d777

Browse files
authored
GH-98686: Quicken everything (GH-98687)
1 parent18fc232 commit276d777

File tree

21 files changed

+144
-239
lines changed

21 files changed

+144
-239
lines changed

‎Include/cpython/code.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ typedef struct {
7070
PyObject*co_exceptiontable;/* Byte string encoding exception handling \
7171
table */ \
7272
intco_flags;/* CO_..., see below */ \
73-
shortco_warmup;/* Warmup counter for quickening */ \
7473
short_co_linearray_entry_size;/* Size of each entry in _co_linearray */ \
7574
\
7675
/* The rest are not so impactful on performance. */ \

‎Include/internal/pycore_code.h

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,8 @@ typedef struct {
9191

9292
#defineINLINE_CACHE_ENTRIES_FOR_ITER CACHE_ENTRIES(_PyForIterCache)
9393

94-
#defineQUICKENING_WARMUP_DELAY 8
95-
96-
/* We want to compare to zero for efficiency, so we offset values accordingly */
97-
#defineQUICKENING_INITIAL_WARMUP_VALUE (-QUICKENING_WARMUP_DELAY)
98-
99-
void_PyCode_Quicken(PyCodeObject*code);
100-
101-
staticinlinevoid
102-
_PyCode_Warmup(PyCodeObject*code)
103-
{
104-
if (code->co_warmup!=0) {
105-
code->co_warmup++;
106-
if (code->co_warmup==0) {
107-
_PyCode_Quicken(code);
108-
}
109-
}
110-
}
111-
11294
externuint8_t_PyOpcode_Adaptive[256];
11395

114-
externPy_ssize_t_Py_QuickenedCount;
115-
11696
// Borrowed references to common callables:
11797
structcallable_cache {
11898
PyObject*isinstance;
@@ -252,10 +232,10 @@ extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr,
252232
intoparg);
253233
externvoid_Py_Specialize_ForIter(PyObject*iter,_Py_CODEUNIT*instr);
254234

255-
/*Deallocator function for static codeobjects used in deepfreeze.py */
256-
externvoid_PyStaticCode_Dealloc(PyCodeObject*co);
257-
/* Function to intern strings of codeobjects */
258-
externint_PyStaticCode_InternStrings(PyCodeObject*co);
235+
/*Finalizer function for static codeobjects used in deepfreeze.py */
236+
externvoid_PyStaticCode_Fini(PyCodeObject*co);
237+
/* Function to intern strings of codeobjectsand quicken the bytecode*/
238+
externint_PyStaticCode_Init(PyCodeObject*co);
259239

260240
#ifdefPy_STATS
261241

@@ -397,8 +377,8 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
397377

398378
/* With a 16-bit counter, we have 12 bits for the counter value, and 4 bits for the backoff */
399379
#defineADAPTIVE_BACKOFF_BITS 4
400-
/* The initial counter value is31 == 2**ADAPTIVE_BACKOFF_START - 1 */
401-
#defineADAPTIVE_BACKOFF_START5
380+
/* The initial counter value is1 == 2**ADAPTIVE_BACKOFF_START - 1 */
381+
#defineADAPTIVE_BACKOFF_START1
402382

403383
#defineMAX_BACKOFF_VALUE (16 - ADAPTIVE_BACKOFF_BITS)
404384

‎Include/internal/pycore_opcode.h

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/opcode.h

Lines changed: 31 additions & 33 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Lib/opcode.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,6 @@ def pseudo_op(name, op, real_ops):
327327
"FOR_ITER_LIST",
328328
"FOR_ITER_RANGE",
329329
],
330-
"JUMP_BACKWARD": [
331-
"JUMP_BACKWARD_QUICK",
332-
],
333330
"LOAD_ATTR": [
334331
"LOAD_ATTR_ADAPTIVE",
335332
# These potentially push [NULL, bound method] onto the stack.
@@ -358,9 +355,6 @@ def pseudo_op(name, op, real_ops):
358355
"LOAD_GLOBAL_BUILTIN",
359356
"LOAD_GLOBAL_MODULE",
360357
],
361-
"RESUME": [
362-
"RESUME_QUICK",
363-
],
364358
"STORE_ATTR": [
365359
"STORE_ATTR_ADAPTIVE",
366360
"STORE_ATTR_INSTANCE_VALUE",

‎Lib/test/libregrtest/refleak.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def get_pooled_int(value):
7373
fd_deltas= [0]*repcount
7474
getallocatedblocks=sys.getallocatedblocks
7575
gettotalrefcount=sys.gettotalrefcount
76-
_getquickenedcount=sys._getquickenedcount
7776
fd_count=os_helper.fd_count
7877
# initialize variables to make pyflakes quiet
7978
rc_before=alloc_before=fd_before=0
@@ -93,7 +92,7 @@ def get_pooled_int(value):
9392
support.gc_collect()
9493

9594
# Read memory statistics immediately after the garbage collection
96-
alloc_after=getallocatedblocks()-_getquickenedcount()
95+
alloc_after=getallocatedblocks()
9796
rc_after=gettotalrefcount()
9897
fd_after=fd_count()
9998

‎Lib/test/test_call.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def testfunction_kw(self, *, kw):
580580
returnself
581581

582582

583-
QUICKENING_WARMUP_DELAY=8
583+
ADAPTIVE_WARMUP_DELAY=2
584584

585585

586586
classTestPEP590(unittest.TestCase):
@@ -771,7 +771,7 @@ def f(num): return num + 1
771771
assert_equal(11,f(num))
772772
function_setvectorcall(f)
773773
# make sure specializer is triggered by running > 50 times
774-
for_inrange(10*QUICKENING_WARMUP_DELAY):
774+
for_inrange(10*ADAPTIVE_WARMUP_DELAY):
775775
assert_equal("overridden",f(num))
776776

777777
deftest_setvectorcall_load_attr_specialization_skip(self):
@@ -787,7 +787,7 @@ def __getattribute__(self, attr):
787787
function_setvectorcall(X.__getattribute__)
788788
# make sure specialization doesn't trigger
789789
# when vectorcall is overridden
790-
for_inrange(QUICKENING_WARMUP_DELAY):
790+
for_inrange(ADAPTIVE_WARMUP_DELAY):
791791
assert_equal("overridden",x.a)
792792

793793
deftest_setvectorcall_load_attr_specialization_deopt(self):
@@ -803,12 +803,12 @@ def get_a(x):
803803
assert_equal=self.assertEqual
804804
x=X()
805805
# trigger LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN specialization
806-
for_inrange(QUICKENING_WARMUP_DELAY):
806+
for_inrange(ADAPTIVE_WARMUP_DELAY):
807807
assert_equal("a",get_a(x))
808808
function_setvectorcall(X.__getattribute__)
809809
# make sure specialized LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN
810810
# gets deopted due to overridden vectorcall
811-
for_inrange(QUICKENING_WARMUP_DELAY):
811+
for_inrange(ADAPTIVE_WARMUP_DELAY):
812812
assert_equal("overridden",get_a(x))
813813

814814
@requires_limited_api

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp