summaryrefslogtreecommitdiff
path: root/test/daemon.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 11:26:54 -0300
committerGabriel Schneider <[email protected]>2026-11-24 11:51:32 -0300
commit3baad4850b25a250649ab4928365b5c3d20f03df (patch)
treeb30d8c1bfd50e2fb07c223e93dc4e0bbe26f0717 /test/daemon.py
parent0252c830daf6184a9faefa32a7d1f384f5a86b94 (diff)
downloadpardes-3baad4850b25a250649ab4928365b5c3d20f03df.tar.gz
pardes-3baad4850b25a250649ab4928365b5c3d20f03df.zip
test/daemon.py --client-motion (FAILING on main, the hunt's first cause of "resizing feels very slow with several clients", 2026-11-24): a run of pointer motions over a client window is one input a pass, as the session's own window takes it, not an input each: on main 300 motions written at once to a window client's test feed were 305 inputs to its session and 382 units to a terminal client watching (each stepped by the session, sent to every client, replayed and drawn again by each); the cause is the client window's wait (dev/gui/gui.zig Client.wait, 1301-1308: every SDL event dispatched and fed at once, no motion coalesced) and, on the session's own window once a client is attached, Shell.split (gui.zig 2469-2483) checked before the coalescing loop of waitInput (2738-2761): the second queued motion is held for the next wait, so every raw motion is its own pump, frame and unit (a real window's: 1652 motions in 0.35 s were 1655 frames of the session over the next second, and an idle client window drew 1453 frames); run by --window-clients too, and alone by --client-motion
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/daemon.py')
-rw-r--r--test/daemon.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/test/daemon.py b/test/daemon.py
index c465b52f..16c40ea9 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -48,6 +48,9 @@ private HOME and runtime directory:
python3 -B test/daemon.py --window-clients <pardes> <pardes-gui>
window replica clients (hidden, offscreen) of a terminal's session,
at 0/30/80/207 ms, and a window's session serving replicas
+ python3 -B test/daemon.py --client-motion <pardes> <pardes-gui>
+ a run of pointer motions over a client window is a few inputs, not
+ one each (also run by --window-clients)
"""
import fcntl
import json
@@ -2145,6 +2148,82 @@ def window_clients(binary, gui_binary):
shutil.rmtree(root, ignore_errors=True)
+def client_motion(binary, gui_binary):
+ """A run of pointer motions over a client window is one move to its last
+ position, as the session's own window takes it (gui.zig waitInput): not
+ an input each, which the session steps one by one and sends every other
+ client as a unit each, every one of them replayed and drawn again (the
+ user's "resizing feels very slow with several clients", 2026-11-24: a
+ 1000 Hz mouse is a thousand inputs a second). 300 motions written at
+ once to a window client's test feed: the inputs it sent the session
+ (its PARDES_REPLICA_STATS) are a pass's each, a few, not 300; a terminal
+ client watching takes as few units."""
+ scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
+ scratch.mkdir(parents=True, exist_ok=True)
+ root = Path(tempfile.mkdtemp(prefix='cm-', dir=os.environ.get('TMPDIR') or scratch))
+ env = base_env()
+ env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'),
+ TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1')
+ (root / 'config' / 'pardes').mkdir(parents=True)
+ (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n')
+ notes = root / 'notes.txt'
+ notes.write_text(''.join(f'line {i} of the notes\n' for i in range(300)))
+ started, terms = [], []
+ w = None
+ try:
+ sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
+ started.append(sess.pid)
+ sock = root / 'pardes-replica.sock'
+ wait_for('the replica socket', sock.exists)
+ wait_for('the session\'s 9P socket', (root / 'pardes-9p-files.sock').exists)
+ nine = Client(root / 'pardes-9p-files.sock')
+ pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
+ tt = Term(24, 80)
+ terms.append(tt)
+ t = tt.spawn([binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(root / 't.stats')))
+ started.append(t.pid)
+ wait_for('the terminal client\'s first frame', lambda: b'line 3 of the notes' in tt.text(), timeout=30)
+ stats = root / 'w.stats'
+ w = Window(root, 'w', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_STATS=str(stats)))
+ started.append(w.pid)
+ w.keys(b'jj')
+ wait_for('the window\'s keys in the session', lambda: b'line' in nine.read(f'/pane/{pane}/body'), timeout=30)
+ time.sleep(2)
+ motions = 300
+ w.p.stdin.write(b''.join(f'\x1b]777;mouse;motion;0;{200 + 3 * i};{300 + i % 40}\x07'.encode() for i in range(motions)))
+ w.p.stdin.flush()
+ time.sleep(3)
+ assert w.close() == 0, w.said()[-800:]
+ said = checks(stats)[-1].split()
+ sent = int(said[said.index('inputs') + 1])
+ tt_units = None
+ t.send_signal(signal.SIGHUP)
+ t.wait(timeout=10)
+ tl = checks(root / 't.stats')
+ if tl:
+ words = tl[-1].split()
+ tt_units = int(words[words.index('units') + 1])
+ print(f'daemon: {motions} motions over a client window: it sent the session {sent} inputs; '
+ f'the terminal client took {tt_units} units')
+ assert sent <= 40, (f'{motions} pointer motions over a client window were {sent} inputs to its session, '
+ 'each a unit for every client: not coalesced as the session\'s own window does')
+ exit_session(nine, pane)
+ sess.wait(timeout=60)
+ nine.socket.close()
+ finally:
+ for tm in terms:
+ tm.close()
+ if w and w.p.poll() is None:
+ w.p.kill()
+ for pid in started + processes(root):
+ try:
+ os.kill(pid, signal.SIGKILL)
+ except OSError:
+ pass
+ shutil.rmtree(root, ignore_errors=True)
+
+
def joins(path):
"""A replica client's joins (PARDES_REPLICA_STATS, a line a link): how
many blobs each listed, how many it held already from the core it left
@@ -4212,6 +4291,9 @@ if __name__ == '__main__':
elif sys.argv[1:2] == ['--window-clients']:
window_clients(sys.argv[2], sys.argv[3])
pdf_window(sys.argv[2], sys.argv[3])
+ client_motion(sys.argv[2], sys.argv[3])
+ elif sys.argv[1:2] == ['--client-motion']:
+ client_motion(sys.argv[2], sys.argv[3])
elif sys.argv[1:2] == ['--ping']:
ping(sys.argv[2], sys.argv[3], sys.argv[4], int(sys.argv[5]) if len(sys.argv) > 5 else 50)
elif sys.argv[1:2] == ['--pair-gui']: