Skip to content

bpo-46072: Print summary stats for overall success of specialization. #31211

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

Merged
Merged
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
32 changes: 32 additions & 0 deletions Tools/scripts/summarize_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ def extract_opcode_stats(stats):
return opcode_stats


def categorized_counts(opcode_stats):
basic = 0
specialized = 0
not_specialized = 0
specialized_instructions = {
op for op in opcode._specialized_instructions
if "__" not in op and "ADAPTIVE" not in op}
adaptive_instructions = {
op for op in opcode._specialized_instructions
if "ADAPTIVE" in op}
for i, opcode_stat in enumerate(opcode_stats):
if "execution_count" not in opcode_stat:
continue
count = opcode_stat['execution_count']
name = opname[i]
if "specializable" in opcode_stat:
not_specialized += count
elif name in adaptive_instructions:
not_specialized += count
elif name in specialized_instructions:
miss = opcode_stat.get("specialization.miss", 0)
not_specialized += miss
specialized += count - miss
else:
basic += count
return basic, not_specialized, specialized

def main():
stats = gather_stats()
opcode_stats = extract_opcode_stats(stats)
Expand All @@ -98,6 +125,11 @@ def main():
for i, opcode_stat in enumerate(opcode_stats):
name = opname[i]
print_specialization_stats(name, opcode_stat)
basic, not_specialized, specialized = categorized_counts(opcode_stats)
print("Specialization effectiveness:")
print(f" Base instructions {basic} {basic*100/total:0.1f}%")
print(f" Not specialized {not_specialized} {not_specialized*100/total:0.1f}%")
print(f" Specialized {specialized} {specialized*100/total:0.1f}%")
print("Call stats:")
total = 0
for key, value in stats.items():
Expand Down