@@ -441,6 +441,8 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
441
441
return {}
442
442
443
443
attempts = self ._data ["Optimization attempts" ]
444
+ estimated_incorrectly = self ._data ["Optimization estimated incorrectly" ]
445
+ estimated_correctly = self ._data ["Optimization estimated correctly" ]
444
446
created = self ._data ["Optimization traces created" ]
445
447
executed = self ._data ["Optimization traces executed" ]
446
448
uops = self ._data ["Optimization uops executed" ]
@@ -466,6 +468,8 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
466
468
Doc (
467
469
"Traces created" , "The number of traces that were successfully created."
468
470
): (created , attempts ),
471
+ Doc ("Estimated incorrectly" , "" ): (estimated_incorrectly , attempts ),
472
+ Doc ("Estimated correctly" , "" ): (estimated_correctly , attempts ),
469
473
Doc (
470
474
"Trace stack overflow" ,
471
475
"A trace is truncated because it would require more than 5 stack frames." ,
@@ -512,6 +516,27 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
512
516
),
513
517
}
514
518
519
+ def get_optimizer_stats (self ) -> dict [str , tuple [int , int | None ]]:
520
+ attempts = self ._data ["Optimization optimizer attempts" ]
521
+ successes = self ._data ["Optimization optimizer successes" ]
522
+ no_memory = self ._data ["Optimization optimizer failure no memory" ]
523
+
524
+ return {
525
+ Doc (
526
+ "Optimizer attempts" ,
527
+ "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run."
528
+ ): (
529
+ attempts ,
530
+ None ,
531
+ ),
532
+ Doc (
533
+ "Optimizer successes" , "The number of traces that were successfully optimized."
534
+ ): (successes , attempts ),
535
+ Doc (
536
+ "Optimizer no memory" , "The number of optimizations that failed due to no memory."
537
+ ): (no_memory , attempts ),
538
+ }
539
+
515
540
def get_histogram (self , prefix : str ) -> list [tuple [int , int ]]:
516
541
rows = []
517
542
for k , v in self ._data .items ():
@@ -1118,6 +1143,18 @@ def calc_optimization_table(stats: Stats) -> Rows:
1118
1143
for label , (value , den ) in optimization_stats .items ()
1119
1144
]
1120
1145
1146
+ def calc_optimizer_table (stats : Stats ) -> Rows :
1147
+ optimizer_stats = stats .get_optimizer_stats ()
1148
+
1149
+ return [
1150
+ (
1151
+ label ,
1152
+ Count (value ),
1153
+ Ratio (value , den , percentage = label != "Uops executed" ),
1154
+ )
1155
+ for label , (value , den ) in optimizer_stats .items ()
1156
+ ]
1157
+
1121
1158
def calc_histogram_table (key : str , den : str ) -> RowCalculator :
1122
1159
def calc (stats : Stats ) -> Rows :
1123
1160
histogram = stats .get_histogram (key )
@@ -1159,6 +1196,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
1159
1196
return
1160
1197
1161
1198
yield Table (("" , "Count:" , "Ratio:" ), calc_optimization_table , JoinMode .CHANGE )
1199
+ yield Table (("" , "Count:" , "Ratio:" ), calc_optimizer_table , JoinMode .CHANGE )
1162
1200
for name , den in [
1163
1201
("Trace length" , "Optimization traces created" ),
1164
1202
("Optimized trace length" , "Optimization traces created" ),
0 commit comments