FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-116879: Add new optimizer pystats to tables by mdboom · Pull Request #116880 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
34 changes: 30 additions & 4 deletions Tools/scripts/summarize_stats.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -512,6 +509,26 @@ 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():
Expand Down Expand Up @@ -1118,6 +1135,14 @@ 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))
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)
Expand Down Expand Up @@ -1159,6 +1184,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"),
Expand Down

Back | FazBrowse Home | New Git URL