harness and matrix: record the whole process's instructions per run and gate the frame and burst rows on them
The harness now counts each timed run's user-space instructions across the whole process. The counts repeat run to run where the times do not: rt's p50 spread across processes was 0.16 to 0.27%. The matrix gates the frame and burst rows (WALL_ROWS) on those counts, beside the host-time judgement and floors they keep under the GPU-p50 rule. devtools: ProcessInstructions opens one user-space instructions counter per core type with inherit set, so every thread started after it opens counts: the runtimes' and the drivers' threads too. The harness opens it first thing in main, before any device starts a thread, and each timed run records the counted delta. A node that refuses perf_event_open, and every non-Linux host, records none. harness: each row whose runs were not sized prints `M2V-MATRIX instructions harness-<runtime>/<row>/per_run <p50>`. matrix: a frame or burst row with a count on both runtimes passes the instructions gate as well as its time's limit: - it fails when rt's count is over old's; - it fails when rt's count is past 1.03 times the stored count in scripts/matrix/instructions.tsv (one column per driver family, `all` where the legs agree within 3%); - it is named when its count is more than 1% under the stored count, which then ratchets down; - it is named when no count is stored, and is then gated against old alone. The single-kernel rows stay judged on their GPU p50 as before, and every row's count is shown beside its times. The old runtime's harness counts are parked from the per-record instructions-versus-base check, like its times. instructions.tsv starts empty: a matrix run's counts seed it. VALIDATION.md describes the time rules and the gate in one paragraph. Verified: scripts/matrix tests (python3 -m unittest discover, 45 OK) on this Mac, over this rule and the GPU-p50 rule together. Before the rebase, check m3-max-45591 on msi (at c597bb3603) passed clippy x4, nextest for devtools, harness and rt (118 passed, with the process counter's test), and the release harness build. Count job m3-max-45641 on the 2080's node recorded the per_run count of every row on both runtimes except long_4cb, which is sized.
This commit is contained in:
1 parent
b2e33dba6d
commit
d2e5edbd60
8 files changed
+314
-26
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# The new runtime's user-space instructions per timed run that each frame and burst row
|
||||
# (results.WALL_ROWS) is held to by the instructions gate (results.STORED_INSTRUCTIONS): the whole process's count, the p50 over a
|
||||
# row's timed runs. One count per row in the `all` column where every leg's count lies within 3%
|
||||
# of the others', else one per driver family (a GPU leg id's vendor). A count only ratchets down:
|
||||
# a landing that lowers it by more than 1% stores the lower one, and nothing raises it without a
|
||||
# ruling. A row with no count here is gated against the old runtime's count alone, and its line
|
||||
# names it, until the counts of a matrix run are stored.
|
||||
row all
|
||||
|
@@ -839,7 +839,7 @@ def run_cmd(sha, only, dry):
|
||||
def print_leg(leg_id, leg):
|
||||
"""A leg's verdict line, then each of its harness rows' times and GPU times."""
|
||||
print(results.verdict_line(leg_id, leg))
|
||||
for line in results.harness_rows(leg["records"]["time"]):
|
||||
for line in results.harness_rows(leg["records"]):
|
||||
print(f" {line}")
|
||||
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ def leg_problems(leg, records, base):
|
||||
problems.append(f"metric {key}: {was} -> {value}")
|
||||
for key, value in sorted(records["instructions"].items()):
|
||||
was = base["instructions"].get(key)
|
||||
if was is not None and value > was * (1 + INSTRUCTIONS_BAND):
|
||||
if was is not None and not key.startswith(PARKED_RECORDS) and value > was * (1 + INSTRUCTIONS_BAND):
|
||||
problems.append(f"instructions {key}: {was} -> {value} (+{(value / was - 1) * 100:.1f}%)")
|
||||
return problems
|
||||
|
||||
@@ -349,6 +349,73 @@ def gpu_beside(times, runtime, row):
|
||||
return "" if gpu is None else f" (GPU p50 {gpu:.1f} us)"
|
||||
|
||||
|
||||
#: The instructions gate of the frame and burst rows (WALL_ROWS), beside the judgement of their
|
||||
#: time: on Linux, the whole process's user-space instructions per timed run (`instructions
|
||||
#: harness-<runtime>/<row>/per_run`, the p50 over its timed runs, every runtime and driver thread
|
||||
#: counted). The new runtime's count is at most the old's, and at most HARNESS_BUDGET times its
|
||||
#: stored count (STORED_INSTRUCTIONS), with no floor and no ceiling: the count repeats to well
|
||||
#: under 1% (0.16 to 0.27% across processes on the 2080's node). A time that moves while the
|
||||
#: count does not names waits. A leg that records no instructions (the kernel refused the
|
||||
#: counter, or Windows) has no gate. Every row records its count; only these are gated on it.
|
||||
INSTRUCTIONS_PER_RUN = "/per_run"
|
||||
|
||||
|
||||
def read_counts(text):
|
||||
"""The stored instruction counts' TEXT: `#` comments, a header of `row` and driver families
|
||||
(a GPU leg id's vendor, `10de`, or `all` for every leg), then per line a row and its count in
|
||||
each, `-` for none. Returns {family: {row: count}}."""
|
||||
counts, families = {}, None
|
||||
for line in text.splitlines():
|
||||
if not line.strip() or line.startswith("#"):
|
||||
continue
|
||||
cells = line.split()
|
||||
if families is None:
|
||||
families = cells[1:]
|
||||
continue
|
||||
for family, cell in zip(families, cells[1:]):
|
||||
if cell != "-":
|
||||
counts.setdefault(family, {})[cells[0]] = int(cell)
|
||||
return counts
|
||||
|
||||
|
||||
#: The new runtime's instructions per timed run that each WALL_ROWS row is held to
|
||||
#: (`instructions.tsv`, beside this file): one count per row where the legs' counts lie within 3%
|
||||
#: of each other, else one per driver family. A count only ratchets down: a landing that lowers a
|
||||
#: row's count by more than 1% stores the lower one, and nothing raises it without a ruling.
|
||||
STORED_INSTRUCTIONS = read_counts((Path(__file__).resolve().parent / "instructions.tsv").read_text())
|
||||
|
||||
|
||||
def stored_count(leg_id, row):
|
||||
"""ROW's stored count on LEG_ID: its driver family's, else every leg's, else None."""
|
||||
family = leg_id.split(":")[0]
|
||||
for column in (family, "all"):
|
||||
if row in STORED_INSTRUCTIONS.get(column, {}):
|
||||
return STORED_INSTRUCTIONS[column][row]
|
||||
return None
|
||||
|
||||
|
||||
def instruction_gate(leg_id, row, records):
|
||||
"""ROW's instructions gate on LEG_ID from the leg's RECORDS: (problems, parked), both empty
|
||||
where ROW is not a WALL_ROWS row or a runtime recorded no count. A count over the old
|
||||
runtime's, or past HARNESS_BUDGET times the stored count, is a problem; one more than
|
||||
INSTRUCTIONS_BAND under the stored count, or a row with none stored, is named."""
|
||||
counted = [records["instructions"].get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}")
|
||||
for runtime in ("new", "old")]
|
||||
if not row.startswith(WALL_ROWS) or not all(counted):
|
||||
return [], []
|
||||
(new, old), stored = counted, stored_count(leg_id, row)
|
||||
line = (f"harness budget {row}: instructions new {new} per run over old {old} is {new / old:.3f}, "
|
||||
+ (f"stored {stored}" if stored else "none stored"))
|
||||
if new > old:
|
||||
return [f"{line}: new over old"], []
|
||||
if stored and new > HARNESS_BUDGET * stored:
|
||||
return [f"{line}: past {HARNESS_BUDGET} times the stored count"], []
|
||||
if stored and new < (1 - INSTRUCTIONS_BAND) * stored:
|
||||
return [], [f"{line}: more than {INSTRUCTIONS_BAND:.0%} under the stored count, which ratchets "
|
||||
"down to it"]
|
||||
return [], [] if stored else [line]
|
||||
|
||||
|
||||
#: The harness rows over HARNESS_BUDGET that a ruling gave a ceiling, per GPU leg, each a ratio of
|
||||
#: the times its row is judged on (gpu_judged): a row past its ceiling fails its leg, so an open
|
||||
#: row can neither hide nor grow. A
|
||||
@@ -567,6 +634,9 @@ def harness_budget(leg_id, leg):
|
||||
"times measure different work")
|
||||
continue
|
||||
limit = row_limit(leg_id, row)
|
||||
gated, named = instruction_gate(leg_id, row, records)
|
||||
problems += gated
|
||||
parked += named
|
||||
if first_row(row):
|
||||
samples = first_samples(times, row)
|
||||
if samples is None:
|
||||
@@ -620,21 +690,30 @@ def harness_budget(leg_id, leg):
|
||||
return problems, parked
|
||||
|
||||
|
||||
def harness_rows(times):
|
||||
"""Every harness row timed on either runtime in a leg's TIMES, one line each: its time and its
|
||||
GPU time (HARNESS_GPU) on the new runtime and on the old, `-` where it has none, and new over
|
||||
old where both have a time."""
|
||||
def harness_rows(records):
|
||||
"""Every harness row timed on either runtime in a leg's RECORDS, one line each: its time, its
|
||||
GPU time (HARNESS_GPU) and, where recorded, its instructions per run, on the new runtime and on
|
||||
the old, `-` where it has none, and new over old of the times and of the instructions."""
|
||||
times, counted = records["time"], records["instructions"]
|
||||
rows = sorted({key.split("/", 1)[1] for key in times if key.startswith((HARNESS_NEW, HARNESS_OLD))})
|
||||
lines = []
|
||||
for row in rows:
|
||||
cells = []
|
||||
for runtime in ("new", "old"):
|
||||
wall, gpu = times.get(f"harness-{runtime}/{row}"), times.get(f"{HARNESS_GPU}{runtime}/{row}")
|
||||
cells.append(f"{runtime} {'-' if wall is None else f'{wall:.1f}':>10} us, "
|
||||
f"GPU p50 {'-' if gpu is None else f'{gpu:.1f}':>10} us")
|
||||
cell = (f"{runtime} {'-' if wall is None else f'{wall:.1f}':>10} us, "
|
||||
f"GPU p50 {'-' if gpu is None else f'{gpu:.1f}':>10} us")
|
||||
instructions = counted.get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}")
|
||||
if instructions is not None:
|
||||
cell += f", {instructions} instructions"
|
||||
cells.append(cell)
|
||||
new, old = times.get(HARNESS_NEW + row), times.get(HARNESS_OLD + row)
|
||||
ratio = f"{new / old:.3f}" if new is not None and old else "-"
|
||||
lines.append(f"{row:<36} {cells[0]} | {cells[1]} | {ratio}")
|
||||
line = f"{row:<36} {cells[0]} | {cells[1]} | {ratio}"
|
||||
new_i, old_i = (counted.get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}") for runtime in ("new", "old"))
|
||||
if new_i is not None and old_i:
|
||||
line += f", instructions {new_i / old_i:.3f}"
|
||||
lines.append(line)
|
||||
return lines
|
||||
|
||||
|
||||
|
||||
@@ -113,6 +113,12 @@ class RuleTests(unittest.TestCase):
|
||||
self.assertEqual(self.problems(recs(metric={"a/barriers": 5, "a/passes": 2}), base),
|
||||
["metric a/barriers: 4 -> 5"])
|
||||
|
||||
def test_the_old_runtime_s_instructions_are_not_compared_to_its_base(self):
|
||||
base = recs(instructions={"harness-old/frame/per_run": 100000, "harness-new/frame/per_run": 50000})
|
||||
now = recs(instructions={"harness-old/frame/per_run": 105000, "harness-new/frame/per_run": 51000})
|
||||
self.assertEqual(self.problems(now, base),
|
||||
["instructions harness-new/frame/per_run: 50000 -> 51000 (+2.0%)"])
|
||||
|
||||
def test_instructions_fail_past_one_percent(self):
|
||||
base = recs(instructions={"a/per_draw": 10000})
|
||||
self.assertEqual(self.problems(recs(instructions={"a/per_draw": 10100}), base), [])
|
||||
@@ -583,20 +589,70 @@ class HarnessBudgetTests(unittest.TestCase):
|
||||
"M2V-MATRIX time harness-retime/sampling/2/new 36.000",
|
||||
"M2V-MATRIX time harness-retime-gpu/sampling/2/new 17.600"])
|
||||
|
||||
def test_every_row_shows_its_times_and_gpu_times_on_both_runtimes(self):
|
||||
def test_every_row_shows_its_times_gpu_times_and_instructions_on_both_runtimes(self):
|
||||
times = {"harness-old/frame": 100.0, "harness-new/frame": 120.0,
|
||||
"harness-gpu-old/frame": 80.25, "harness-gpu-new/frame": 81.0,
|
||||
"harness-new/create_64MiB/first_take": 50.0, "harness-old/create_64MiB/first_take": 40.0,
|
||||
"harness-old/sampling": 50.0, "harness-first/create_64MiB/first_take/2/new": 51.0,
|
||||
"loop/gpu": 1000.0}
|
||||
self.assertEqual(results.harness_rows(times), [
|
||||
counted = {"harness-new/frame/per_run": 61253, "harness-old/frame/per_run": 149185}
|
||||
self.assertEqual(results.harness_rows(recs(time=times, instructions=counted)), [
|
||||
"create_64MiB/first_take new 50.0 us, GPU p50 - us | old 40.0 us, "
|
||||
"GPU p50 - us | 1.250",
|
||||
"frame new 120.0 us, GPU p50 81.0 us | old 100.0 us, "
|
||||
"GPU p50 80.2 us | 1.200",
|
||||
"frame new 120.0 us, GPU p50 81.0 us, 61253 instructions | "
|
||||
"old 100.0 us, GPU p50 80.2 us, 149185 instructions | 1.200, instructions 0.411",
|
||||
"sampling new - us, GPU p50 - us | old 50.0 us, "
|
||||
"GPU p50 - us | -"])
|
||||
|
||||
def test_the_frame_and_burst_rows_keep_their_time_s_limit_and_pass_the_instructions_gate_too(self):
|
||||
times = {"harness-old/frame": 100.0, "harness-new/frame": 101.0,
|
||||
"harness-old/alu": 100.0, "harness-new/alu": 101.0}
|
||||
counted = {"harness-new/frame/per_run": 61000, "harness-old/frame/per_run": 149000,
|
||||
"harness-new/alu/per_run": 9000, "harness-old/alu/per_run": 5000}
|
||||
|
||||
def budget(leg_id, counts, these=times):
|
||||
return results.harness_budget(leg_id, leg_of(recs(time=these, instructions=counts)))
|
||||
|
||||
line = "harness budget frame: instructions new {} per run over old 149000 is {}, {}"
|
||||
with mock.patch.object(results, "HARNESS_CEILINGS", {}), \
|
||||
mock.patch.object(results, "HARNESS_FLOORS", {}):
|
||||
# Both within the time's budget. alu, not a frame or burst row, has no gate, its count
|
||||
# over old's though it is.
|
||||
with mock.patch.object(results, "STORED_INSTRUCTIONS", {}):
|
||||
self.assertEqual(budget("10de:1e87", counted), ([], [line.format(61000, "0.409", "none stored")]))
|
||||
stored = {"all": {"frame": 60000}}
|
||||
with mock.patch.object(results, "STORED_INSTRUCTIONS", stored):
|
||||
# Within 1.03 times the stored count: nothing to say.
|
||||
self.assertEqual(budget("10de:1e87", counted), ([], []))
|
||||
over = dict(counted, **{"harness-new/frame/per_run": 61900})
|
||||
self.assertEqual(budget("10de:1e87", over)[0], [
|
||||
line.format(61900, "0.415", "stored 60000") + ": past 1.03 times the stored count"])
|
||||
under = dict(counted, **{"harness-new/frame/per_run": 59000})
|
||||
self.assertEqual(budget("10de:1e87", under), ([], [
|
||||
line.format(59000, "0.396", "stored 60000") + ": more than 1% under the stored count, "
|
||||
"which ratchets down to it"]))
|
||||
past_old = dict(counted, **{"harness-new/frame/per_run": 150000})
|
||||
self.assertEqual(budget("10de:1e87", past_old)[0], [
|
||||
line.format(150000, "1.007", "stored 60000") + ": new over old"])
|
||||
# A time past its limit still fails, its count within the gate though it is.
|
||||
slow = dict(times, **{"harness-new/frame": 120.0})
|
||||
self.assertEqual(budget("10de:1e87", counted, slow)[0], [
|
||||
"harness budget frame: new 120.0 us over old 100.0 us is 1.200, past 1.03"])
|
||||
# A driver family's count before every leg's.
|
||||
with mock.patch.object(results, "STORED_INSTRUCTIONS", {"all": {"frame": 60000},
|
||||
"1002": {"frame": 70000}}):
|
||||
self.assertEqual(results.stored_count("1002:744c", "frame"), 70000)
|
||||
self.assertEqual(results.stored_count("10de:2204", "frame"), 60000)
|
||||
# A leg with no counts (Windows, or a refused counter) has no gate.
|
||||
self.assertEqual(budget("8086:3e9b", {}), ([], []))
|
||||
|
||||
def test_the_stored_counts_table_reads_per_family_and_row(self):
|
||||
text = "# a comment\nrow all 1002\nframe 61253 -\nburst_160 - 90000\n"
|
||||
self.assertEqual(results.read_counts(text), {"all": {"frame": 61253}, "1002": {"burst_160": 90000}})
|
||||
for family, rows in results.STORED_INSTRUCTIONS.items():
|
||||
self.assertRegex(family, r"^(all|[0-9a-f]{4})$")
|
||||
self.assertTrue(all(row.startswith(results.WALL_ROWS) for row in rows), family)
|
||||
|
||||
def test_every_ceiling_is_over_the_budget(self):
|
||||
for leg, rows in results.HARNESS_CEILINGS.items():
|
||||
for row, ceiling in rows.items():
|
||||
|
||||
Reference in new issue
Block a user