Title: Wait for a window's panes concurrently to speed up loads by tony · Pull Request #1056 · tmux-python/tmuxp · GitHub
Open Graph Title: Wait for a window's panes concurrently to speed up loads by tony · Pull Request #1056 · tmux-python/tmuxp
X Title: Wait for a window's panes concurrently to speed up loads by tony · Pull Request #1056 · tmux-python/tmuxp
Description: Summary Fix slow workspace loads (#1053): the per-pane readiness wait added in #1018 ran serially, so a window's load time grew with its pane count even though tmux warms every pane's shell concurrently. Replace the serial per-pane wait with a single concurrent barrier (_wait_for_panes_ready) that polls all of a window's default-shell panes together under one shared timeout. Preserve config-order semantics: each window is still built and finished before the next begins, so a later window can rely on a directory or side effect created by an earlier window's commands. Preserve the #365 zsh partial-line % fix: no pane is resized before its shell has drawn its prompt; select_layout runs once per window, after that window's barrier. Update the load progress display and before_script handling to match the new build-event ordering (see Follow-on changes). No config or YAML changes — same workspaces, faster loads. Motivation #1018 fixed the long-standing zsh % marker (#365) by waiting for each pane's shell to draw its prompt before applying its layout. That wait ran serially: pane N+1 wasn't split until pane N was ready. Because tmux starts a pane's shell the moment the pane is split, the shells in a window already warm up concurrently — only the observation of readiness was serial. With a heavy interactive rc file, a window's load cost became panes × shell-init, the regression reported in #1053. Design decisions Concurrent barrier per window. A window's panes are all split first, so their shells initialize together; a single barrier then waits for every default-shell pane in that window under one shared timeout. Readiness becomes one observation pass over all the panes instead of one blocking wait per pane. Per-window, not whole-session. Windows are built one at a time: create panes → barrier → lay out → dispatch commands → finish → next window. A window's commands run before the next window is created, so a later window can depend on side effects of an earlier one (e.g. a start_directory whose directory an earlier command created). The readiness wait is collapsed within a window; window-to-window ordering is unchanged. Split the newest pane; defer layout until after the barrier. A split resizes the pane it targets, and the build only ever splits the newest pane — created microseconds earlier and still sourcing its rc, which is safe to resize. The window's single select_layout is deferred until after its barrier, when every shell in the window is past its prompt. Why not keep a per-split select_layout? That call also resizes the older panes; if one is mid-prompt, the resize races zsh's prompt redraw and resurrects the % marker. Adaptive space reclaim. Without a per-split layout, a window with many panes can run out of room for the next split. _split_pane_reclaiming_space handles this: on a no-space failure it first waits for the window's existing panes (so they are safe to resize), runs select_layout to redistribute, then retries. Reclaim never resizes a not-ready pane, and a genuinely-too-small window still raises as before (#800). Internal and always-on. No new YAML keys or tunables; the barrier just makes the existing readiness behavior cheap. Follow-on changes Building a window's panes together (rather than one-ready-then-next) changes the grouping and ordering of build events, so two adjacent areas needed updates: Progress display (src/tmuxp/cli/_progress.py): window_done events now carry window identity, and the default progress bar tracks created vs. finished windows so the bar and the window label stay in sync as panes are created. before_script streaming (src/tmuxp/cli/load.py, src/tmuxp/util.py): before_script inherits the terminal's stdio by default so TTY-aware tools run interactively, the spinner starts only after before_script finishes, and its output is captured into the panel only when a nonzero --progress-lines is requested. synchronize-panes restore (src/tmuxp/workspace/builder.py): the temporary synchronize-panes disable is isolated to pane-command dispatch and skips targets for panes that exited during startup. Before / After Readiness wait for a window with N default-shell panes: Before: N serial waits (pane N+1 not split until pane N is ready) After: 1 concurrent barrier over all N panes (shells already warming together) Test plan Builder / readiness: test_wait_for_panes_ready_all_ready, test_wait_for_panes_ready_mixed — the barrier reports each pane ready and times out only non-prompt panes test_wait_for_pane_ready_returns_true, test_wait_for_pane_ready_timeout — the one-pane wrapper test_pane_readiness_waits_for_default_shell_panes — only default-shell panes enter the barrier (custom shell/window_shell skipped) test_build_waits_for_each_window_before_dispatch — a window's panes are awaited together before its commands run test_select_layout_called_once_per_window, test_layout_runs_after_readiness_barrier — the #365 invariant: select_layout runs once per window, after that window's barrier test_split_target_refreshes_without_readiness_wait — splitting no longer blocks on a per-pane prompt wait test_build_dispatches_window_commands_before_later_start_directory — a later window can depend on an earlier window's command side effects test_issue_800_default_size_many_windows — reclaim still re-raises when a window is genuinely too small (#800) test_synchronize_panes_disabled_during_pane_commands, test_synchronize_panes_ignores_exited_targets — sync isolation and skipping exited targets test_plugin_hook_order — on_window_create / after_window_finished order across windows Progress / before_script: test_builder_window_done_events_include_window_identity — completion events carry window identity test_spinner_default_progress_tracks_started_window_in_phase_one, test_spinner_default_progress_tracks_completed_window_in_phase_two — bar and label stay in sync test_load_workspace_pauses_spinner_for_before_script — spinner starts after before_script test_load_workspace_handles_explicit_before_script_progress_lines — before_script output captured into the panel only on explicit --progress-lines Suite / quality: uv run py.test — full suite green uv run mypy — strict, clean uv run ruff check . && uv run ruff format . — clean uv run py.test --doctest-modules src/tmuxp/workspace/builder.py — doctests for the readiness helpers
Open Graph Description: Summary Fix slow workspace loads (#1053): the per-pane readiness wait added in #1018 ran serially, so a window's load time grew with its pane count even though tmux warms every pane's shel...
X Description: Summary Fix slow workspace loads (#1053): the per-pane readiness wait added in #1018 ran serially, so a window's load time grew with its pane count even though tmux warms every pane...
Opengraph URL: https://github.com/tmux-python/tmuxp/pull/1056
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4e842195-3ff1-2836-3eec-a5ada338b9b7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8D1A:180C56:44F4D8:600DF2:6B007019 |
| html-safe-nonce | f57dafb67ef51defc519263bf1fe7cc2d79bdd4737445dbe6429f31d621989ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDFBOjE4MEM1Njo0NEY0RDg6NjAwREYyOjZCMDA3MDE5IiwidmlzaXRvcl9pZCI6IjI5Njc2NjM4NDE3Mjg1NTcwODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2fd9bac58b6662f504db74be2db1d90602de7e5700a8282e12e8403f1492fd8d |
| hovercard-subject-tag | pull_request:3938968386 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/tmux-python/tmuxp/pull/1056/files |
| twitter:image | https://avatars.githubusercontent.com/u/26336?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26336?s=400&v=4 |
| og:image:alt | Summary Fix slow workspace loads (#1053): the per-pane readiness wait added in #1018 ran serially, so a window's load time grew with its pane count even though tmux warms every pane's shel... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/tmux-python/tmuxp git https://github.com/tmux-python/tmuxp.git |
| octolytics-dimension-user_id | 37234308 |
| octolytics-dimension-user_login | tmux-python |
| octolytics-dimension-repository_id | 12398170 |
| octolytics-dimension-repository_nwo | tmux-python/tmuxp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 12398170 |
| octolytics-dimension-repository_network_root_nwo | tmux-python/tmuxp |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width