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

Commitdf59226

Browse files
authored
gh-100239: more refined specialisation stats for BINARY_OP/SUBSCR (#132068)
1 parent7212306 commitdf59226

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

‎Include/cpython/pystats.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#definePYSTATS_MAX_UOP_ID 512
3333

34-
#defineSPECIALIZATION_FAILURE_KINDS37
34+
#defineSPECIALIZATION_FAILURE_KINDS44
3535

3636
/* Stats for determining who is calling PyEval_EvalFrame */
3737
#defineEVAL_CALL_TOTAL 0

‎Python/specialize.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,13 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
597597
#defineSPEC_FAIL_BINARY_OP_SUBSCR_TUPLE_SLICE 35
598598
#defineSPEC_FAIL_BINARY_OP_SUBSCR_STRING_SLICE 36
599599
#defineSPEC_FAIL_BINARY_OP_SUBSCR_NOT_HEAP_TYPE 37
600+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_OTHER_SLICE 38
601+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_MAPPINGPROXY 39
602+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_RE_MATCH 40
603+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_ARRAY 41
604+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_DEQUE 42
605+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_ENUMDICT 43
606+
#defineSPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY 44
600607

601608
/* Calls */
602609

@@ -2358,6 +2365,34 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
23582365
}
23592366
}
23602367
Py_XDECREF(descriptor);
2368+
2369+
if (PyObject_TypeCheck(lhs,&PyDictProxy_Type)) {
2370+
returnSPEC_FAIL_BINARY_OP_SUBSCR_MAPPINGPROXY;
2371+
}
2372+
2373+
if (strcmp(container_type->tp_name,"array.array")==0) {
2374+
returnSPEC_FAIL_BINARY_OP_SUBSCR_ARRAY;
2375+
}
2376+
2377+
if (strcmp(container_type->tp_name,"re.Match")==0) {
2378+
returnSPEC_FAIL_BINARY_OP_SUBSCR_RE_MATCH;
2379+
}
2380+
2381+
if (strcmp(container_type->tp_name,"collections.deque")==0) {
2382+
returnSPEC_FAIL_BINARY_OP_SUBSCR_DEQUE;
2383+
}
2384+
2385+
if (strcmp(_PyType_Name(container_type),"EnumDict")!=0) {
2386+
returnSPEC_FAIL_BINARY_OP_SUBSCR_ENUMDICT;
2387+
}
2388+
2389+
if (strcmp(container_type->tp_name,"StackSummary")!=0) {
2390+
returnSPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY;
2391+
}
2392+
2393+
if (PySlice_Check(rhs)) {
2394+
returnSPEC_FAIL_BINARY_OP_SUBSCR_OTHER_SLICE;
2395+
}
23612396
returnSPEC_FAIL_BINARY_OP_SUBSCR;
23622397
}
23632398
Py_UNREACHABLE();

‎Tools/scripts/summarize_stats.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,20 @@ def kind_to_text(kind: int, opcode: str):
298298
return"kind "+str(kind)
299299

300300
family_stats=self._get_stats_for_opcode(opcode)
301-
failure_kinds= [0]*40
301+
302+
defkey_to_index(key):
303+
returnint(key[:-1].split("[")[1])
304+
305+
max_index=0
306+
forkeyinfamily_stats:
307+
ifkey.startswith("specialization.failure_kind"):
308+
max_index=max(max_index,key_to_index(key))
309+
310+
failure_kinds= [0]* (max_index+1)
302311
forkeyinfamily_stats:
303312
ifnotkey.startswith("specialization.failure_kind"):
304313
continue
305-
index=int(key[:-1].split("[")[1])
306-
failure_kinds[index]=family_stats[key]
314+
failure_kinds[key_to_index(key)]=family_stats[key]
307315
return {
308316
kind_to_text(index,opcode):value
309317
for (index,value)inenumerate(failure_kinds)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp