@@ -459,10 +459,7 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
459459 "The number of times a potential trace is identified. Specifically, this "
460460 "occurs in the JUMP BACKWARD instruction when the counter reaches a "
461461 "threshold." ,
462- ): (
463- attempts ,
464- None ,
465- ),
462+ ): (attempts , None ),
466463 Doc (
467464 "Traces created" , "The number of traces that were successfully created."
468465 ): (created , attempts ),
@@ -512,6 +509,26 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]:
512509 ),
513510 }
514511
512+ def get_optimizer_stats (self ) -> dict [str , tuple [int , int | None ]]:
513+ attempts = self ._data ["Optimization optimizer attempts" ]
514+ successes = self ._data ["Optimization optimizer successes" ]
515+ no_memory = self ._data ["Optimization optimizer failure no memory" ]
516+
517+ return {
518+ Doc (
519+ "Optimizer attempts" ,
520+ "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run." ,
521+ ): (attempts , None ),
522+ Doc (
523+ "Optimizer successes" ,
524+ "The number of traces that were successfully optimized." ,
525+ ): (successes , attempts ),
526+ Doc (
527+ "Optimizer no memory" ,
528+ "The number of optimizations that failed due to no memory." ,
529+ ): (no_memory , attempts ),
530+ }
531+
515532 def get_histogram (self , prefix : str ) -> list [tuple [int , int ]]:
516533 rows = []
517534 for k , v in self ._data .items ():
@@ -1118,6 +1135,14 @@ def calc_optimization_table(stats: Stats) -> Rows:
11181135 for label , (value , den ) in optimization_stats .items ()
11191136 ]
11201137
1138+ def calc_optimizer_table (stats : Stats ) -> Rows :
1139+ optimizer_stats = stats .get_optimizer_stats ()
1140+
1141+ return [
1142+ (label , Count (value ), Ratio (value , den ))
1143+ for label , (value , den ) in optimizer_stats .items ()
1144+ ]
1145+
11211146 def calc_histogram_table (key : str , den : str ) -> RowCalculator :
11221147 def calc (stats : Stats ) -> Rows :
11231148 histogram = stats .get_histogram (key )
@@ -1159,6 +1184,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
11591184 return
11601185
11611186 yield Table (("" , "Count:" , "Ratio:" ), calc_optimization_table , JoinMode .CHANGE )
1187+ yield Table (("" , "Count:" , "Ratio:" ), calc_optimizer_table , JoinMode .CHANGE )
11621188 for name , den in [
11631189 ("Trace length" , "Optimization traces created" ),
11641190 ("Optimized trace length" , "Optimization traces created" ),
0 commit comments