Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ checked before anything else; a PR that does not meet them waits (or is closed a
time. The PR's block must name its head commit with no uncommitted changes (rerun it after every
push); the other must be made on a commit of `main`. The PR's run must show no device removal and
no crash (the `main` run may: a PR that fixes a crash shows it there), at least 80 % of `main`'s
frames and at most 125 % of its peak commit. A run on a title that does not reach the code the PR
changes still counts as a regression check; say what it does not cover under **Not tested**.
frames and at most 125 % of its peak commit. Both runs must report a numeric `peak commit`;
a missing value or `n/a` cannot establish the memory comparison. A run on a title that does not
reach the code the PR changes still counts as a regression check; say what it does not cover
under **Not tested**.
`scripts/pr_check.py` checks all of this (and the rest of this list it can see) on every PR.
If a test-only diff touches a runtime file, a maintainer can apply the `test-only` label after
reviewing the diff. The label event waives only the smoke check for that revision. Adding or
Expand Down
4 changes: 4 additions & 0 deletions scripts/pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ def check(body, head, files, is_main_ancestor, *, test_only=False):
if mf and (pf is None or pf < FRAMES_KEPT * mf):
problems.append(f"the PR's run shows fewer frames than main's ({pf} against {mf})")
pc, mc = number(pr.get("peak commit")), number(m.get("peak commit"))
if pc is None:
problems.append("the PR's regression run needs a numeric peak commit measurement")
if mc is None:
problems.append("the main regression run needs a numeric peak commit measurement")
if pc and mc and pc > COMMIT_GROWTH * mc:
problems.append(f"the PR's run commits much more memory than main's ({pc} MB against {mc} MB)")
return problems
Expand Down
4 changes: 2 additions & 2 deletions scripts/test_pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_test_paths_do_not_need_approval(self):

class SmokeBlockTests(unittest.TestCase):
def test_two_blocks_in_one_fence_are_two_blocks(self):
body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\ntitle: G\nseconds: 60\n\n"
"xcl-smoke v1\ncommit: 1234567890\ntitle: G\nseconds: 60\n```\n")
body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\ntitle: G\nseconds: 60\npeak commit: 100 MB\n\n"
"xcl-smoke v1\ncommit: 1234567890\ntitle: G\nseconds: 60\npeak commit: 100 MB\n```\n")
blocks = smoke_blocks(body)
self.assertEqual(["1111111aaaa", "1234567890"], [b["commit"] for b in blocks])
files = [changed("crates/xcl/src/hle/d3d12x/vram.rs")]
Expand Down
40 changes: 40 additions & 0 deletions scripts/test_pr_check_memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest

from pr_check import check


HEAD = "1234567890abcdef"
MAIN = "abcdef1234567890"
BODY = "**Tested**\nSynthetic fixtures\n**Not tested**\nRetail titles\n**AI use**\nNone\n"
FILES = [("crates/xcl/src/config.rs", "modified", False, lambda: 10)]


def smoke(commit, peak):
block = (
f"```\nxcl-smoke v1\ncommit: {commit}\ntitle: synthetic\nseconds: 60\n"
"exit: 0x0\nframes shown: 1000 (PresentX 1000)\ndevice removals: 0\ncrashes: 0\n"
)
if peak is not None:
block += f"peak commit: {peak}\n"
return block + "```\n"


def problems(main_peak, pr_peak):
return check(BODY + smoke(MAIN, main_peak) + smoke(HEAD, pr_peak), HEAD, FILES, lambda sha: sha == MAIN)


class SmokeMemoryTests(unittest.TestCase):
def test_both_runs_need_a_memory_measurement(self):
for side in ("main", "PR"):
for missing in (None, "", "n/a MB", "unknown"):
with self.subTest(side=side, peak=missing):
peaks = (missing, "100 MB") if side == "main" else ("100 MB", missing)
self.assertTrue(problems(*peaks))

def test_measured_memory_still_obeys_the_growth_limit(self):
self.assertEqual([], problems("100 MB", "125 MB"))
self.assertTrue(problems("100 MB", "126 MB"))


if __name__ == "__main__":
unittest.main()
Loading