MCPcopy Index your code
hub / github.com/python/cpython / pre_succ_pairs_section

Function pre_succ_pairs_section

Tools/scripts/summarize_stats.py:832–878  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

830
831
832def pre_succ_pairs_section() -> Section:
833 def iter_pre_succ_pairs_tables(base_stats: Stats, head_stats: Stats | None = None):
834 assert head_stats is None
835
836 opcode_stats = base_stats.get_opcode_stats("opcode")
837
838 for opcode in opcode_stats.get_opcode_names():
839 predecessors = opcode_stats.get_predecessors(opcode)
840 successors = opcode_stats.get_successors(opcode)
841 predecessors_total = predecessors.total()
842 successors_total = successors.total()
843 if predecessors_total == 0 and successors_total == 0:
844 continue
845 pred_rows = [
846 (pred, Count(count), Ratio(count, predecessors_total))
847 for (pred, count) in predecessors.most_common(5)
848 ]
849 succ_rows = [
850 (succ, Count(count), Ratio(count, successors_total))
851 for (succ, count) in successors.most_common(5)
852 ]
853
854 yield Section(
855 opcode,
856 f"Successors and predecessors for {opcode}",
857 [
858 Table(
859 ("Predecessors", "Count:", "Percentage:"),
860 lambda *_: pred_rows, # type: ignore
861 ),
862 Table(
863 ("Successors", "Count:", "Percentage:"),
864 lambda *_: succ_rows, # type: ignore
865 ),
866 ],
867 )
868
869 return Section(
870 "Predecessor/Successor Pairs",
871 "Top 5 predecessors and successors of each Tier 1 opcode.",
872 iter_pre_succ_pairs_tables,
873 comparative=False,
874 doc="""
875 This does not include the unspecialized instructions that occur after a
876 specialized instruction deoptimizes.
877 """,
878 )
879
880
881def specialization_section() -> Section:

Callers 1

summarize_stats.pyFile · 0.85

Calls 1

SectionClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…