Skip to content
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

GH-111213: Fix a few broken stats #111216

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
fprintf(out, "opcode[BINARY_SLICE].specializable : 1\n");
fprintf(out, "opcode[STORE_SLICE].specializable : 1\n");
for (int i = 0; i < 256; i++) {
if (_PyOpcode_Caches[i]) {
if (_PyOpcode_Caches[i] && i != JUMP_BACKWARD) {
fprintf(out, "opcode[%s].specializable : 1\n", _PyOpcode_OpName[i]);
}
PRINT_STAT(i, specialization.success);
Expand Down
24 changes: 18 additions & 6 deletions Tools/scripts/summarize_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def is_specializable(self, opcode: str) -> bool:

def get_specialized_total_counts(self) -> tuple[int, int, int]:
basic = 0
specialized = 0
specialized_hits = 0
specialized_misses = 0
not_specialized = 0
for opcode, opcode_stat in self._data.items():
if "execution_count" not in opcode_stat:
Expand All @@ -261,16 +262,17 @@ def get_specialized_total_counts(self) -> tuple[int, int, int]:
not_specialized += count
elif opcode in self._specialized_instructions:
miss = opcode_stat.get("specialization.miss", 0)
not_specialized += miss
specialized += count - miss
specialized_hits += count - miss
specialized_misses += miss
else:
basic += count
return basic, specialized, not_specialized
return basic, specialized_hits, specialized_misses, not_specialized

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

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

(
basic,
specialized,
specialized_hits,
specialized_misses,
not_specialized,
) = opcode_stats.get_specialized_total_counts()

Expand All @@ -810,7 +813,16 @@ def calc_specialization_effectiveness_table(stats: Stats) -> Rows:
Count(not_specialized),
Ratio(not_specialized, total),
),
("Specialized", Count(specialized), Ratio(specialized, total)),
(
"Specialized hits",
Count(specialized_hits),
Ratio(specialized_hits, total),
),
(
"Specialized misses",
Count(specialized_misses),
Ratio(specialized_misses, total),
),
]

def calc_deferred_by_table(stats: Stats) -> Rows:
Expand Down
Loading