@@ -512,6 +512,27 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
512
512
),
513
513
}
514
514
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
+
515
536
def get_histogram (self , prefix : str ) -> list [tuple [int , int ]]:
516
537
rows = []
517
538
for k , v in self ._data .items ():
@@ -1118,6 +1139,18 @@ def calc_optimization_table(stats: Stats) -> Rows:
1118
1139
for label , (value , den ) in optimization_stats .items ()
1119
1140
]
1120
1141
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
+
1121
1154
def calc_histogram_table (key : str , den : str ) -> RowCalculator :
1122
1155
def calc (stats : Stats ) -> Rows :
1123
1156
histogram = stats .get_histogram (key )
@@ -1159,6 +1192,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
1159
1192
return
1160
1193
1161
1194
yield Table (("" , "Count:" , "Ratio:" ), calc_optimization_table , JoinMode .CHANGE )
1195
+ yield Table (("" , "Count:" , "Ratio:" ), calc_optimizer_table , JoinMode .CHANGE )
1162
1196
for name , den in [
1163
1197
("Trace length" , "Optimization traces created" ),
1164
1198
("Optimized trace length" , "Optimization traces created" ),
0 commit comments