From 89f4b611e4e6e1732595d070184daf167b53bfb3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 04:51:01 -0300 Subject: tape: the budget is a count, step 7 (reports/pardes-handle-69-design.md section 2, P33's lean 3): Names.rescore stops after 3,000,000 of the scorer's cells (a key's bytes times the query's and one, what `match` can visit of a candidate, so a long query's slice is no longer than a short one's) and a tick's Places.fill after 512 KiB read, the places an insert above the view moves charged as read (with many places below it, the moving was what only the clock bounded), so no clock is read in a step: Tape.over, the free over, overNow, the budget site and the two clock reads are deleted, and a far client's guess of a key into a big name query is the session's step by construction (test/daemon.py --far's new scene, a Find over 40,000 names typed into: mispredicted 1, 1, 1 and 4 in four runs of the base, 0 in four of this); the constants measured by pardes-perf's new --search (ReleaseFast, this machine at a load of 12 to 24, every call's instructions counted): a tick's fill on the 18 MB text at most 23-24M instructions where the clock's 4 ms ticks took 47-75M, a rescore's scan on a long query at most 31.5M where the clock's took 32.6M; the longest rescore is not the scan but its sort of every hit at each call (about 125-145M instructions, 16-22 ms, with the clock and with the count alike: not bounded by either, left); the semantics word moves (the site's number goes: 7a610621b2f37456 -> df1f0502317ed362), so cross_replay across this change diverges at the first site after it, as it must; tui core-test 857/1008 (151 skipped), shell-test 1048/1051, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test 0 of 144 failed, both soaks diverged 0 unequal 0 corpus 22 of 22 no leak (bytes: the base's one unlisted `now` stop at 30 ms), daemon.py plain, --far, --games (alone, at load 24), --window-clients, --upgrade both ways against merge31 (new->old alone after the Adopt race); gui unit-test 1645/1649 (the perf check's BaselineHarnessMismatch); frames 77/77, perfab +0.055%, the 121 counts within 0.1% against tree2 (key-down on medium 10,039,595, render on medium 11,454,507; the base 10,039,283 and 11,454,252) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/daemon.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'test/daemon.py') diff --git a/test/daemon.py b/test/daemon.py index d134732b..887e6d0d 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -1425,6 +1425,74 @@ def games(binary, libs, secs=10): shutil.rmtree(root, ignore_errors=True) +def far_find(binary): + """A far client types a query into a Find over 40,000 names: each key + scores the names again a slice at a time (core/Names.zig `rescore`), + the client's guess of the key first. The slice is a count, the same on + both sides, so no guess is wrong (a slice the clock ended was the + client's clock's verdict, which the session's own contradicted).""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rq-', dir=scratch)) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_DATA_HOME=str(root / 'data'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_REPLICA_FAR='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + tree = root / 'tree' + for d in range(200): + (tree / f'module_{d}').mkdir(parents=True) + for f in range(200): + (tree / f'module_{d}' / f'replica_{f}.zig').touch() + notes = tree / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(300))) + started, terms = [], [] + try: + sess = subprocess.Popen([binary, '--detach=find', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + started.append(sess.pid) + wait_for('the replica socket', (root / 'pardes-replica.sock').exists) + wait_for('the session\'s 9P socket', (root / 'pardes-9p-find.sock').exists) + nine = Client(root / 'pardes-9p-find.sock') + text = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text') + t = Term(30, 100) + terms.append(t) + c = t.spawn([binary, f'--attach={root / "pardes-replica.sock"}:find'], + dict(env, PARDES_REPLICA_CHECK=str(root / 'q.check'), PARDES_REPLICA_STATS=str(root / 'q.stats'))) + started.append(c.pid) + wait_for('the client\'s first frame', lambda: b'line 3 of the notes' in t.text(), timeout=30) + time.sleep(.3) + # SPC f f: the Find, typed into, its names walked on the session's worker. + os.write(t.master, b' ff') + time.sleep(3) + wait_for('the client agrees once the walk is done', lambda: agreed(root / 'q.check', 0), timeout=60) + query = b'module_19/replica_3' + for ch in query: + os.write(t.master, bytes([ch])) + time.sleep(.15) + seen = len(checks(root / 'q.check')) + wait_for('the client agrees once quiet', lambda: agreed(root / 'q.check', seen), timeout=60) + c.send_signal(signal.SIGHUP) + c.wait(timeout=20) + line = (root / 'q.stats').read_text().split() + got = {line[i]: line[i + 1] for i in range(0, len(line) - 1, 2)} + print(f'daemon: a far client typed {len(query)} keys into a Find over 40,000 names: of its {got["inputs"]} inputs ' + f'{got["mispredicted"]} mispredicted, {got["stopped"]} stopped, {got["fast"]} applied at once') + assert got['mispredicted'] == '0', got + exit_session(nine, text) + sess.wait(timeout=60) + nine.socket.close() + finally: + for term in terms: + term.close() + for pid in started + processes(root): + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + shutil.rmtree(root, ignore_errors=True) + + def far_joins(sock, session, binary, n): """`n` far joins of one session in a row, each read whole (its blobs asked for by none, its zstd frames unpacked) and answering a ping, then @@ -2238,6 +2306,9 @@ if __name__ == '__main__': elif sys.argv[1:2] == ['--far']: far(sys.argv[2]) by_hash(sys.argv[2]) + far_find(sys.argv[2]) + elif sys.argv[1:2] == ['--far-find']: + far_find(sys.argv[2]) elif sys.argv[1:2] == ['--window-clients']: window_clients(sys.argv[2], sys.argv[3]) pdf_window(sys.argv[2], sys.argv[3]) -- cgit v1.3