Skip to content

Commit 328fe3f

Browse files
authored
Print summary stats for overall success of specialization. (GH-31211)
1 parent c8b62bb commit 328fe3f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Tools/scripts/summarize_stats.py

+32
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,33 @@ def extract_opcode_stats(stats):
7777
return opcode_stats
7878

7979

80+
def categorized_counts(opcode_stats):
81+
basic = 0
82+
specialized = 0
83+
not_specialized = 0
84+
specialized_instructions = {
85+
op for op in opcode._specialized_instructions
86+
if "__" not in op and "ADAPTIVE" not in op}
87+
adaptive_instructions = {
88+
op for op in opcode._specialized_instructions
89+
if "ADAPTIVE" in op}
90+
for i, opcode_stat in enumerate(opcode_stats):
91+
if "execution_count" not in opcode_stat:
92+
continue
93+
count = opcode_stat['execution_count']
94+
name = opname[i]
95+
if "specializable" in opcode_stat:
96+
not_specialized += count
97+
elif name in adaptive_instructions:
98+
not_specialized += count
99+
elif name in specialized_instructions:
100+
miss = opcode_stat.get("specialization.miss", 0)
101+
not_specialized += miss
102+
specialized += count - miss
103+
else:
104+
basic += count
105+
return basic, not_specialized, specialized
106+
80107
def main():
81108
stats = gather_stats()
82109
opcode_stats = extract_opcode_stats(stats)
@@ -102,6 +129,11 @@ def main():
102129
for i, opcode_stat in enumerate(opcode_stats):
103130
name = opname[i]
104131
print_specialization_stats(name, opcode_stat)
132+
basic, not_specialized, specialized = categorized_counts(opcode_stats)
133+
print("Specialization effectiveness:")
134+
print(f" Base instructions {basic} {basic*100/total:0.1f}%")
135+
print(f" Not specialized {not_specialized} {not_specialized*100/total:0.1f}%")
136+
print(f" Specialized {specialized} {specialized*100/total:0.1f}%")
105137
print("Call stats:")
106138
total = 0
107139
for key, value in stats.items():

0 commit comments

Comments
 (0)