From cc3b5e83967368e8510b5aa7f2b22f4ec51e04f7 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 15 Mar 2024 15:02:37 -0400 Subject: [PATCH 1/4] gh-116879: Add new optimizer pystats to tables --- Tools/scripts/summarize_stats.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index 2925e096f4d95e..a1d5edcc403070 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -512,6 +512,27 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]: ), } + def get_optimizer_stats(self) -> dict[str, tuple[int, int | None]]: + attempts = self._data["Optimization optimizer attempts"] + successes = self._data["Optimization optimizer successes"] + no_memory = self._data["Optimization optimizer failure no memory"] + + return { + Doc( + "Optimizer attempts", + "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run." + ): ( + attempts, + None, + ), + Doc( + "Optimizer successes", "The number of traces that were successfully optimized." + ): (successes, attempts), + Doc( + "Optimizer no memory", "The number of optimizations that failed due to no memory." + ): (no_memory, attempts), + } + def get_histogram(self, prefix: str) -> list[tuple[int, int]]: rows = [] for k, v in self._data.items(): @@ -1118,6 +1139,18 @@ def calc_optimization_table(stats: Stats) -> Rows: for label, (value, den) in optimization_stats.items() ] + def calc_optimizer_table(stats: Stats) -> Rows: + optimizer_stats = stats.get_optimizer_stats() + + return [ + ( + label, + Count(value), + Ratio(value, den, percentage=label != "Uops executed"), + ) + for label, (value, den) in optimizer_stats.items() + ] + def calc_histogram_table(key: str, den: str) -> RowCalculator: def calc(stats: Stats) -> Rows: histogram = stats.get_histogram(key) @@ -1159,6 +1192,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None) return yield Table(("", "Count:", "Ratio:"), calc_optimization_table, JoinMode.CHANGE) + yield Table(("", "Count:", "Ratio:"), calc_optimizer_table, JoinMode.CHANGE) for name, den in [ ("Trace length", "Optimization traces created"), ("Optimized trace length", "Optimization traces created"), From 464963932f0988c3a58f92fcbfcb589c987aa9a7 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 15 Mar 2024 15:19:54 -0400 Subject: [PATCH 2/4] Simplify --- Tools/scripts/summarize_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index a1d5edcc403070..1546c7b3fc8c4d 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -1146,7 +1146,7 @@ def calc_optimizer_table(stats: Stats) -> Rows: ( label, Count(value), - Ratio(value, den, percentage=label != "Uops executed"), + Ratio(value, den) ) for label, (value, den) in optimizer_stats.items() ] From 0069363713d62c738d07607fa90e939d7921c4f9 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 15 Mar 2024 15:28:40 -0400 Subject: [PATCH 3/4] Formatter --- Tools/scripts/summarize_stats.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index 1546c7b3fc8c4d..dfd4b665c944cf 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -459,10 +459,7 @@ def get_optimization_stats(self) -> dict[str, tuple[int, int | None]]: "The number of times a potential trace is identified. Specifically, this " "occurs in the JUMP BACKWARD instruction when the counter reaches a " "threshold.", - ): ( - attempts, - None, - ), + ): (attempts, None), Doc( "Traces created", "The number of traces that were successfully created." ): (created, attempts), @@ -521,10 +518,7 @@ def get_optimizer_stats(self) -> dict[str, tuple[int, int | None]]: Doc( "Optimizer attempts", "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run." - ): ( - attempts, - None, - ), + ): (attempts, None), Doc( "Optimizer successes", "The number of traces that were successfully optimized." ): (successes, attempts), From 412a930db2db13787ec49dc3aaca4d626bd9de4f Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 15 Mar 2024 15:29:48 -0400 Subject: [PATCH 4/4] Formatter --- Tools/scripts/summarize_stats.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index dfd4b665c944cf..6af14e1b769b80 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -517,13 +517,15 @@ def get_optimizer_stats(self) -> dict[str, tuple[int, int | None]]: return { Doc( "Optimizer attempts", - "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run." + "The number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run.", ): (attempts, None), Doc( - "Optimizer successes", "The number of traces that were successfully optimized." + "Optimizer successes", + "The number of traces that were successfully optimized.", ): (successes, attempts), Doc( - "Optimizer no memory", "The number of optimizations that failed due to no memory." + "Optimizer no memory", + "The number of optimizations that failed due to no memory.", ): (no_memory, attempts), } @@ -1137,11 +1139,7 @@ def calc_optimizer_table(stats: Stats) -> Rows: optimizer_stats = stats.get_optimizer_stats() return [ - ( - label, - Count(value), - Ratio(value, den) - ) + (label, Count(value), Ratio(value, den)) for label, (value, den) in optimizer_stats.items() ]