From 07b322d7a85e8c085aa8c434b3a744efe099dcae Mon Sep 17 00:00:00 2001 From: Stuart Cameron Date: Thu, 19 Nov 2026 22:29:33 +1100 Subject: [PATCH 1/3] fix(probe): havsfunc's Lut2 tables once per process; per-call timings and --budget (task #75) The push gate's quick plugin format probe timed out on macOS x64 (442-857 s passing, against 15 min), and nightly's full probe never finished there (its LUTDeCrawl child passed the 3600 s child timeout). Not a hang: havsfunc's LUTDeCrawl and LUTDeRainbow build four Lut2(function=lambda x, y: x & y) tables per call, a million Python calls each at 10 bits (1.95 s per table on an M1), rebuilt in every cell: 80% of the quick probe. - The probe's children wrap havsfunc's core so a Lut2 whose function reads only its arguments is evaluated once per process into a lut= list (bit-identical, same format checks). --no-lut-memo runs it as written. M1, 1.18.0-rc1: quick probe 86 s -> 33 s wall (205 -> 70 s CPU); full LUTDeCrawl 654 s -> 96 s; the same cells in every mode. - Each call prints one stderr line as it finishes (cells, refused, seconds). --budget N reports the calls still running (with their last cell) and the ones never started, kills the children and exits 3. A child past CHILD_TIMEOUT is one ERROR line naming its call, not a traceback. - Children run under Popen, registered so the watchdog can kill them; calls are submitted largest grid first. - Both probe tests run through support/plugin_probe_runner.dart, which streams those lines into the log and passes --budget 90 s under the test's timeout. A push-gate test checks the memo against the functions and that havsfunc's own LUTDeCrawl still takes it. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 8 +- Scripts/probe-plugin-formats.py | 279 +++++++++++++++++++-- app/test/plugin_format_contracts_test.dart | 96 ++++++- app/test/plugin_format_probe_test.dart | 25 +- app/test/support/plugin_probe_runner.dart | 70 ++++++ 5 files changed, 431 insertions(+), 47 deletions(-) create mode 100644 app/test/support/plugin_probe_runner.dart diff --git a/CLAUDE.md b/CLAUDE.md index 7d38cb95..603cf968 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -3143,7 +3143,13 @@ Headless Dart-VM tests. Three groups: `schema_converter_integration_test`, `template_call_arguments_test`, `plugin_format_contracts_test` (the quick plugin format probe against its table, the contracts, and `run_within()` on real low bits; the full probe - is the heavy `plugin_format_probe_test`), `removedirt_determinism_test` + is the heavy `plugin_format_probe_test`. Both print each call's time as it + finishes and stop themselves with `--budget` before their timeout, naming + the calls still running. The probe evaluates havsfunc's pure `Lut2` + functions once per process into lists, bit-identical and checked in the + push gate (task #75: LUTDeCrawl's 10-bit tables were 80% of the quick + probe, and the full probe never finished on macOS x64); + `--no-lut-memo` runs them as written), `removedirt_determinism_test` (task #57); need the per-arch `deps/` and (for whisper) `addons/`. - **Integration tests** — `integration_*_test.dart`. They spawn the worker diff --git a/Scripts/probe-plugin-formats.py b/Scripts/probe-plugin-formats.py index 9b28c7c7..6b7dc7d0 100755 --- a/Scripts/probe-plugin-formats.py +++ b/Scripts/probe-plugin-formats.py @@ -39,6 +39,14 @@ run through plugin_formats.run_within() (the `within` result, task #57): the plugin may refuse a size its contract pads. --quick does that only for a contract with a frame-size step. + +Each call prints one stderr line as it finishes (cells, refused, seconds). +--budget N stops the run after N seconds, says which calls were still +running (and their last finished cell) and which never started, kills the +children and exits 3: how a hang is told from slowness (task #75). A child +running past CHILD_TIMEOUT is reported as one ERROR line naming its call. +havsfunc's pure Lut2 functions are evaluated once per process into lists +(see _LutMemoStd, task #75); --no-lut-memo runs them as written. """ import argparse import concurrent.futures @@ -49,6 +57,8 @@ import subprocess import sys import tempfile +import threading +import time HERE = os.path.dirname(os.path.abspath(__file__)) REPO = os.path.dirname(HERE) @@ -335,15 +345,87 @@ def quick_grid(limited, padded=False, key=None): return grid + [cell('420', b, 0, w, h) for (w, h) in QUICK_SIZES.get(key, []) for b in (8, 16)] +# --------------------------------------------------------------------------- +# havsfunc's lookup tables, built once per process (task #75) +# +# LUTDeCrawl and LUTDeRainbow each call +# core.std.Lut2(a, b, function=lambda x, y: x & y) four times. At 10 bits +# VapourSynth calls that lambda 2^20 times per table: 1.95 s each, so 7.9 s of +# graph building per 10-bit cell on an M1 and several times that on the Intel +# runners, where the full probe's LUTDeCrawl child passed an hour. The same +# table as a list is bit-identical (the push gate checks it) and goes through +# the same format checks, so which formats a call accepts cannot change. Only +# a function that depends on nothing but its arguments (no closure, no +# defaults, no global or attribute names) is evaluated this way, and each +# table once per process; every other Lut2 call passes through untouched. +# --no-lut-memo runs the calls exactly as havsfunc writes them. +# --------------------------------------------------------------------------- + +class _LutMemoStd: + def __init__(self, std): + self._std = std + self.tables = {} + + def __getattr__(self, name): + return self._lut2 if name == 'Lut2' else getattr(self._std, name) + + @staticmethod + def _pure(f): + code = getattr(f, '__code__', None) + return (code is not None and not getattr(f, '__closure__', None) + and not getattr(f, '__defaults__', None) and not getattr(f, '__kwdefaults__', None) + and not code.co_names and code.co_argcount == 2) + + def _lut2(self, *args, **kw): + import vapoursynth as vs + f = kw.get('function') + names = ('clipa', 'clipb') + clips = list(args) + [kw.get(n) for n in names[len(args):]] + if (f is None or len(args) > 2 or not self._pure(f) or any(k in kw for k in ('bits', 'floatout', 'lut', 'lutf')) + or len(clips) != 2 or not all(isinstance(c, vs.VideoNode) for c in clips) + or not all(c.format and c.format.sample_type == vs.INTEGER for c in clips)): + return self._std.Lut2(*args, **kw) + ba, bb = clips[0].format.bits_per_sample, clips[1].format.bits_per_sample + tkey = (f.__code__, ba, bb) + lut = self.tables.get(tkey) + if lut is None: + # Lut2's index is x + (y << bits of clipa). + lut = self.tables[tkey] = [f(x, y) for y in range(1 << bb) for x in range(1 << ba)] + rest = {k: v for k, v in kw.items() if k not in names and k != 'function'} + return self._std.Lut2(clips[0], clips[1], lut=lut, **rest) + + +class _LutMemoCore: + """Wraps a core (or havsfunc's akarin shim) so std.Lut2 goes through + _LutMemoStd; everything else passes through.""" + + def __init__(self, core): + self._core = core + self.std = _LutMemoStd(core.std) + + def __getattr__(self, name): + return getattr(self._core, name) + + +def memo_havsfunc_luts(): + sys.path.insert(0, TEMPLATES) + import havsfunc + if not isinstance(havsfunc.core, _LutMemoCore): + havsfunc.core = _LutMemoCore(havsfunc.core) + return havsfunc.core + + # --------------------------------------------------------------------------- # Child: run one call's cells, one JSON line per cell as it finishes # --------------------------------------------------------------------------- -def child(key, cells, fixtures, within=True): +def child(key, cells, fixtures, within=True, lut_memo=True): import ctypes import vapoursynth as vs core = vs.core calls = _calls() + if lut_memo: + memo_havsfunc_luts() run = calls[key]['run'] cache = {} @@ -425,40 +507,152 @@ def exit_status(code): return 'exit code %d' % code -def run_cells(key, cells, fixtures, within=True): +CHILD_TIMEOUT = 3600 # a backstop per child process; --budget is the real limit + + +class ChildTimeout(Exception): + pass + + +class Progress: + """What every call's children are doing, for the timing lines and the + --budget report. Also the one place children are started, so the + watchdog can kill them all.""" + + def __init__(self): + self.lock = threading.Lock() + self.stopped = False + self.calls = {} # key -> {'start', 'done', 'total', 'last', 'proc'} + + def submitted(self, key, total): + with self.lock: + self.calls[key] = {'start': None, 'end': None, 'done': 0, 'total': total, + 'last': None, 'proc': None} + + def spawn(self, key, argv): + with self.lock: + if self.stopped: + raise ChildTimeout('%s: stopped by --budget' % key) + st = self.calls.setdefault(key, {'start': None, 'end': None, 'done': 0, 'total': 0, + 'last': None, 'proc': None}) + if st['start'] is None: + st['start'] = time.monotonic() + p = subprocess.Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True) + st['proc'] = p + return p + + def cell_done(self, key, ck): + with self.lock: + st = self.calls[key] + st['done'] += 1 + st['last'] = ck + + def finished(self, key): + with self.lock: + st = self.calls[key] + st['end'] = time.monotonic() + st['proc'] = None + return st['end'] - st['start'] + + def stop(self): + """Kills every child and returns a report of where each call was.""" + now = time.monotonic() + with self.lock: + self.stopped = True + running, waiting = [], [] + for k, st in self.calls.items(): + if st['start'] is None: + waiting.append(k) + elif st['end'] is None: + running.append(' %-40s running %6.0f s, %d/%d cells done, last %s' + % (k, now - st['start'], st['done'], st['total'], st['last'] or '(none)')) + if st['proc'] is not None: + try: + st['proc'].kill() + except OSError: + pass + return running, waiting + + +PROGRESS = Progress() + + +def _child_once(key, cells, fixtures, within, lut_memo): + """Runs one child over cells; returns (results, returncode, stderr).""" + p = PROGRESS.spawn(key, [sys.executable, os.path.abspath(__file__), '--child', key]) + err = [] + drain = threading.Thread(target=lambda: err.append(p.stderr.read()), daemon=True) + drain.start() + timed_out = [] + + def expire(): + timed_out.append(True) + p.kill() + timer = threading.Timer(CHILD_TIMEOUT, expire) + timer.daemon = True + timer.start() + try: + p.stdin.write(json.dumps({'cells': cells, 'fixtures': fixtures, 'within': within, + 'lut_memo': lut_memo})) + p.stdin.close() + except BrokenPipeError: + pass + results = {} + last = None + for line in p.stdout: + if line.startswith('{'): + r = json.loads(line) + last = r.pop('key') + results[last] = r + PROGRESS.cell_done(key, last) + code = p.wait() + timer.cancel() + drain.join(5) + if timed_out: + raise ChildTimeout('%s: a child ran past %d s; last cell finished: %s (%d of %d)' + % (key, CHILD_TIMEOUT, last or 'none', len(results), len(cells))) + if PROGRESS.stopped: + raise ChildTimeout('%s: stopped by --budget' % key) + return results, code, ''.join(err) + + +def run_cells(key, cells, fixtures, within=True, lut_memo=True): """{cell key: {'ok', 'error'?}} for every cell, through as many child processes as crashes need. within=False skips the run_within() pass.""" results = {} todo = list(cells) while todo: - p = subprocess.run( - [sys.executable, os.path.abspath(__file__), '--child', key], - input=json.dumps({'cells': todo, 'fixtures': fixtures, 'within': within}), - capture_output=True, text=True, timeout=3600) - for line in p.stdout.splitlines(): - if line.startswith('{'): - r = json.loads(line) - results[r.pop('key')] = r + got, code, err = _child_once(key, todo, fixtures, within, lut_memo) + results.update(got) todo = [c for c in todo if cell_key(c) not in results] - if todo and p.returncode == 0: + if todo and code == 0: raise RuntimeError('%s: child exited cleanly without %d cells:\n%s' - % (key, len(todo), p.stderr[-2000:])) + % (key, len(todo), err[-2000:])) if todo: # The first cell not reported crashed it: re-run that one alone. first = todo.pop(0) - q = subprocess.run( - [sys.executable, os.path.abspath(__file__), '--child', key], - input=json.dumps({'cells': [first], 'fixtures': fixtures, 'within': within}), - capture_output=True, text=True, timeout=3600) - got = [json.loads(l) for l in q.stdout.splitlines() if l.startswith('{')] + got, code, _ = _child_once(key, [first], fixtures, within, lut_memo) if got: - r = got[0] - results[r.pop('key')] = r + results.update(got) else: - results[cell_key(first)] = {'ok': False, 'error': 'crash: ' + exit_status(q.returncode)} + results[cell_key(first)] = {'ok': False, 'error': 'crash: ' + exit_status(code)} return results +def _watchdog(budget): + """--budget: past it, say where every call is, kill the children, exit 3.""" + time.sleep(budget) + running, waiting = PROGRESS.stop() + out = ['--budget: %d s spent; stopping.' % budget] + out += ['calls still running:'] + (running or [' (none)']) + out += ['calls not started (%d): %s' % (len(waiting), ', '.join(waiting) or '(none)')] + sys.stderr.write('\n'.join(out) + '\n') + sys.stderr.flush() + sys.stdout.flush() + os._exit(3) + + def make_fixtures(tmp, sizes, ffmpeg): out = {} for (w, h) in sizes: @@ -523,13 +717,17 @@ def main(): ap.add_argument('--list', action='store_true', help='print the probe list as JSON and exit') ap.add_argument('--jobs', type=int, default=max(1, (os.cpu_count() or 2) // 2)) ap.add_argument('--ffmpeg', default=os.environ.get('VAPOURBOX_FFMPEG', 'ffmpeg')) + ap.add_argument('--budget', type=float, + help='seconds: past this, report where every call is, kill the children, exit 3') + ap.add_argument('--no-lut-memo', action='store_true', + help="run havsfunc's Lut2 functions as written, not as one list per process") a = ap.parse_args() if a.quick and a.out: ap.error('--quick measures a subset and writes no summaries; write the table from a full run') if a.child: req = json.loads(sys.stdin.read()) - child(a.child, req['cells'], req['fixtures'], req.get('within', True)) + child(a.child, req['cells'], req['fixtures'], req.get('within', True), req.get('lut_memo', True)) return 0 calls = _calls() @@ -549,7 +747,11 @@ def main(): grids[k] = base_grid() + doc_grid() + size_grid() sizes = sorted({(c['w'], c['h']) for g in grids.values() for c in g}) + if a.budget: + threading.Thread(target=_watchdog, args=(a.budget,), daemon=True).start() + t0 = time.monotonic() table = {} + errors = [] with tempfile.TemporaryDirectory() as tmp: fixtures = make_fixtures(tmp, sizes, a.ffmpeg) with concurrent.futures.ThreadPoolExecutor(a.jobs) as ex: @@ -559,17 +761,40 @@ def main(): # frames by plugin_format_contracts_test, and running every # LUTDeCrawl/LUTDeRainbow cell again at 10-bit doubled their cost # (task #56: macOS x64 passed the push gate's 30 minutes). - futs = {k: ex.submit(run_cells, k, grids[k], fixtures, not a.quick or k in padded) - for k in keys} - for k in keys: - res = futs[k].result() + # Largest grids first, so a long call doesn't start last. + order = sorted(keys, key=lambda k: -len(grids[k])) + futs = {} + for k in order: + PROGRESS.submitted(k, len(grids[k])) + futs[ex.submit(run_cells, k, grids[k], fixtures, not a.quick or k in padded, + not a.no_lut_memo)] = k + for fut in concurrent.futures.as_completed(futs): + k = futs[fut] + try: + res = fut.result() + except (ChildTimeout, RuntimeError) as e: + errors.append(str(e).splitlines()[0]) + sys.stderr.write('%-40s ERROR: %s\n' % (k, errors[-1])) + sys.stderr.flush() + continue + secs = PROGRESS.finished(k) cells = grids[k] entry = {'cells': {cell_key(c): res[cell_key(c)] for c in cells}} if not a.quick: entry['summary'] = summarise(cells, res) table[k] = entry bad = sum(1 for r in res.values() if not r['ok']) - sys.stderr.write('%-40s %4d cells, %4d refused\n' % (k, len(cells), bad)) + sys.stderr.write('%-40s %4d cells, %4d refused, %7.1f s\n' % (k, len(cells), bad, secs)) + sys.stderr.flush() + sys.stderr.write('probe: %d calls in %.0f s, --jobs %d, lut memo %s\n' + % (len(keys), time.monotonic() - t0, a.jobs, 'off' if a.no_lut_memo else 'on')) + table = {k: table[k] for k in keys if k in table} + if errors: + for e in errors: + print('ERROR %s' % e) + if a.out: + print('the table was not written: %d call(s) did not finish' % len(errors)) + return 2 status = 0 if a.check: @@ -598,6 +823,8 @@ def main(): for d in diffs: print(d) status = 1 if diffs else 0 + if errors: + status = 2 if a.out: doc = { diff --git a/app/test/plugin_format_contracts_test.dart b/app/test/plugin_format_contracts_test.dart index bd840742..670a6a3f 100644 --- a/app/test/plugin_format_contracts_test.dart +++ b/app/test/plugin_format_contracts_test.dart @@ -21,6 +21,7 @@ import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as p; +import 'support/plugin_probe_runner.dart'; import 'support/worker_harness.dart'; String get _templatesDir => p.join(WorkerHarness.repoRoot, 'worker', 'templates'); @@ -287,6 +288,73 @@ for (w, h, b, o) in ((64, 48, 16, 8), (176, 144, 32, 8)): print(json.dumps(problems)) '''; +// The probe evaluates havsfunc's pure Lut2 functions into one list per +// process (task #75: 7.9 s -> 0.3 s per 10-bit LUTDeCrawl cell). The list must +// give the same picture and format as the function, a function that reads +// anything but its arguments must pass through, and havsfunc's own calls must +// still take the memo (else the probe is slow again, silently). +const _lutMemoCheck = r''' +import importlib.util, json, sys +import vapoursynth as vs +core = vs.core +spec = importlib.util.spec_from_file_location('probe', sys.argv[1]) +probe = importlib.util.module_from_spec(spec) +spec.loader.exec_module(probe) +sys.path.insert(0, sys.argv[2]) + +problems = [] +def check(cond, msg): + if not cond: + problems.append(msg) + +def same(a, b): + if a.format.id != b.format.id or (a.width, a.height, a.num_frames) != (b.width, b.height, b.num_frames): + return False + for p in range(a.format.num_planes): + st = core.std.PlaneStats(a, b, plane=p) + for n in range(a.num_frames): + if st.get_frame(n).props['PlaneStatsDiff'] != 0: + return False + return True + +def clip(fmt, seed): + c = core.std.BlankClip(width=64, height=48, format=fmt, length=3) + return core.grain.Add(c, var=800, uvar=800, constant=False, seed=seed) + +memo = probe._LutMemoCore(core) +asym8 = lambda x, y: (x * 3 + (y >> 1)) & 255 +asym10 = lambda x, y: (x * 3 + (y >> 1)) & 1023 +for fa, fb, f in ((vs.GRAY8, vs.GRAY8, asym8), (vs.GRAY8, vs.GRAY10, asym8), + (vs.GRAY10, vs.GRAY10, asym10), (vs.YUV420P10, vs.YUV420P8, asym10)): + a, b = clip(fa, 1), clip(fb, 2) + n = len(memo.std.tables) + got = memo.std.Lut2(a, b, function=f) + check(len(memo.std.tables) == n + 1, '%s x %s: the memo was not used' % (a.format.name, b.format.name)) + check(same(got, core.std.Lut2(a, b, function=f)), + '%s x %s: the list differs from the function' % (a.format.name, b.format.name)) + got = memo.std.Lut2(clipa=a, clipb=b, function=f, planes=[0]) + check(same(got, core.std.Lut2(a, b, function=f, planes=[0])), + '%s x %s, keywords and planes: the list differs' % (a.format.name, b.format.name)) + +t = 5 +n = len(memo.std.tables) +a = clip(vs.GRAY8, 3) +check(same(memo.std.Lut2(a, a, function=lambda x, y: (x + t) & 255), + core.std.Lut2(a, a, function=lambda x, y: (x + t) & 255)), 'a closure changed the picture') +check(same(memo.std.Lut2(a, a, function=lambda x, y: max(x, y)), core.std.Lut2(a, a, function=lambda x, y: max(x, y))), + 'a function naming a global changed the picture') +check(len(memo.std.tables) == n, 'a function that reads more than its arguments was memoised') + +import havsfunc as haf +src = clip(vs.YUV420P8, 4) +want = haf.LUTDeCrawl(src, ythresh=10, cthresh=10, maxdiff=50) +shim = probe.memo_havsfunc_luts() +got = haf.LUTDeCrawl(src, ythresh=10, cthresh=10, maxdiff=50) +check(len(shim.std.tables) > 0, 'havsfunc.LUTDeCrawl no longer goes through the memo: the probe is slow again') +check(same(got, want), 'havsfunc.LUTDeCrawl through the memo differs') +print(json.dumps(problems)) +'''; + void main() { setUpAll(() async { await WorkerHarness.ensureReady(); @@ -404,16 +472,32 @@ print(json.dumps({'contracts': {k: dict(v._asdict()) for k, v in pf.CONTRACTS.it expect(problems, isEmpty, reason: problems.join('\n')); }); + // macOS x64 is the slowest: 442-857 s before task #75 evaluated havsfunc's + // Lut2 tables once per process (LUTDeCrawl/LUTDeRainbow were 80% of it). + // The probe stops itself 90 s before this (--budget) and says which calls + // were still running. + const quickTimeout = Duration(minutes: 15); test('the bundle still refuses exactly what the table says (quick probe)', () async { - final sw = Stopwatch()..start(); - final r = await _python([_probe, '--quick', '--check', _tablePath, '--ffmpeg', WorkerHarness.ffmpegPath]); - // ignore: avoid_print - print(' quick probe: ${sw.elapsed.inSeconds} s'); + final r = await runPluginProbe(['--quick', '--check', _tablePath], timeout: quickTimeout); expect(r.exitCode, 0, reason: 'the bundle disagrees with ${p.basename(_tablePath)}. If a deps update changed a ' 'plugin\'s limits, re-run Scripts/probe-plugin-formats.py --out on every platform, ' - 'then update plugin_formats.CONTRACTS and the report:\n${r.stdout}\n${r.stderr}'); - }, timeout: const Timeout(Duration(minutes: 15))); + 'then update plugin_formats.CONTRACTS and the report. Exit 3 is --budget: the probe ' + 'ran out of time and says which calls were still running:\n${r.report}'); + }, timeout: const Timeout(quickTimeout)); + + test('the probe\'s Lut2 memo gives exactly what havsfunc\'s functions give (task #75)', () async { + final script = File(p.join(Directory.systemTemp.path, 'vb_lutmemo_$pid.py')); + await script.writeAsString(_lutMemoCheck); + try { + final r = await _python([script.path, _probe, _templatesDir]); + expect(r.exitCode, 0, reason: '${r.stdout}\n${r.stderr}'); + final problems = jsonDecode((r.stdout as String).trim().split('\n').last) as List; + expect(problems, isEmpty, reason: problems.join('\n')); + } finally { + if (script.existsSync()) script.deleteSync(); + } + }); test('MVTools Flow calls avoid the AVX2 upsizer below 8 block columns (task #69)', () async { final problems = await _pythonJson(_flowGuardCheck) as List; diff --git a/app/test/plugin_format_probe_test.dart b/app/test/plugin_format_probe_test.dart index 3edf9555..5a78c4cd 100644 --- a/app/test/plugin_format_probe_test.dart +++ b/app/test/plugin_format_probe_test.dart @@ -2,15 +2,15 @@ // every plugin call the template makes, at every reachable format, the // documentation rows (4:1:1, 9 and 14-bit), and the frame-size axis up to // 1080 lines. The push gate runs the quick subset -// (plugin_format_contracts_test.dart); this is the rest, nightly. +// (plugin_format_contracts_test.dart); this is the rest, nightly. Both print +// each call's time as it finishes (support/plugin_probe_runner.dart). @Tags(['heavy']) library; -import 'dart:io'; - import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as p; +import 'support/plugin_probe_runner.dart'; import 'support/worker_harness.dart'; void main() { @@ -18,19 +18,16 @@ void main() { await WorkerHarness.ensureReady(); }); + // macOS arm64 took 59 min (nightly 44342418084). macOS x64 never finished + // before task #75: its LUTDeCrawl child alone passed an hour. The probe + // stops itself 90 s before this (--budget) and says which calls were still + // running. + const fullTimeout = Duration(hours: 2); test('every plugin call refuses exactly what the table says, at every size', () async { final table = p.join(WorkerHarness.repoRoot, 'Tests', 'TestResources', 'plugin_format_table.json'); - final r = await Process.run( - WorkerHarness.pythonPath, - [ - p.join(WorkerHarness.repoRoot, 'Scripts', 'probe-plugin-formats.py'), - '--check', table, - '--ffmpeg', WorkerHarness.ffmpegPath, - ], - environment: {...WorkerHarness.workerEnv, 'VAPOURBOX_PLATFORM': WorkerHarness.platform}, - ); + final r = await runPluginProbe(['--check', table], timeout: fullTimeout); expect(r.exitCode, 0, reason: 'the bundle disagrees with ${p.basename(table)} (see the probe\'s docstring for ' - 'what to do):\n${r.stdout}\n${r.stderr}'); - }, timeout: const Timeout(Duration(hours: 2))); + 'what to do; exit 3 is --budget, exit 2 a call that did not finish):\n${r.report}'); + }, timeout: const Timeout(fullTimeout)); } diff --git a/app/test/support/plugin_probe_runner.dart b/app/test/support/plugin_probe_runner.dart new file mode 100644 index 00000000..98a2894a --- /dev/null +++ b/app/test/support/plugin_probe_runner.dart @@ -0,0 +1,70 @@ +// Runs Scripts/probe-plugin-formats.py for plugin_format_contracts_test +// (--quick, push gate) and plugin_format_probe_test (full, nightly). +// +// The probe prints one stderr line per call as it finishes (cells, refused, +// seconds); they are printed here as they arrive, so every CI log carries +// per-call timings, passing or not. --budget stops it 90 s before the test's +// own timeout and makes it say which calls were still running and which never +// started (task #75: a timeout used to leave nothing to tell a hang from +// slowness). +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart' as p; + +import 'worker_harness.dart'; + +class ProbeRun { + ProbeRun(this.exitCode, this.stdout, this.stderr, this.elapsed); + + final int exitCode; + final String stdout; + final String stderr; + final Duration elapsed; + + /// The failure reason: the --check differences, then the probe's log. + String get report => '$stdout\n$stderr'; +} + +/// Runs the probe with [args] (plus --ffmpeg and --budget) under the bundle's +/// Python. [timeout] is the calling test's timeout. +Future runPluginProbe(List args, {required Duration timeout}) async { + final budget = timeout - const Duration(seconds: 90); + final sw = Stopwatch()..start(); + final proc = await Process.start( + WorkerHarness.pythonPath, + [ + p.join(WorkerHarness.repoRoot, 'Scripts', 'probe-plugin-formats.py'), + ...args, + '--ffmpeg', WorkerHarness.ffmpegPath, + '--budget', '${budget.inSeconds}', + ], + environment: { + ...WorkerHarness.workerEnv, + 'VAPOURBOX_FFMPEG': WorkerHarness.ffmpegPath, + 'VAPOURBOX_PLATFORM': WorkerHarness.platform, + }, + ); + final out = StringBuffer(); + final err = StringBuffer(); + final outDone = proc.stdout.transform(utf8.decoder).listen(out.write).asFuture(); + final errDone = proc.stderr + .transform(utf8.decoder) + .transform(const LineSplitter()) + .listen((line) { + err.writeln(line); + // ignore: avoid_print + print(' probe ${(sw.elapsed.inMilliseconds / 1000).toStringAsFixed(0).padLeft(5)} s | $line'); + }).asFuture(); + // A backstop only: --budget ends the probe first. + final code = await proc.exitCode.timeout(budget + const Duration(seconds: 45), onTimeout: () { + proc.kill(ProcessSignal.sigkill); + err.writeln('killed: the probe outlived its --budget'); + return -1; + }); + await Future.wait([outDone, errDone]).timeout(const Duration(seconds: 10), onTimeout: () => []); + // ignore: avoid_print + print(' probe finished: exit $code after ${sw.elapsed.inSeconds} s'); + return ProbeRun(code, out.toString(), err.toString(), sw.elapsed); +} From e842cb7f4ba10b029f405358893c6a04dd4a9894 Mon Sep 17 00:00:00 2001 From: Stuart Cameron Date: Thu, 19 Nov 2026 22:56:37 +1100 Subject: [PATCH 2/3] test(probe): memo check builds no 10x10 reference table; 3 min timeout (task #75) The reference tables are built the slow way (function=), which passed the default 30 s on the macOS x64 and Windows runners. Mixed 8x10 / 10x8 pins the index order both ways at a quarter of the cost. Also corrects the per-cell figure: a cached table still costs ~0.28 s to hand over, so a 10-bit LUTDeCrawl cell goes 7.7 s -> 1.1 s on an M1. Co-Authored-By: Claude Opus 5.5 --- Scripts/probe-plugin-formats.py | 2 ++ app/test/plugin_format_contracts_test.dart | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Scripts/probe-plugin-formats.py b/Scripts/probe-plugin-formats.py index 6b7dc7d0..c1f57d64 100755 --- a/Scripts/probe-plugin-formats.py +++ b/Scripts/probe-plugin-formats.py @@ -358,6 +358,8 @@ def quick_grid(limited, padded=False, key=None): # a function that depends on nothing but its arguments (no closure, no # defaults, no global or attribute names) is evaluated this way, and each # table once per process; every other Lut2 call passes through untouched. +# Handing VapourSynth a cached list still costs about 0.28 s per table, so a +# 10-bit cell goes from 7.7 s to 1.1 s on an M1, not to nothing. # --no-lut-memo runs the calls exactly as havsfunc writes them. # --------------------------------------------------------------------------- diff --git a/app/test/plugin_format_contracts_test.dart b/app/test/plugin_format_contracts_test.dart index 670a6a3f..decd7c19 100644 --- a/app/test/plugin_format_contracts_test.dart +++ b/app/test/plugin_format_contracts_test.dart @@ -289,7 +289,7 @@ print(json.dumps(problems)) '''; // The probe evaluates havsfunc's pure Lut2 functions into one list per -// process (task #75: 7.9 s -> 0.3 s per 10-bit LUTDeCrawl cell). The list must +// process (task #75: 7.7 s -> 1.1 s per 10-bit LUTDeCrawl cell on an M1). The list must // give the same picture and format as the function, a function that reads // anything but its arguments must pass through, and havsfunc's own calls must // still take the memo (else the probe is slow again, silently). @@ -324,17 +324,20 @@ def clip(fmt, seed): memo = probe._LutMemoCore(core) asym8 = lambda x, y: (x * 3 + (y >> 1)) & 255 asym10 = lambda x, y: (x * 3 + (y >> 1)) & 1023 +# Mixed depths pin the index order both ways (x + (y << bits_a)) at a quarter +# of a 10x10 table's cost: the reference is built the slow way, which takes +# seconds per 10-bit table on the Intel runners. for fa, fb, f in ((vs.GRAY8, vs.GRAY8, asym8), (vs.GRAY8, vs.GRAY10, asym8), - (vs.GRAY10, vs.GRAY10, asym10), (vs.YUV420P10, vs.YUV420P8, asym10)): + (vs.YUV420P10, vs.YUV420P8, asym10)): a, b = clip(fa, 1), clip(fb, 2) n = len(memo.std.tables) got = memo.std.Lut2(a, b, function=f) check(len(memo.std.tables) == n + 1, '%s x %s: the memo was not used' % (a.format.name, b.format.name)) check(same(got, core.std.Lut2(a, b, function=f)), '%s x %s: the list differs from the function' % (a.format.name, b.format.name)) - got = memo.std.Lut2(clipa=a, clipb=b, function=f, planes=[0]) - check(same(got, core.std.Lut2(a, b, function=f, planes=[0])), - '%s x %s, keywords and planes: the list differs' % (a.format.name, b.format.name)) +a, b = clip(vs.YUV420P8, 1), clip(vs.YUV420P8, 2) +check(same(memo.std.Lut2(clipa=a, clipb=b, function=asym8, planes=[0]), core.std.Lut2(a, b, function=asym8, planes=[0])), + 'keywords and planes: the list differs') t = 5 n = len(memo.std.tables) @@ -497,7 +500,8 @@ print(json.dumps({'contracts': {k: dict(v._asdict()) for k, v in pf.CONTRACTS.it } finally { if (script.existsSync()) script.deleteSync(); } - }); + // About 6 s on an M1; the reference tables are much slower on the Intel runners. + }, timeout: const Timeout(Duration(minutes: 3))); test('MVTools Flow calls avoid the AVX2 upsizer below 8 block columns (task #69)', () async { final problems = await _pythonJson(_flowGuardCheck) as List; From f9ee3bf5a65223e54b15ee7f9dc96bd9ed349c96 Mon Sep 17 00:00:00 2001 From: Stuart Cameron Date: Thu, 19 Nov 2026 23:27:40 +1100 Subject: [PATCH 3/3] docs(report): task #75, the plugin format probe was slow, not hung Report with CI timings before and after, per-call and per-cell times, the Lut2 cost and identity, and the scripts that produced them; engineering note and index row. Co-Authored-By: Claude Opus 5.5 --- docs/ENGINEERING_NOTES.md | 20 +++ docs/reports/README.md | 1 + .../data/ci_quick_probe_times_before.tsv | 89 ++++++++++ .../full_probe_lut_calls_memo_arm64_j2.txt | 7 + .../full_probe_lut_calls_nomemo_arm64_j2.txt | 7 + .../data/quick_probe_memo_arm64_j4.txt | 71 ++++++++ .../data/quick_probe_nomemo_arm64_j4.txt | 71 ++++++++ .../data/time_quick_serial_deps1.16_arm64.txt | 71 ++++++++ .../task-75-quick-probe-timeout/index.html | 154 ++++++++++++++++++ .../scripts/ci_quick_probe_times.sh | 19 +++ .../scripts/lut_cost.py | 12 ++ .../scripts/lut_order.py | 12 ++ .../scripts/reproduce.sh | 17 ++ .../scripts/time_cells.py | 37 +++++ .../scripts/time_quick.py | 20 +++ 15 files changed, 608 insertions(+) create mode 100644 docs/reports/task-75-quick-probe-timeout/data/ci_quick_probe_times_before.tsv create mode 100644 docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_memo_arm64_j2.txt create mode 100644 docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_nomemo_arm64_j2.txt create mode 100644 docs/reports/task-75-quick-probe-timeout/data/quick_probe_memo_arm64_j4.txt create mode 100644 docs/reports/task-75-quick-probe-timeout/data/quick_probe_nomemo_arm64_j4.txt create mode 100644 docs/reports/task-75-quick-probe-timeout/data/time_quick_serial_deps1.16_arm64.txt create mode 100644 docs/reports/task-75-quick-probe-timeout/index.html create mode 100755 docs/reports/task-75-quick-probe-timeout/scripts/ci_quick_probe_times.sh create mode 100644 docs/reports/task-75-quick-probe-timeout/scripts/lut_cost.py create mode 100644 docs/reports/task-75-quick-probe-timeout/scripts/lut_order.py create mode 100755 docs/reports/task-75-quick-probe-timeout/scripts/reproduce.sh create mode 100644 docs/reports/task-75-quick-probe-timeout/scripts/time_cells.py create mode 100644 docs/reports/task-75-quick-probe-timeout/scripts/time_quick.py diff --git a/docs/ENGINEERING_NOTES.md b/docs/ENGINEERING_NOTES.md index 01c04401..defa8f6a 100644 --- a/docs/ENGINEERING_NOTES.md +++ b/docs/ENGINEERING_NOTES.md @@ -5479,6 +5479,26 @@ now read 0.000; the passthrough parity baseline is 0.19. Found on the way: `bt2020c`, …), filed as task #73. Report: [docs/reports/task-67-preview-rgb-decode](reports/task-67-preview-rgb-decode/index.html). +### The plugin format probe was slow, not hung: havsfunc's Lut2 tables (task #75, 2026-11-19) + +The push gate's quick probe timed out on macOS x64 (passing runs 442–857 s +against 15 min, two timeouts in 25 runs), and nightly's full probe never +finished there: its LUTDeCrawl child passed the probe's own 3600 s child +limit. One cause: havsfunc's `LUTDeCrawl` and `LUTDeRainbow` build four +`Lut2(function=lambda x, y: x & y)` tables per call, a million Python calls +each at 10 bits (1.99 s per table on an M1, 7.7 s per cell), rebuilt in every +cell: 80% of the quick probe. The probe's children now evaluate havsfunc's +pure `Lut2` functions once per process into `lut=` lists (bit-identical, the +same format checks; a cached list still costs ~0.28 s to hand over, so a cell +is 1.1 s). Quick probe on CI: macOS x64 232 s, arm64 91 s, Windows 108 s, +Linux 35 s; locally the full probe's two LUT calls went 654 s -> 96 s with the +same cells. Kept in the push gate rather than moved to nightly (nightly runs a +superset and was failing on the same cost). Every run now prints each call's +time, and `--budget` stops it before the test's timeout naming the calls still +running. Real 10-bit previews still pay ~8 s for the same tables (task #82); +nightly's other probe differences are tasks #69 and #81. Report: +[docs/reports/task-75-quick-probe-timeout](reports/task-75-quick-probe-timeout/index.html). + ### QTGMC's "uninitialised memory" at an odd chroma width was memcheck's model of `vpmaddwd` (task #70, 2026-11-19) Task #66 saw valgrind report QTGMC's output as uninitialised on x86 Linux at diff --git a/docs/reports/README.md b/docs/reports/README.md index 5592acc6..8fa0d3fe 100644 --- a/docs/reports/README.md +++ b/docs/reports/README.md @@ -129,5 +129,6 @@ to it. | 2026-11-17 | [Task #58: what the output conformance matrix found, fixed](task-58-output-conformance-findings/index.html) | Fixed all five: `pipe_source` keeps frames until served and raises on a dropped one (6/320 wrong runs under load → 0); primed AVI trims end with `-t`, not `-shortest` (49 → 50 pictures, Convert trimmed to the end too); MP1/MP2 rendered with the float decoder (exact from any seek); the reset join decided by the picture (`-copyts` + `setts`); the delayed AVI's late click was the oracle's (the source's own 23 ms). `knownFailures` empty | | 2026-11-18 | [Task #65: the IVTC preview's vspipe crash, and IVTC parity](task-65-ivtc-preview-teardown/index.html) | Fixed: vspipe R78 counts a frame done before writing it, so a one-frame preview whose frame is ready at once can be torn down under its callback (SIGSEGV; fixed upstream in R80). Task #46's evaluation-time `get_frame()` made the IVTC preview's frame ready at once: 2–3% of x86 IVTC previews under load crashed, 0/3960 with the read moved into the graph. Any preview can still hit it rarely (2/1200 Bwdif previews on macOS x64) until the bundle has R80+. The IVTC parity case needed a telecined fixture | | 2026-11-19 | [Task #68: vspipe's teardown race, backported to R78](task-68-vspipe-teardown-backport/index.html) | Built: R80+ is blocked (it dropped API 3; 12 bundled plugins are API 3 only, most with no API 4 release), so upstream's vspipe fix (4ff3f8a0) is applied to R78 on every platform, Windows by rebuilding `vspipe.exe` with Zig. With the race window widened, unpatched R78 crashed 400/400 runs and the patch 0/400; the x86 A/B on the built bundles is still to run (2026-11-19, measured in task #72: R78 71/32,160 crashes, patched 0/32,160) | +| 2026-11-19 | [Task #75: the plugin format probe timed out on macOS x64](task-75-quick-probe-timeout/index.html) | Slow, not hung: havsfunc's LUTDeCrawl/LUTDeRainbow built four 2^20-entry Python `Lut2` tables per 10-bit cell (80% of the quick probe; nightly's full probe never finished on macOS x64). The probe now evaluates pure `Lut2` functions once per process into bit-identical lists: macOS x64 quick probe 442–857 s (2 timeouts) -> 232 s. Kept in the push gate; per-call timings and `--budget` in every run. App previews still pay it (task #82) | | 2026-11-19 | [Task #73: matrices FFmpeg 9's scale can't name](task-73-swscale-matrix-tags/index.html) | Fixed: the preview's `in_color_matrix` goes through `ColorMetadata::swscale_matrix`. `scale` has no conversion (by name or number) for ycgco, bt2020c, smpte2085, chroma-derived-* or ictcp, so each SDR preview failed; now mapped (bt2020c/ictcp → bt2020, chroma-derived by primaries) or left to auto (ycgco, smpte2085). A frame tagged with one of them can't be converted at all (before frame, thumbnails, detectors): task #76 | | 2026-11-19 | [Task #72: the macOS x64 format-sweep SIGILL was vspipe's teardown race](task-72-macos-x64-sigill/index.html) | Diagnosed, fixed by deps 1.18.0-rc1: every macOS x64 sweep SIGILL on rc3 (5 rows, 4 runs) has vspipe's `frameDoneCallback` signalling a freed condition variable, which macOS traps (`_os_unfair_lock_unowned_abort`, `ud2`); Linux shows the same race as SIGSEGV. No plugin on the stack. x86 A/B with only `vspipe-bin` swapped: R78 71/32,160 crashes, patched 0/32,160 (Linux 66 vs 0, macOS 2 vs 0, Windows 3 vs 0). The CI crash-report step now names the race; no retry added | diff --git a/docs/reports/task-75-quick-probe-timeout/data/ci_quick_probe_times_before.tsv b/docs/reports/task-75-quick-probe-timeout/data/ci_quick_probe_times_before.tsv new file mode 100644 index 00000000..e857371a --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/ci_quick_probe_times_before.tsv @@ -0,0 +1,89 @@ +run job quick_probe_s deps +44484258865 windows 423 deps-v1.18.0-rc1 +44484258865 linux 117 deps-v1.18.0-rc1 +44484258865 macos (arm64, macos-15) 298 deps-v1.18.0-rc1 +44484258865 macos (x64, macos-15-intel) 857 deps-v1.18.0-rc1 +44481983232 linux 113 deps-v1.18.0-rc1 +44481983232 macos (x64, macos-15-intel) 803 deps-v1.18.0-rc1 +44481983232 windows 283 deps-v1.18.0-rc1 +44481983232 macos (arm64, macos-15) 318 deps-v1.18.0-rc1 +44411658811 windows 198 deps-v1.18.0-rc1 +44411658811 macos (arm64, macos-15) 277 deps-v1.18.0-rc1 +44411658811 linux 114 deps-v1.18.0-rc1 +44411658811 macos (x64, macos-15-intel) 803 deps-v1.18.0-rc1 +44318045317 linux 352 deps-v1.17.0-rc3 +44318045317 macos (x64, macos-15-intel) 593 deps-v1.17.0-rc3 +44318045317 windows 404 deps-v1.17.0-rc3 +44318045317 macos (arm64, macos-15) 269 deps-v1.17.0-rc3 +44306273218 linux 116 deps-v1.17.0-rc3 +44306273218 macos (x64, macos-15-intel) TIMEOUT deps-v1.17.0-rc3 +44306273218 macos (arm64, macos-15) 294 deps-v1.17.0-rc3 +44306273218 windows 285 deps-v1.17.0-rc3 +44291218371 windows 287 deps-v1.17.0-rc3 +44291218371 linux 116 deps-v1.17.0-rc3 +44291218371 macos (arm64, macos-15) 268 deps-v1.17.0-rc3 +44291218371 macos (x64, macos-15-intel) TIMEOUT deps-v1.17.0-rc3 +44277479142 linux 166 deps-v1.17.0-rc3 +44277479142 macos (arm64, macos-15) 316 deps-v1.17.0-rc3 +44277479142 windows 376 deps-v1.17.0-rc3 +44277479142 macos (x64, macos-15-intel) 585 deps-v1.17.0-rc3 +44260782676 windows 191 deps-v1.17.0-rc3 +44260782676 linux 351 deps-v1.17.0-rc3 +44260782676 macos (arm64, macos-15) 290 deps-v1.17.0-rc3 +44260782676 macos (x64, macos-15-intel) 648 deps-v1.17.0-rc3 +44256005348 macos (arm64, macos-15) 306 deps-v1.17.0-rc3 +44256005348 windows 301 deps-v1.17.0-rc3 +44256005348 macos (x64, macos-15-intel) 614 deps-v1.17.0-rc3 +44256005348 linux 160 deps-v1.17.0-rc3 +44237866325 linux 248 deps-v1.17.0-rc3 +44237866325 macos (x64, macos-15-intel) 655 deps-v1.17.0-rc3 +44237866325 macos (arm64, macos-15) 282 deps-v1.17.0-rc3 +44237866325 windows 422 deps-v1.17.0-rc3 +44234532522 windows 427 deps-v1.17.0-rc3 +44234532522 macos (x64, macos-15-intel) 771 deps-v1.17.0-rc3 +44234532522 macos (arm64, macos-15) 249 deps-v1.17.0-rc3 +44234532522 linux 351 deps-v1.17.0-rc3 +44227421728 macos (x64, macos-15-intel) 660 deps-v1.17.0-rc3 +44227421728 linux 327 deps-v1.17.0-rc3 +44227421728 windows 434 deps-v1.17.0-rc3 +44227421728 macos (arm64, macos-15) 337 deps-v1.17.0-rc3 +44223093873 windows 329 deps-v1.17.0-rc3 +44223093873 macos (x64, macos-15-intel) 514 deps-v1.17.0-rc3 +44223093873 linux 116 deps-v1.17.0-rc3 +44223093873 macos (arm64, macos-15) 277 deps-v1.17.0-rc3 +44222529261 linux 253 deps-v1.17.0-rc3 +44222529261 macos (arm64, macos-15) 300 deps-v1.17.0-rc3 +44222529261 macos (x64, macos-15-intel) 639 deps-v1.17.0-rc3 +44222529261 windows 421 deps-v1.17.0-rc3 +44078793187 windows 285 deps-v1.17.0-rc3 +44078793187 linux 210 deps-v1.17.0-rc3 +44078793187 macos (x64, macos-15-intel) 798 deps-v1.17.0-rc3 +44078793187 macos (arm64, macos-15) 325 deps-v1.17.0-rc3 +44075463187 macos (x64, macos-15-intel) 534 deps-v1.17.0-rc3 +44075463187 windows 430 deps-v1.17.0-rc3 +44075463187 linux 223 deps-v1.17.0-rc3 +44075463187 macos (arm64, macos-15) 303 deps-v1.17.0-rc3 +44071748096 linux 333 deps-v1.17.0-rc2 +44071748096 macos (arm64, macos-15) 338 deps-v1.17.0-rc2 +44071748096 macos (x64, macos-15-intel) 587 deps-v1.17.0-rc2 +44071748096 windows 327 deps-v1.17.0-rc2 +44062306190 linux 163 deps-v1.17.0-rc2 +44062306190 macos (arm64, macos-15) 301 deps-v1.17.0-rc2 +44062306190 macos (x64, macos-15-intel) 761 deps-v1.17.0-rc2 +44062306190 windows 432 deps-v1.17.0-rc2 +44053235342 macos (arm64, macos-15) 306 deps-v1.17.0-rc2 +44053235342 macos (x64, macos-15-intel) 648 deps-v1.17.0-rc2 +44053235342 linux 235 deps-v1.17.0-rc2 +44053235342 windows 403 deps-v1.17.0-rc2 +44028906054 linux 122 deps-v1.17.0-rc2 +44028906054 macos (arm64, macos-15) 241 deps-v1.17.0-rc2 +44028906054 windows 408 deps-v1.17.0-rc2 +44028906054 macos (x64, macos-15-intel) 442 deps-v1.17.0-rc2 +44008841552 windows 155 deps-v1.17.0-rc2 +44008841552 macos (x64, macos-15-intel) 546 deps-v1.17.0-rc2 +44008841552 linux 202 deps-v1.17.0-rc2 +44008841552 macos (arm64, macos-15) 239 deps-v1.17.0-rc2 +44004684546 macos (x64, macos-15-intel) 616 deps-v1.17.0-rc2 +44004684546 macos (arm64, macos-15) 307 deps-v1.17.0-rc2 +44004684546 windows 332 deps-v1.17.0-rc2 +44004684546 linux 109 deps-v1.17.0-rc2 diff --git a/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_memo_arm64_j2.txt b/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_memo_arm64_j2.txt new file mode 100644 index 00000000..8a94d613 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_memo_arm64_j2.txt @@ -0,0 +1,7 @@ +havsfunc.LUTDeRainbow 112 cells, 55 refused, 96.2 s +havsfunc.LUTDeCrawl 112 cells, 55 refused, 96.3 s +probe: 2 calls in 97 s, --jobs 2, lut memo on +real 97.27 +user 190.55 +sys 2.35 +memo exit 0 diff --git a/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_nomemo_arm64_j2.txt b/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_nomemo_arm64_j2.txt new file mode 100644 index 00000000..4691747f --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/full_probe_lut_calls_nomemo_arm64_j2.txt @@ -0,0 +1,7 @@ +havsfunc.LUTDeRainbow 112 cells, 55 refused, 646.8 s +havsfunc.LUTDeCrawl 112 cells, 55 refused, 654.4 s +probe: 2 calls in 655 s, --jobs 2, lut memo off +real 655.31 +user 1281.61 +sys 6.98 +nomemo exit 0 diff --git a/docs/reports/task-75-quick-probe-timeout/data/quick_probe_memo_arm64_j4.txt b/docs/reports/task-75-quick-probe-timeout/data/quick_probe_memo_arm64_j4.txt new file mode 100644 index 00000000..da302fbb --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/quick_probe_memo_arm64_j4.txt @@ -0,0 +1,71 @@ +havsfunc.QTGMC[SrchClipPP=1] 38 cells, 2 refused, 1.9 s +havsfunc.Deblock_QED 38 cells, 1 refused, 0.9 s +havsfunc.MCTemporalDenoise 38 cells, 2 refused, 2.7 s +havsfunc.QTGMC 38 cells, 2 refused, 2.8 s +deblock.Deblock 38 cells, 1 refused, 0.2 s +dctf.DCTFilter 38 cells, 1 refused, 0.2 s +bifrost.Bifrost 38 cells, 2 refused, 0.5 s +sangnom.SangNom 38 cells, 1 refused, 1.1 s +temporaldegrain2.TemporalDegrain2 38 cells, 1 refused, 4.0 s +vivtc.VFM 36 cells, 27 refused, 0.2 s +descratch.DeScratch 36 cells, 29 refused, 0.2 s +dedot.Dedot 36 cells, 27 refused, 0.2 s +pass.DeScratch 36 cells, 27 refused, 0.2 s +havsfunc.LSFmod 38 cells, 1 refused, 4.0 s +bwdif.Bwdif 4 cells, 0 refused, 0.2 s +nnedi3.nnedi3 4 cells, 0 refused, 0.2 s +vivtc.VDecimate 4 cells, 0 refused, 0.1 s +srestore.unblend 4 cells, 0 refused, 0.2 s +fb.FillBorders 4 cells, 0 refused, 0.1 s +lghost.LGhost 4 cells, 0 refused, 0.1 s +deflicker.global_deflicker 4 cells, 0 refused, 0.3 s +deflicker.reduce_flicker 4 cells, 0 refused, 0.2 s +spotless.SpotLess 4 cells, 0 refused, 0.2 s +removedirt.remove_dirt 4 cells, 0 refused, 0.2 s +havsfunc.SMDegrain 4 cells, 0 refused, 0.4 s +dfttest.DFTTest 4 cells, 0 refused, 0.2 s +fft3dfilter.FFT3DFilter 4 cells, 0 refused, 0.1 s +ttmpsm.TTempSmooth 4 cells, 0 refused, 0.1 s +flux.SmoothT 4 cells, 0 refused, 0.1 s +flux.SmoothST 4 cells, 0 refused, 0.1 s +havsfunc.STPresso 4 cells, 0 refused, 0.3 s +ctmf.CTMF 4 cells, 0 refused, 0.1 s +mv.Degrain1 4 cells, 0 refused, 0.1 s +mv.Degrain2 4 cells, 0 refused, 0.1 s +mv.Degrain3 4 cells, 0 refused, 0.2 s +bm3d 4 cells, 0 refused, 1.9 s +vszip.NLMeans 4 cells, 0 refused, 0.2 s +mclean.mClean 4 cells, 0 refused, 0.4 s +havsfunc.ContraSharpening 4 cells, 0 refused, 0.3 s +zsmooth.CCD 4 cells, 0 refused, 0.1 s +zsmooth.Cnr4 4 cells, 0 refused, 0.2 s +havsfunc.DeHalo_alpha 4 cells, 0 refused, 0.6 s +havsfunc.FineDehalo 4 cells, 0 refused, 0.7 s +havsfunc.FineDehalo2 4 cells, 0 refused, 0.3 s +havsfunc.YAHR 4 cells, 0 refused, 0.2 s +havsfunc.EdgeCleaner 4 cells, 0 refused, 0.1 s +havsfunc.HQDeringmod 4 cells, 0 refused, 0.3 s +vine 4 cells, 0 refused, 0.1 s +havsfunc.FixChromaBleedingMod 38 cells, 1 refused, 13.8 s +mpeg2stinx 4 cells, 0 refused, 0.2 s +neo_f3kdb.Deband 4 cells, 0 refused, 0.1 s +havsfunc.daa 4 cells, 0 refused, 0.2 s +havsfunc.LUTDeRainbow 36 cells, 18 refused, 12.7 s +havsfunc.santiag 4 cells, 0 refused, 0.2 s +autochromafix.auto_chroma_fix 4 cells, 0 refused, 0.3 s +havsfunc.LUTDeCrawl 36 cells, 18 refused, 12.9 s +havsfunc.Vinverse 4 cells, 0 refused, 0.3 s +retinex.MSRCP 4 cells, 0 refused, 0.1 s +vszip.CLAHE 4 cells, 0 refused, 0.1 s +stabilize.weave 4 cells, 0 refused, 0.2 s +cas.CAS 4 cells, 0 refused, 0.1 s +eedi3m.EEDI3 4 cells, 0 refused, 0.3 s +havsfunc.SmoothLevels 4 cells, 0 refused, 0.6 s +warp.AWarpSharp2 4 cells, 0 refused, 0.1 s +grain.Add 4 cells, 0 refused, 0.1 s +mv.FlowFPS 4 cells, 0 refused, 0.2 s +mv.FlowInter 4 cells, 0 refused, 0.2 s +havsfunc.GrainFactory3 4 cells, 0 refused, 0.3 s +havsfunc.ChangeFPS 4 cells, 0 refused, 0.1 s +stabilize.correct_pitch 4 cells, 0 refused, 1.3 s +probe: 70 calls in 20 s, --jobs 4, lut memo on diff --git a/docs/reports/task-75-quick-probe-timeout/data/quick_probe_nomemo_arm64_j4.txt b/docs/reports/task-75-quick-probe-timeout/data/quick_probe_nomemo_arm64_j4.txt new file mode 100644 index 00000000..969e6769 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/quick_probe_nomemo_arm64_j4.txt @@ -0,0 +1,71 @@ +havsfunc.QTGMC[SrchClipPP=1] 38 cells, 2 refused, 1.7 s +havsfunc.MCTemporalDenoise 38 cells, 2 refused, 2.6 s +havsfunc.Deblock_QED 38 cells, 1 refused, 1.0 s +havsfunc.QTGMC 38 cells, 2 refused, 2.7 s +deblock.Deblock 38 cells, 1 refused, 0.2 s +dctf.DCTFilter 38 cells, 1 refused, 0.2 s +bifrost.Bifrost 38 cells, 2 refused, 0.4 s +sangnom.SangNom 38 cells, 1 refused, 1.2 s +temporaldegrain2.TemporalDegrain2 38 cells, 1 refused, 3.9 s +vivtc.VFM 36 cells, 27 refused, 0.2 s +descratch.DeScratch 36 cells, 29 refused, 0.1 s +pass.DeScratch 36 cells, 27 refused, 0.1 s +dedot.Dedot 36 cells, 27 refused, 0.2 s +havsfunc.LSFmod 38 cells, 1 refused, 3.5 s +bwdif.Bwdif 4 cells, 0 refused, 0.2 s +nnedi3.nnedi3 4 cells, 0 refused, 0.2 s +vivtc.VDecimate 4 cells, 0 refused, 0.1 s +srestore.unblend 4 cells, 0 refused, 0.2 s +fb.FillBorders 4 cells, 0 refused, 0.1 s +lghost.LGhost 4 cells, 0 refused, 0.1 s +deflicker.global_deflicker 4 cells, 0 refused, 0.3 s +deflicker.reduce_flicker 4 cells, 0 refused, 0.2 s +spotless.SpotLess 4 cells, 0 refused, 0.1 s +removedirt.remove_dirt 4 cells, 0 refused, 0.1 s +havsfunc.SMDegrain 4 cells, 0 refused, 0.4 s +dfttest.DFTTest 4 cells, 0 refused, 0.2 s +fft3dfilter.FFT3DFilter 4 cells, 0 refused, 0.2 s +ttmpsm.TTempSmooth 4 cells, 0 refused, 0.2 s +flux.SmoothT 4 cells, 0 refused, 0.1 s +flux.SmoothST 4 cells, 0 refused, 0.1 s +havsfunc.STPresso 4 cells, 0 refused, 0.3 s +ctmf.CTMF 4 cells, 0 refused, 0.1 s +mv.Degrain1 4 cells, 0 refused, 0.1 s +mv.Degrain2 4 cells, 0 refused, 0.2 s +mv.Degrain3 4 cells, 0 refused, 0.2 s +bm3d 4 cells, 0 refused, 1.9 s +vszip.NLMeans 4 cells, 0 refused, 0.1 s +mclean.mClean 4 cells, 0 refused, 0.4 s +havsfunc.ContraSharpening 4 cells, 0 refused, 0.3 s +zsmooth.CCD 4 cells, 0 refused, 0.1 s +zsmooth.Cnr4 4 cells, 0 refused, 0.1 s +havsfunc.DeHalo_alpha 4 cells, 0 refused, 0.5 s +havsfunc.FineDehalo 4 cells, 0 refused, 0.8 s +havsfunc.FineDehalo2 4 cells, 0 refused, 0.3 s +havsfunc.YAHR 4 cells, 0 refused, 0.2 s +havsfunc.EdgeCleaner 4 cells, 0 refused, 0.2 s +havsfunc.HQDeringmod 4 cells, 0 refused, 0.4 s +havsfunc.FixChromaBleedingMod 38 cells, 1 refused, 12.9 s +vine 4 cells, 0 refused, 0.2 s +mpeg2stinx 4 cells, 0 refused, 0.2 s +neo_f3kdb.Deband 4 cells, 0 refused, 0.2 s +havsfunc.daa 4 cells, 0 refused, 0.2 s +havsfunc.santiag 4 cells, 0 refused, 0.2 s +autochromafix.auto_chroma_fix 4 cells, 0 refused, 0.3 s +havsfunc.Vinverse 4 cells, 0 refused, 0.3 s +retinex.MSRCP 4 cells, 0 refused, 0.2 s +vszip.CLAHE 4 cells, 0 refused, 0.1 s +stabilize.weave 4 cells, 0 refused, 0.2 s +havsfunc.SmoothLevels 4 cells, 0 refused, 0.6 s +eedi3m.EEDI3 4 cells, 0 refused, 0.3 s +cas.CAS 4 cells, 0 refused, 0.1 s +warp.AWarpSharp2 4 cells, 0 refused, 0.1 s +grain.Add 4 cells, 0 refused, 0.1 s +havsfunc.GrainFactory3 4 cells, 0 refused, 0.3 s +mv.FlowFPS 4 cells, 0 refused, 0.2 s +mv.FlowInter 4 cells, 0 refused, 0.2 s +stabilize.correct_pitch 4 cells, 0 refused, 1.4 s +havsfunc.ChangeFPS 4 cells, 0 refused, 0.1 s +havsfunc.LUTDeCrawl 36 cells, 18 refused, 81.3 s +havsfunc.LUTDeRainbow 36 cells, 18 refused, 81.3 s +probe: 70 calls in 86 s, --jobs 4, lut memo off diff --git a/docs/reports/task-75-quick-probe-timeout/data/time_quick_serial_deps1.16_arm64.txt b/docs/reports/task-75-quick-probe-timeout/data/time_quick_serial_deps1.16_arm64.txt new file mode 100644 index 00000000..2ab16c00 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/data/time_quick_serial_deps1.16_arm64.txt @@ -0,0 +1,71 @@ +havsfunc.QTGMC 2.7 s 38 cells +havsfunc.QTGMC[SrchClipPP=1] 1.6 s 38 cells +bwdif.Bwdif 0.2 s 4 cells +nnedi3.nnedi3 0.2 s 4 cells +vivtc.VFM 0.2 s 36 cells +vivtc.VDecimate 0.2 s 4 cells +srestore.unblend 0.2 s 4 cells +fb.FillBorders 0.2 s 4 cells +lghost.LGhost 0.2 s 4 cells +deflicker.global_deflicker 0.3 s 4 cells +deflicker.reduce_flicker 0.2 s 4 cells +descratch.DeScratch 0.2 s 36 cells +pass.DeScratch 0.1 s 36 cells +spotless.SpotLess 0.2 s 4 cells +removedirt.remove_dirt 0.2 s 4 cells +havsfunc.SMDegrain 0.4 s 4 cells +havsfunc.MCTemporalDenoise 2.5 s 38 cells +dfttest.DFTTest 0.2 s 4 cells +fft3dfilter.FFT3DFilter 0.2 s 4 cells +ttmpsm.TTempSmooth 0.2 s 4 cells +flux.SmoothT 0.2 s 4 cells +flux.SmoothST 0.1 s 4 cells +havsfunc.STPresso 0.4 s 4 cells +ctmf.CTMF 0.2 s 4 cells +mv.Degrain1 0.1 s 4 cells +mv.Degrain2 0.1 s 4 cells +mv.Degrain3 0.1 s 4 cells +bm3d 1.6 s 4 cells +vszip.NLMeans 0.1 s 4 cells +mclean.mClean 0.4 s 4 cells +temporaldegrain2.TemporalDegrain2 3.9 s 38 cells +havsfunc.ContraSharpening 0.3 s 4 cells +zsmooth.CCD 0.1 s 4 cells +zsmooth.Cnr4 0.1 s 4 cells +havsfunc.DeHalo_alpha 0.4 s 4 cells +havsfunc.FineDehalo 0.6 s 4 cells +havsfunc.FineDehalo2 0.2 s 4 cells +havsfunc.YAHR 0.2 s 4 cells +havsfunc.EdgeCleaner 0.1 s 4 cells +havsfunc.HQDeringmod 0.3 s 4 cells +vine 0.1 s 4 cells +havsfunc.Deblock_QED 0.7 s 38 cells +deblock.Deblock 0.2 s 38 cells +dctf.DCTFilter 0.2 s 38 cells +mpeg2stinx 0.1 s 4 cells +neo_f3kdb.Deband 0.1 s 4 cells +havsfunc.daa 0.1 s 4 cells +havsfunc.santiag 0.2 s 4 cells +sangnom.SangNom 0.9 s 38 cells +autochromafix.auto_chroma_fix 0.3 s 4 cells +dedot.Dedot 0.1 s 36 cells +havsfunc.FixChromaBleedingMod 14.2 s 38 cells +havsfunc.LUTDeCrawl 89.8 s 36 cells +havsfunc.LUTDeRainbow 76.8 s 36 cells +bifrost.Bifrost 0.2 s 38 cells +havsfunc.Vinverse 0.2 s 4 cells +havsfunc.SmoothLevels 0.6 s 4 cells +retinex.MSRCP 0.1 s 4 cells +vszip.CLAHE 0.1 s 4 cells +stabilize.weave 0.1 s 4 cells +stabilize.correct_pitch 1.1 s 4 cells +eedi3m.EEDI3 0.2 s 4 cells +havsfunc.LSFmod 3.2 s 38 cells +cas.CAS 0.1 s 4 cells +warp.AWarpSharp2 0.1 s 4 cells +grain.Add 0.1 s 4 cells +havsfunc.GrainFactory3 0.2 s 4 cells +mv.FlowFPS 0.1 s 4 cells +mv.FlowInter 0.1 s 4 cells +havsfunc.ChangeFPS 0.1 s 4 cells +TOTAL wall 210.6 s, sum 210.6 s diff --git a/docs/reports/task-75-quick-probe-timeout/index.html b/docs/reports/task-75-quick-probe-timeout/index.html new file mode 100644 index 00000000..5530edd5 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/index.html @@ -0,0 +1,154 @@ + + + + + +Plugin probe timeout + + + +
+

Task #75: the plugin format probe timed out on macOS x64

+

2026-11-19 · local: macOS arm64 (M-series), deps 1.18.0-rc1 (1.16.0 where marked) · CI: GitHub's +macos-15-intel (i7-8700B, 4 vCPU), macos-15 (M1, 3 vCPU), windows-latest, ubuntu-24.04 · scripts in +scripts/, numbers in data/

+ +

Decision

+

The push gate's quick plugin format probe (plugin_format_contracts_test.dart) failed on macOS x64 +with "Test timed out after 15 minutes". It was slow, not hung, and one thing made it slow: +havsfunc's LUTDeCrawl and LUTDeRainbow build four +core.std.Lut2(a, b, function=lambda x, y: x & y) tables per call, and at 10 bits VapourSynth calls +that lambda a million times per table. The probe rebuilt them in every 10-bit cell. The same cost kept the +nightly full probe from ever finishing on macOS x64: its LUTDeCrawl child passed the probe's own +3600 s per-child limit.

+
    +
  • The probe's children now evaluate havsfunc's pure Lut2 functions once per process into a +lut= list (_LutMemoStd in Scripts/probe-plugin-formats.py). The list is +bit-identical and goes through the same format checks, so the table cannot change. A push-gate test checks the +identity and that havsfunc's own LUTDeCrawl still takes the memo. --no-lut-memo runs the +calls as written.
  • +
  • Each call prints its time as it finishes, in every CI log, and --budget stops the probe before the +test's timeout, naming the calls still running. A timeout can now tell a hang from slowness.
  • +
  • Kept in the push gate (the alternative was moving it to nightly): with the memo, macOS x64 takes +232 s where it took 442–857 s, and the push gate is the only place a deps bump meets the table +before merge. The 15 minute timeout stays, now with about 4× headroom.
  • +
  • The same tables cost real previews of 10-bit sources about 8 s each on an M1: filed as task #82 (a havsfunc +patch, needs a deps release). The nightly full probe also differs from the table on Linux and Windows for reasons +unrelated to time: task #69 (Flow at 64x48) and task #81 (znedi3 at 720x486 on x86, VFM documentation rows).
  • +
+ +

1. Slow, not hung

+

The quick probe's printed time in every job of 23 push-gate runs, 2026-11-17 to 2026-11-19 +(data/ci_quick_probe_times_before.tsv, from scripts/ci_quick_probe_times.sh):

+ + + + + + + + +
jobdepspassing runs (s)timeouts
macOS x641.17.0-rc2616, 546, 442, 648, 761, 5870
macOS x641.17.0-rc3534, 798, 639, 514, 660, 771, 655, 614, 648, 585, 5932
macOS x641.18.0-rc1803, 803, 8570
macOS arm64all239–3380
Windows x64all155–4340
Linux x64all109–352 (usually ~115)0
+

The two timeouts (main f3706092, run 44291218371; PR #223, run 44306273218) are the tail of a +distribution whose passing runs reached 857 s against 900 s. In both, every other test had passed (1804), no crash +report or crash: line appeared, and the probe was simply the last test still running. The probe never +runs vspipe, so task #68's teardown race could not reach it, and a crashing child (task #72's SIGILL) is recorded +and re-run, which shows as a table difference, not a timeout.

+

No single change started it. Task #56 raised the timeout to 30 minutes when its padded cells pushed macOS x64 past +15, then put it back to 15 after a speedup measured on arm64 only (81 s). From then on macOS x64 ran without +headroom. Bifrost 4.0 (rc3) brought no step; the three 1.18.0-rc1 runs are high but inside rc3's spread, and every +other platform was flat across the three bundles.

+ +

2. Where the time went

+

scripts/time_quick.py, every quick-probe call serially, deps 1.16.0 arm64 +(data/time_quick_serial_deps1.16_arm64.txt): 210 s in all, of which

+ + + + + + +
callcellsserial time
havsfunc.LUTDeCrawl3689.8 s
havsfunc.LUTDeRainbow3676.8 s
havsfunc.FixChromaBleedingMod3814.2 s
the other 67 callsabout 30 s
+

scripts/time_cells.py, one cell at a time (deps 1.18.0-rc1): a LUTDeCrawl cell takes 0.5 s at 8 bits, +7.7 s at 10 bits, and nothing at 12/16 (havsfunc refuses them up front). All of it is graph +building. scripts/lut_cost.py: one 10-bit Lut2(function=) takes 1.99 s; the same table +passed as a list takes 0.31 s, and R78's std.Expr has no bitand to replace it with. +scripts/lut_order.py: a list indexed x + (y << bits_a) gives exactly the +function's picture and format, for an asymmetric function at 10×10 and 8×10 bits.

+

The quick grid gives each of the two calls 9 cells at 10 bits (3 subsamplings × 3 field flags), each rebuilding the +same four tables. The full probe rebuilds them about 70 times per call: every 10-bit cell twice (the plugin and +run_within()), and every 12/16-bit cell's run_within(), which converts to 10 bits.

+ +

3. With the tables built once per process

+

A cached table still costs about 0.28 s to hand to VapourSynth, so a 10-bit LUTDeCrawl cell goes from +7.7 s to 1.1 s (time_cells.py … memo), not to nothing. Local, deps 1.18.0-rc1 arm64:

+ + + + +
runwithout memowith memoresult
quick probe, --jobs 486 s wall, 205 s CPU33 s wall, 70 s CPUboth clean against the table; identical refusals per call
full probe, LUTDeCrawl + LUTDeRainbow, --jobs 2654 s96 sboth clean; 112 cells, 55 refused each
+

Files: data/quick_probe_{memo,nomemo}_arm64_j4.txt, +data/full_probe_lut_calls_{memo,nomemo}_arm64_j2.txt.

+

On CI (push-gate run 44515328673, branch at c6448e16), quick probe:

+ + + + + + +
jobbefore (s)after (s)LUTDeCrawl / LUTDeRainbow after (s)
macOS x64 (--jobs 2)442–857, 2 timeouts23272.6 / 100.3
macOS arm64 (--jobs 1)239–3389117.3 / 16.6
Windows x64155–43410835.5 / 37.4
Linux x64109–3523511.4 / 11.8
+

Further runs are listed in section 5.

+ +

4. What the change is, and what it is not

+
    +
  • Only pure functions. The memo takes a Lut2 function only when it has no closure, +no defaults and names nothing (co_names empty), so its value depends on its two arguments alone; with +bits, floatout, lut or lutf, or non-integer clips, the call +passes through. havsfunc's x & y qualifies; the push-gate test checks a closure and a function +naming max pass through.
  • +
  • The probe's measurement, not the template's call. It wraps havsfunc's module-level +core inside the probe's own children only, around whatever it already is (the akarin shim on arm64, +vs.core on x64). Real jobs are unchanged and still pay ~8 s per 10-bit preview (task #82).
  • +
  • Checked so it cannot rot silently. If havsfunc's lambdas change so the memo no longer applies, +the push gate fails with "havsfunc.LUTDeCrawl no longer goes through the memo". Breaking the purity test on purpose +made it fail with "the memo was not used" for every case.
  • +
  • Stalls are readable. --budget was exercised locally at 8 s: it listed the two +running calls with their elapsed time and last cell and the 59 not started, killed the children (none left) and +exited 3. A child past the 3600 s backstop is now one ERROR line naming the call and its last finished +cell, where the nightly printed a TimeoutExpired traceback.
  • +
+ +

5. CI runs on the branch

+ + + +
runworkflowmacOS x64macOS arm64WindowsLinuxnotes
44515328673push gate232 s91 s108 s35 sthe new memo check hit the default 30 s on macOS x64 and Windows (its reference tables are built the slow way); fixed by dropping the 10×10 case and a 3 min timeout
+ +

Limits

+
    +
  • Every CI time includes whatever else the push gate runs at once (the format sweep takes half the cores), so +times vary run to run; the "before" column is 25 runs, the "after" column a few.
  • +
  • The memo makes the probe faster and changes nothing it measures; it says nothing about the cost in the app, +which is task #82's.
  • +
  • Local timings are one M-series Mac; Intel per-table cost was not measured directly, only inferred from the CI +per-call lines.
  • +
+
+ + diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/ci_quick_probe_times.sh b/docs/reports/task-75-quick-probe-timeout/scripts/ci_quick_probe_times.sh new file mode 100755 index 00000000..33f39057 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/ci_quick_probe_times.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Task #75: the quick probe's time (or timeout) in every job of the last N +# ci-test.yml runs, from the logs. Needs gh, authenticated. +# ci_quick_probe_times.sh [N] +set -euo pipefail +N=${1:-25} +TMP=$(mktemp -d) +for run in $(gh run list --workflow ci-test.yml --limit "$N" --status completed --json databaseId --jq '.[].databaseId'); do + gh api "repos/{owner}/{repo}/actions/runs/$run/jobs?per_page=50" \ + --jq '.jobs[] | "\(.id)\t\(.name)"' | while IFS=$'\t' read -r job name; do + gh run view --job "$job" --log > "$TMP/$job.log" 2>/dev/null || continue + q=$(grep -oE "quick probe: [0-9]+ s|probe finished: exit [0-9-]+ after [0-9]+ s" "$TMP/$job.log" | head -1 || true) + grep -q "TimeoutException after 0:15" "$TMP/$job.log" && q="TIMEOUT" + deps=$(grep -oE "deps-v1\.[0-9]+\.[0-9]+(-rc[0-9]+)?" "$TMP/$job.log" | head -1 || true) + printf '%s\t%s\t%s\t%s\n' "$run" "$name" "${q:-?}" "${deps:-?}" + rm -f "$TMP/$job.log" + done +done +rmdir "$TMP" diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/lut_cost.py b/docs/reports/task-75-quick-probe-timeout/scripts/lut_cost.py new file mode 100644 index 00000000..3369540b --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/lut_cost.py @@ -0,0 +1,12 @@ +"""Task #75: Lut2 at 10 bits, function= against a precomputed lut= list, and std.Expr bitand.""" +import time, vapoursynth as vs +core = vs.core +c = core.std.BlankClip(format=vs.GRAY10, width=160, height=120, length=4) +c = core.grain.Add(c, var=500) +t=time.time(); a = core.std.Lut2(c, c[1:]+c[0], function=lambda x, y: x & y); print('Lut2 function= 10-bit %.2f s' % (time.time()-t)) +t=time.time(); lut = [x & y for y in range(1024) for x in range(1024)]; b = core.std.Lut2(c, c[1:]+c[0], lut=lut); print('Lut2 lut= list 10-bit %.2f s' % (time.time()-t)) +print('identical', core.std.PlaneStats(a, b).get_frame(0).props['PlaneStatsDiff'] == 0) +try: + t=time.time(); e = core.std.Expr([c, c[1:]+c[0]], 'x y bitand'); e.get_frame(0); print('Expr bitand %.3f s identical %s' % (time.time()-t, core.std.PlaneStats(a, e).get_frame(0).props['PlaneStatsDiff'] == 0)) +except Exception as ex: print('Expr bitand:', ex) +print(core.core_version.release_major, vs.__version__) diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/lut_order.py b/docs/reports/task-75-quick-probe-timeout/scripts/lut_order.py new file mode 100644 index 00000000..1c13f323 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/lut_order.py @@ -0,0 +1,12 @@ +"""Task #75: a lut= list indexed x + (y << bits_a) gives exactly what function= gives (asymmetric f, mixed depths).""" +import vapoursynth as vs +core = vs.core +for fa, fb in ((vs.GRAY10, vs.GRAY10), (vs.GRAY8, vs.GRAY10)): + a = core.grain.Add(core.std.BlankClip(format=fa, width=64, height=64, length=2), var=500, seed=1) + b = core.grain.Add(core.std.BlankClip(format=fb, width=64, height=64, length=2), var=500, seed=2) + f = lambda x, y: max(0, min(1023 if fa == vs.GRAY10 else 255, x * 3 - y // 2)) + r1 = core.std.Lut2(a, b, function=f) + ba, bb = fa.bits_per_sample if hasattr(fa,'bits_per_sample') else a.format.bits_per_sample, b.format.bits_per_sample + lut = [f(x, y) for y in range(1 << bb) for x in range(1 << a.format.bits_per_sample)] + r2 = core.std.Lut2(a, b, lut=lut) + print(a.format.name, b.format.name, 'identical:', core.std.PlaneStats(r1, r2).get_frame(0).props['PlaneStatsDiff'] == 0, r1.format.name, r2.format.name) diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/reproduce.sh b/docs/reports/task-75-quick-probe-timeout/scripts/reproduce.sh new file mode 100755 index 00000000..2500e883 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/reproduce.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Task #75: runs the timing scripts with a deps bundle's Python, the way +# WorkerHarness.workerEnv does on macOS/Linux. +# reproduce.sh +set -euo pipefail +D=$(cd "$1" && pwd) +HERE=$(cd "$(dirname "$0")" && pwd) +LIB=DYLD_LIBRARY_PATH; [ "$(uname)" = Linux ] && LIB=LD_LIBRARY_PATH +export PYTHONHOME="$D/python" PYTHONPATH="$D:$D/python-packages" PYTHONNOUSERSITE=1 \ + XDG_CONFIG_HOME="$D/config" "$LIB=$D/vapoursynth:$D/python/lib:$D/lib" +PY="$D/python/bin/python3"; FF="$D/ffmpeg/ffmpeg" +"$PY" "$HERE/lut_cost.py" +"$PY" "$HERE/lut_order.py" +"$PY" "$HERE/time_cells.py" "$FF" havsfunc.LUTDeCrawl,havsfunc.LUTDeRainbow,havsfunc.FixChromaBleedingMod +"$PY" "$HERE/time_cells.py" "$FF" havsfunc.LUTDeCrawl,havsfunc.LUTDeRainbow memo +"$PY" "$HERE/time_quick.py" "$FF" 1 nomemo +"$PY" "$HERE/time_quick.py" "$FF" 1 memo diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/time_cells.py b/docs/reports/task-75-quick-probe-timeout/scripts/time_cells.py new file mode 100644 index 00000000..cb43c0ec --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/time_cells.py @@ -0,0 +1,37 @@ +"""Task #75: one cell at a time, per depth and subsampling (graph build + one frame). +Usage: time_cells.py [memo]. Run with the bundle's Python under WorkerHarness.workerEnv (see reproduce.sh).""" +import os +import importlib.util, sys, time, tempfile +spec = importlib.util.spec_from_file_location('probe', os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..', 'Scripts', 'probe-plugin-formats.py')) +m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m) +import vapoursynth as vs +core = vs.core +calls = m._calls() +if len(sys.argv) > 3 and sys.argv[3] == 'memo': + m.memo_havsfunc_luts() +with tempfile.TemporaryDirectory() as tmp: + fx = m.make_fixtures(tmp, [m.BASE], sys.argv[1]) + path = fx['160x120'] + w, h = m.BASE + import ctypes + blank = core.std.BlankClip(width=w, height=h, format=vs.YUV444P16, length=m.FRAMES) + fsize = w*h*6 + def fill(n, f): + o = f.copy(); data = open(path,'rb').read()[n*fsize:(n+1)*fsize]; off=0 + for p in range(3): + b = ctypes.cast(o.get_write_ptr(p), ctypes.c_void_p).value; st=o.get_stride(p) + for y in range(h): + ctypes.memmove(b+y*st, data[off:off+w*2], w*2); off += w*2 + return o + src = core.std.ModifyFrame(blank, blank, fill) + for key in sys.argv[2].split(','): + for ss,(sw,sh) in (('420',(1,1)),('422',(1,0)),('444',(0,0))): + for bits in (8,10,12,16): + for field in (0,): + fmt = core.query_video_format(vs.YUV, vs.INTEGER, bits, sw, sh) + c = core.std.SetFieldBased(core.resize.Bicubic(src, format=fmt.id, dither_type='none'), field) + t=time.time(); + try: + o = calls[key]['run'](c); tb=time.time()-t; o.get_frame(5); ok='ok' + except Exception as e: tb=time.time()-t; ok=str(e).splitlines()[0][:60] + print('%-32s %sp%-2d f%d build %.2f s total %.2f s %s' % (key, ss, bits, field, tb, time.time()-t, ok), flush=True) diff --git a/docs/reports/task-75-quick-probe-timeout/scripts/time_quick.py b/docs/reports/task-75-quick-probe-timeout/scripts/time_quick.py new file mode 100644 index 00000000..b8bb08a0 --- /dev/null +++ b/docs/reports/task-75-quick-probe-timeout/scripts/time_quick.py @@ -0,0 +1,20 @@ +"""Task #75: every quick-probe call timed, serially or in parallel. +Usage: time_quick.py [memo|nomemo]. Run with the bundle's Python under WorkerHarness.workerEnv (see reproduce.sh).""" +import os +import importlib.util, sys, time, json, tempfile, concurrent.futures +spec = importlib.util.spec_from_file_location('probe', os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..', 'Scripts', 'probe-plugin-formats.py')) +m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m) +calls = m._calls(); limited = m.limited_calls(); padded = m.padded_calls() +grids = {k: m.quick_grid(k in limited, k in padded) for k in calls} +sizes = sorted({(c['w'], c['h']) for g in grids.values() for c in g}) +out = {} +memo = len(sys.argv) < 4 or sys.argv[3] != 'nomemo' +with tempfile.TemporaryDirectory() as tmp: + fx = m.make_fixtures(tmp, sizes, sys.argv[1]) + def one(k): + t = time.time(); r = m.run_cells(k, grids[k], fx, k in padded, memo); return k, time.time() - t, len(grids[k]), sum(1 for v in r.values() if 'crash' in v.get('error','')) + t0 = time.time() + with concurrent.futures.ThreadPoolExecutor(int(sys.argv[2])) as ex: + for k, dt, n, cr in ex.map(one, list(calls)): + out[k] = dt; print('%-42s %7.1f s %3d cells%s' % (k, dt, n, ' CRASH %d' % cr if cr else ''), flush=True) + print('TOTAL wall %.1f s, sum %.1f s' % (time.time() - t0, sum(out.values())))