matrix: the instructions gate judges the new runtime's own threads, a driver's left beside
The burst rows' whole-process count swung by up to 25 million instructions per run between processes on NVIDIA, all of it in the driver's own "[vkrt] Analysis" thread, while rt's own threads held steady (48-50k instructions per command buffer on the 2080, 23k on the XTX). A gate on the whole count judged the driver. rt now registers the OS id of every thread it starts in Gauges::threads, at one place: the spawn helper device::start, which the reaper, block-maker, submit and completion threads and the cache store's removal thread all start through. A thread holds its slot until it ends. The list is bounded by construction (5 slots), nothing on a commit or submit path reads it, and Device::new's paths are untouched. devtools gains ThreadInstructions (per-thread user-space counters by OS id, a thread that already ended skipped) and this_thread. The harness reads the runtime's thread ids through Device::threads before a row's timed runs, counts them with its own thread, and records own_per_run and others_per_run beside per_run. Every counter read now sits outside the timed wall span. results.py, per the planner's ruling: EXACT, the new runtime's own count at most 1.03 times its stored count (instructions.tsv now holds own counts), ratcheting down; LENIENT, named on every row, the own count at most the old runtime's whole count, old's driver share not separable since the old runtime names no threads. A whole count with no own count fails the row. The base comparison skips the harness's counts: the gate judges them. Verified: scripts/matrix/test_results.py, 42 tests OK locally. Builds and the other suites run on the check job.
This commit is contained in:
1 parent
e2a75fffec
commit
eb16d34f15
17 files changed
+451
-129
No files matched your search
@@ -1,8 +1,9 @@
|
||||
# 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%
|
||||
# (results.WALL_ROWS) is held to by the instructions gate (results.STORED_INSTRUCTIONS): its own
|
||||
# threads' and the harness's thread's count (`own_per_run`, the threads a driver starts for itself
|
||||
# left out), 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.
|
||||
# ruling. A row with no count here is gated against the old runtime's whole count alone, and its
|
||||
# line names it, until the counts of a matrix run are stored.
|
||||
row all
|
||||
|
+57
-31
@@ -253,7 +253,8 @@ 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 not key.startswith(PARKED_RECORDS) and value > was * (1 + INSTRUCTIONS_BAND):
|
||||
if (was is not None and not key.startswith(PARKED_RECORDS + ("harness-",))
|
||||
and value > was * (1 + INSTRUCTIONS_BAND)):
|
||||
problems.append(f"instructions {key}: {was} -> {value} (+{(value / was - 1) * 100:.1f}%)")
|
||||
return problems
|
||||
|
||||
@@ -350,14 +351,22 @@ def gpu_beside(times, runtime, row):
|
||||
|
||||
|
||||
#: 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.
|
||||
#: time, on Linux's user-space instructions per timed run, each the p50 over the row's timed runs.
|
||||
#: The harness records the whole process's (`instructions harness-<runtime>/<row>/per_run`), and
|
||||
#: where the runtime names the threads it started (the new runtime's `Gauges::threads`), the count
|
||||
#: of those and the harness's own thread (`.../own_per_run`) and the rest, the threads a driver
|
||||
#: started for itself (`.../others_per_run`). A driver's threads swing by millions of instructions
|
||||
#: per run between processes (NVIDIA's on burst_160: 0 to 25 million), the runtime's own do not.
|
||||
#: The gate is on the runtime's own: EXACT, the new runtime's own count at most HARNESS_BUDGET
|
||||
#: times its stored count (STORED_INSTRUCTIONS), which ratchets down; and LENIENT, printed on
|
||||
#: every row, the new runtime's own count at most the old's whole count, the old runtime naming
|
||||
#: none of its threads, so its driver's share cannot be taken out. The base comparison of
|
||||
#: leg_problems skips the harness's counts: this gate judges them. A leg that records no
|
||||
#: instructions (the kernel refused the counter, or Windows) has no gate. Every row records its
|
||||
#: counts; only these are gated on them.
|
||||
INSTRUCTIONS_PER_RUN = "/per_run"
|
||||
#: The new runtime's own threads' count of a row, and the rest of the process's.
|
||||
OWN_PER_RUN, OTHERS_PER_RUN = "/own_per_run", "/others_per_run"
|
||||
|
||||
|
||||
def read_counts(text):
|
||||
@@ -378,10 +387,11 @@ def read_counts(text):
|
||||
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.
|
||||
#: The new runtime's own threads' instructions per timed run (OWN_PER_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())
|
||||
|
||||
|
||||
@@ -396,24 +406,33 @@ def stored_count(leg_id, row):
|
||||
|
||||
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):
|
||||
where ROW is not a WALL_ROWS row or a runtime recorded no whole count. EXACT: the new runtime's
|
||||
own count past HARNESS_BUDGET times the stored count is a problem; one more than
|
||||
INSTRUCTIONS_BAND under it, or a row with none stored, is named. LENIENT, named on every row:
|
||||
the new runtime's own count over the old's whole count is a problem. A new runtime that
|
||||
recorded its whole count but not its own is a problem: the gate could not run."""
|
||||
counted = records["instructions"]
|
||||
new, old = (counted.get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}") for runtime in ("new", "old"))
|
||||
if not row.startswith(WALL_ROWS) or not new or not old:
|
||||
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]
|
||||
own, others = (counted.get(f"harness-new/{row}{part}") for part in (OWN_PER_RUN, OTHERS_PER_RUN))
|
||||
if own is None:
|
||||
return [f"harness budget {row}: instructions new {new} per run, but no count of its own threads"], []
|
||||
problems, parked = [], []
|
||||
stored = stored_count(leg_id, row)
|
||||
exact = f"harness budget {row}: EXACT instructions new own {own} per run, " + (
|
||||
f"stored {stored}, is {own / stored:.3f}" if stored else "none stored")
|
||||
if stored and own > HARNESS_BUDGET * stored:
|
||||
problems.append(f"{exact}: past {HARNESS_BUDGET} times the stored count")
|
||||
elif stored and own < (1 - INSTRUCTIONS_BAND) * stored:
|
||||
parked.append(f"{exact}: more than {INSTRUCTIONS_BAND:.0%} under the stored count, which ratchets "
|
||||
"down to it")
|
||||
elif not stored:
|
||||
parked.append(exact)
|
||||
lenient = (f"harness budget {row}: LENIENT instructions new own {own} per run over old whole {old} is "
|
||||
f"{own / old:.3f}; new others {others}, old's driver threads not separable")
|
||||
(problems if own > old else parked).append(lenient + (": new own over old whole" if own > old else ""))
|
||||
return problems, parked
|
||||
|
||||
|
||||
#: The harness rows over HARNESS_BUDGET that a ruling gave a ceiling, per GPU leg, each a ratio of
|
||||
@@ -705,8 +724,9 @@ def harness_budget(leg_id, leg):
|
||||
|
||||
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."""
|
||||
GPU time (HARNESS_GPU) and, where recorded, its instructions per run (with its own threads'
|
||||
where the runtime names them), on the new runtime and on the old, `-` where it has none, and
|
||||
new over old of the times and of the instructions (and of new's own over old's whole)."""
|
||||
times, counted = records["time"], records["instructions"]
|
||||
rows = sorted({key.split("/", 1)[1] for key in times if key.startswith((HARNESS_NEW, HARNESS_OLD))})
|
||||
lines = []
|
||||
@@ -719,6 +739,9 @@ def harness_rows(records):
|
||||
instructions = counted.get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}")
|
||||
if instructions is not None:
|
||||
cell += f", {instructions} instructions"
|
||||
own = counted.get(f"harness-{runtime}/{row}{OWN_PER_RUN}")
|
||||
if own is not None:
|
||||
cell += f" ({own} own)"
|
||||
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 "-"
|
||||
@@ -726,6 +749,9 @@ def harness_rows(records):
|
||||
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}"
|
||||
own = counted.get(f"harness-new/{row}{OWN_PER_RUN}")
|
||||
if own is not None:
|
||||
line += f", own over old {own / old_i:.3f}"
|
||||
lines.append(line)
|
||||
return lines
|
||||
|
||||
|
||||
@@ -113,11 +113,13 @@ 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_the_harness_s_instructions_are_not_compared_to_the_base(self):
|
||||
# The instructions gate judges them (harness_budget); a driver's threads swing the whole count.
|
||||
base = recs(instructions={"harness-old/frame/per_run": 100000, "harness-new/frame/per_run": 50000,
|
||||
"harness-new/frame/own_per_run": 30000, "a/per_draw": 10000})
|
||||
now = recs(instructions={"harness-old/frame/per_run": 105000, "harness-new/frame/per_run": 71000,
|
||||
"harness-new/frame/own_per_run": 31000, "a/per_draw": 10200})
|
||||
self.assertEqual(self.problems(now, base), ["instructions a/per_draw: 10000 -> 10200 (+2.0%)"])
|
||||
|
||||
def test_instructions_fail_past_one_percent(self):
|
||||
base = recs(instructions={"a/per_draw": 10000})
|
||||
@@ -610,45 +612,60 @@ class HarnessBudgetTests(unittest.TestCase):
|
||||
"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}
|
||||
counted = {"harness-new/frame/per_run": 61253, "harness-old/frame/per_run": 149185}
|
||||
counted = {"harness-new/frame/per_run": 61253, "harness-old/frame/per_run": 149185,
|
||||
"harness-new/frame/own_per_run": 40001, "harness-new/frame/others_per_run": 21252}
|
||||
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, 61253 instructions | "
|
||||
"old 100.0 us, GPU p50 80.2 us, 149185 instructions | 1.200, instructions 0.411",
|
||||
"frame new 120.0 us, GPU p50 81.0 us, 61253 instructions "
|
||||
"(40001 own) | old 100.0 us, GPU p50 80.2 us, 149185 instructions | 1.200, "
|
||||
"instructions 0.411, own over old 0.268",
|
||||
"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,
|
||||
counted = {"harness-new/frame/per_run": 161000, "harness-old/frame/per_run": 149000,
|
||||
"harness-new/frame/own_per_run": 61000, "harness-new/frame/others_per_run": 100000,
|
||||
"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 {}, {}"
|
||||
def lenient(own, ratio, others=100000, over=""):
|
||||
return (f"harness budget frame: LENIENT instructions new own {own} per run over old whole 149000 is "
|
||||
f"{ratio}; new others {others}, old's driver threads not separable{over}")
|
||||
|
||||
exact = "harness budget frame: EXACT instructions new own {} per run, {}"
|
||||
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.
|
||||
# over old's though it is. The whole count, a driver's threads in it, is over old's
|
||||
# and judges nothing: the runtime's own count is the one gated.
|
||||
with mock.patch.object(results, "STORED_INSTRUCTIONS", {}):
|
||||
self.assertEqual(budget("10de:1e87", counted), ([], [line.format(61000, "0.409", "none stored")]))
|
||||
self.assertEqual(budget("10de:1e87", counted), ([], [
|
||||
exact.format(61000, "none stored"), lenient(61000, "0.409")]))
|
||||
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})
|
||||
# Within 1.03 times the stored count: only the lenient line.
|
||||
self.assertEqual(budget("10de:1e87", counted), ([], [lenient(61000, "0.409")]))
|
||||
over = dict(counted, **{"harness-new/frame/own_per_run": 61900})
|
||||
self.assertEqual(budget("10de:1e87", over), ([
|
||||
exact.format(61900, "stored 60000, is 1.032") + ": past 1.03 times the stored count"],
|
||||
[lenient(61900, "0.415")]))
|
||||
under = dict(counted, **{"harness-new/frame/own_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})
|
||||
exact.format(59000, "stored 60000, is 0.983") + ": more than 1% under the stored count, "
|
||||
"which ratchets down to it", lenient(59000, "0.396")]))
|
||||
past_old = dict(counted, **{"harness-new/frame/own_per_run": 150000})
|
||||
self.assertEqual(budget("10de:1e87", past_old)[0], [
|
||||
line.format(150000, "1.007", "stored 60000") + ": new over old"])
|
||||
exact.format(150000, "stored 60000, is 2.500") + ": past 1.03 times the stored count",
|
||||
lenient(150000, "1.007", over=": new own over old whole")])
|
||||
# A whole count with no count of the runtime's own threads: the gate could not run.
|
||||
no_own = {key: value for key, value in counted.items() if "own" not in key and "others" not in key}
|
||||
self.assertEqual(budget("10de:1e87", no_own)[0], [
|
||||
"harness budget frame: instructions new 161000 per run, but no count of its own threads"])
|
||||
# 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], [
|
||||
|
||||
Reference in new issue
Block a user