Skip to content

Commit 14859bf

Browse files
Include zero-sized diffs in the set of textual diffs generated (#79917)
Diffs with zero size are important to examine because they most likely indicate GC info changes.
1 parent 8508703 commit 14859bf

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/coreclr/scripts/superpmi.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,12 +1759,6 @@ def create_exception():
17591759
logging.info("%s %s -c ### %s %s", self.superpmi_path, " ".join(altjit_replay_flags), self.diff_jit_path, mch_file)
17601760
logging.info("")
17611761

1762-
smallest = sorted(diffs, key=lambda r: int(r["Context size"]))[:20]
1763-
logging.debug("Smallest {} contexts with binary differences:".format(len(smallest)))
1764-
for diff in smallest:
1765-
logging.debug(diff["Context"])
1766-
logging.debug("")
1767-
17681762
if base_metrics is not None and diff_metrics is not None:
17691763
base_bytes = int(base_metrics["Overall"]["Diffed code bytes"])
17701764
diff_bytes = int(diff_metrics["Overall"]["Diffed code bytes"])
@@ -2117,15 +2111,26 @@ def pick_contexts_to_disassemble(self, diffs):
21172111
# available without needing to disassemble all, so pick a subset of
21182112
# interesting diffs to pass to jit-analyze.
21192113

2114+
def display_subset(message, subset):
2115+
logging.debug(message.format(len(subset)))
2116+
for diff in subset:
2117+
logging.debug(diff["Context"])
2118+
logging.debug("")
2119+
21202120
# 20 smallest method contexts with diffs
21212121
smallest_contexts = sorted(diffs, key=lambda r: int(r["Context size"]))[:20]
2122+
display_subset("Smallest {} contexts with binary differences:", smallest_contexts)
2123+
21222124
# Order by byte-wise improvement, largest improvements first
21232125
by_diff_size = sorted(diffs, key=lambda r: int(r["Diff size"]) - int(r["Base size"]))
21242126
# 20 top improvements, byte-wise
21252127
top_improvements_bytes = by_diff_size[:20]
21262128
# 20 top regressions, byte-wise
21272129
top_regressions_bytes = by_diff_size[-20:]
21282130

2131+
display_subset("Top {} improvements, byte-wise:", top_improvements_bytes)
2132+
display_subset("Top {} regressions, byte-wise:", top_regressions_bytes)
2133+
21292134
# Order by percentage-wise size improvement, largest improvements first
21302135
def diff_pct(r):
21312136
base = int(r["Base size"])
@@ -2138,7 +2143,16 @@ def diff_pct(r):
21382143
top_improvements_pct = by_diff_size_pct[:20]
21392144
top_regressions_pct = by_diff_size_pct[-20:]
21402145

2141-
contexts = smallest_contexts + top_improvements_bytes + top_regressions_bytes + top_improvements_pct + top_regressions_pct
2146+
display_subset("Top {} improvements, percentage-wise:", top_improvements_pct)
2147+
display_subset("Top {} regressions, percentage-wise:", top_regressions_pct)
2148+
2149+
# 20 contexts without size diffs (possibly GC info diffs), sorted by size
2150+
zero_size_diffs = filter(lambda r: int(r["Diff size"]) == int(r["Base size"]), diffs)
2151+
smallest_zero_size_contexts = sorted(zero_size_diffs, key=lambda r: int(r["Context size"]))[:20]
2152+
2153+
display_subset("Smallest {} zero sized diffs:", smallest_zero_size_contexts)
2154+
2155+
contexts = smallest_contexts + top_improvements_bytes + top_regressions_bytes + top_improvements_pct + top_regressions_pct + smallest_zero_size_contexts
21422156

21432157
final_contexts_indices = list(set(int(r["Context"]) for r in contexts))
21442158
final_contexts_indices.sort()

0 commit comments

Comments
 (0)