Thanks to visit codestin.com
Credit goes to github.com

Skip to content

perf(workspace): move blocking workspace commands off the GTK main thread#85

Merged
Zeus-Deus merged 1 commit into
mainfrom
feature/74-perf-move-blocking-workspace-rs-commands-off-the-gtk-main
Jun 9, 2026
Merged

perf(workspace): move blocking workspace commands off the GTK main thread#85
Zeus-Deus merged 1 commit into
mainfrom
feature/74-perf-move-blocking-workspace-rs-commands-off-the-gtk-main

Conversation

@Zeus-Deus

Copy link
Copy Markdown
Owner

Fixes #74.

What

Six workspace commands were sync #[tauri::command] fns calling populate_git_info, which shells out to 5–8 git subprocesses. In Tauri v2 a sync command runs on the GTK main thread, so each call froze the entire UI (~100–300 ms warm cache, unbounded if a git subprocess wedges).

  • create_workspace, create_empty_workspace, get_or_create_home_workspace, create_workspace_with_preset, refresh_workspace_git_info, checkout_default_branch_in_workspaceasync fn, git work via the existing populate_git_info_async (blocking pool).
  • checkout_default_branch (slow on large repos) additionally wrapped in spawn_blocking.
  • create_workspace_impl becomes async; its control-socket caller (dispatch_request) was already async and now awaits it.
  • No State/non-Send guard held across an .await (only owned PathBufs cross the spawn_blocking boundary — same shape as commands/git.rs and create_worktree_workspace_impl).
  • Frontend invoke() already returns a Promise → zero caller changes.
  • package-lock.json: version field synced to 0.8.0 (stale since the bump).

Verification

  • cargo check
  • cargo test ✅ — 1677 passed; the 2 failures (project_codemux_entry_is_filtered_out, resolve_binary_finds_native_binary_from_project_root) fail identically on the unmodified baseline (machine-local MCP config / sandbox), pre-existing.
  • npm run check ✅, npm run test ✅ (1818 tests)

E2E (real app, real IPC, pathological git)

Booted the actual built app in an isolated environment (own XDG_RUNTIME_DIR/config/data/HOME, dedicated identifier + devUrl) with a git shim on PATH that sleeps 1.5 s per invocation (simulating a huge repo / cold cache), then drove create_workspace through the control socket against a real repo while probing concurrently:

  • create_workspace took 22.6 s of wall-clock git work (shim exercised) and succeeded; the new workspace snapshot carried real git info (branch=main, changed_files=1).
  • 59 samples of the GTK main thread's kernel wait channel while git children were in flight: every sample was S / poll_schedule_timeout (healthy event-loop park). Never wait4/pipe_read — the signature a sync handler would show while reaping a git child.
  • Concurrent IPC probes during the 22.6 s run: p50 = 1 ms, p90 = 1 ms — runtime fully responsive throughout.
  • Webview booted and hydrated against the patched backend (real frontend over real IPC).

…read

Six workspace commands were sync #[tauri::command] fns calling
populate_git_info, which shells out to 5-8 git subprocesses. In Tauri v2
a sync command runs on the GTK main thread, so each call froze the whole
UI (~100-300ms warm, unbounded if a git subprocess wedges).

- Convert create_workspace, create_empty_workspace,
  get_or_create_home_workspace, create_workspace_with_preset,
  refresh_workspace_git_info, and checkout_default_branch_in_workspace
  to async fn (Tokio worker pool) using the existing
  populate_git_info_async helper (blocking pool).
- checkout_default_branch additionally wrapped in spawn_blocking.
- create_workspace_impl becomes async; its control-socket caller in
  dispatch_request is already async and now awaits it.
- package-lock.json: sync version field to 0.8.0 (stale since the bump).

Same pattern as commands/git.rs (see its header note). Frontend invoke()
already returns a Promise, so no caller changes are needed.

Closes #74
@Zeus-Deus Zeus-Deus merged commit a633de5 into main Jun 9, 2026
4 checks passed
@Zeus-Deus Zeus-Deus deleted the feature/74-perf-move-blocking-workspace-rs-commands-off-the-gtk-main branch June 9, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[perf] Move blocking workspace.rs commands off the GTK main thread (async + spawn_blocking)

1 participant