Skip to content

Commit cc3b5e8

Browse files
committed
gh-116879: Add new optimizer pystats to tables
1 parent 950667e commit cc3b5e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Tools/scripts/summarize_stats.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,27 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
512512
),
513513
}
514514

515+
def get_optimizer_stats(self) -> dict[str, tuple[int, int | None]]:
516+
attempts = self._data["Optimization optimizer attempts"]
517+
successes = self._data["Optimization optimizer successes"]
518+
no_memory = self._data["Optimization optimizer failure no memory"]
519+
520+
return {
521+
Doc(
522+
"Optimizer attempts",
523+
"The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run."
524+
): (
525+
attempts,
526+
None,
527+
),
528+
Doc(
529+
"Optimizer successes", "The number of traces that were successfully optimized."
530+
): (successes, attempts),
531+
Doc(
532+
"Optimizer no memory", "The number of optimizations that failed due to no memory."
533+
): (no_memory, attempts),
534+
}
535+
515536
def get_histogram(self, prefix: str) -> list[tuple[int, int]]:
516537
rows = []
517538
for k, v in self._data.items():
@@ -1118,6 +1139,18 @@ def calc_optimization_table(stats: Stats) -> Rows:
11181139
for label, (value, den) in optimization_stats.items()
11191140
]
11201141

1142+
def calc_optimizer_table(stats: Stats) -> Rows:
1143+
optimizer_stats = stats.get_optimizer_stats()
1144+
1145+
return [
1146+
(
1147+
label,
1148+
Count(value),
1149+
Ratio(value, den, percentage=label != "Uops executed"),
1150+
)
1151+
for label, (value, den) in optimizer_stats.items()
1152+
]
1153+
11211154
def calc_histogram_table(key: str, den: str) -> RowCalculator:
11221155
def calc(stats: Stats) -> Rows:
11231156
histogram = stats.get_histogram(key)
@@ -1159,6 +1192,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
11591192
return
11601193

11611194
yield Table(("", "Count:", "Ratio:"), calc_optimization_table, JoinMode.CHANGE)
1195+
yield Table(("", "Count:", "Ratio:"), calc_optimizer_table, JoinMode.CHANGE)
11621196
for name, den in [
11631197
("Trace length", "Optimization traces created"),
11641198
("Optimized trace length", "Optimization traces created"),

0 commit comments

Comments
 (0)