Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0699aa

Browse files
authored
GH-111213: Fix a few broken stats (GH-111216)
1 parent 5c9d449 commit b0699aa

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Python/specialize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
134134
fprintf(out, "opcode[BINARY_SLICE].specializable : 1\n");
135135
fprintf(out, "opcode[STORE_SLICE].specializable : 1\n");
136136
for (int i = 0; i < 256; i++) {
137-
if (_PyOpcode_Caches[i]) {
137+
if (_PyOpcode_Caches[i] && i != JUMP_BACKWARD) {
138138
fprintf(out, "opcode[%s].specializable : 1\n", _PyOpcode_OpName[i]);
139139
}
140140
PRINT_STAT(i, specialization.success);

Tools/scripts/summarize_stats.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def is_specializable(self, opcode: str) -> bool:
251251

252252
def get_specialized_total_counts(self) -> tuple[int, int, int]:
253253
basic = 0
254-
specialized = 0
254+
specialized_hits = 0
255+
specialized_misses = 0
255256
not_specialized = 0
256257
for opcode, opcode_stat in self._data.items():
257258
if "execution_count" not in opcode_stat:
@@ -261,16 +262,17 @@ def get_specialized_total_counts(self) -> tuple[int, int, int]:
261262
not_specialized += count
262263
elif opcode in self._specialized_instructions:
263264
miss = opcode_stat.get("specialization.miss", 0)
264-
not_specialized += miss
265-
specialized += count - miss
265+
specialized_hits += count - miss
266+
specialized_misses += miss
266267
else:
267268
basic += count
268-
return basic, specialized, not_specialized
269+
return basic, specialized_hits, specialized_misses, not_specialized
269270

270271
def get_deferred_counts(self) -> dict[str, int]:
271272
return {
272273
opcode: opcode_stat.get("specialization.deferred", 0)
273274
for opcode, opcode_stat in self._data.items()
275+
if opcode != "RESUME"
274276
}
275277

276278
def get_misses_counts(self) -> dict[str, int]:
@@ -799,7 +801,8 @@ def calc_specialization_effectiveness_table(stats: Stats) -> Rows:
799801

800802
(
801803
basic,
802-
specialized,
804+
specialized_hits,
805+
specialized_misses,
803806
not_specialized,
804807
) = opcode_stats.get_specialized_total_counts()
805808

@@ -810,7 +813,16 @@ def calc_specialization_effectiveness_table(stats: Stats) -> Rows:
810813
Count(not_specialized),
811814
Ratio(not_specialized, total),
812815
),
813-
("Specialized", Count(specialized), Ratio(specialized, total)),
816+
(
817+
"Specialized hits",
818+
Count(specialized_hits),
819+
Ratio(specialized_hits, total),
820+
),
821+
(
822+
"Specialized misses",
823+
Count(specialized_misses),
824+
Ratio(specialized_misses, total),
825+
),
814826
]
815827

816828
def calc_deferred_by_table(stats: Stats) -> Rows:

0 commit comments

Comments
 (0)