Skip to content

chore(submodule): bump nyanpasu-utils to cap runtime worker threads - #446

Merged
greenhat616 merged 1 commit into
mainfrom
perf/cap-runtime-workers
Oct 17, 2026
Merged

greenhat616 merged 1 commit into
mainfrom
perf/cap-runtime-workers

Conversation

@greenhat616

Copy link
Copy Markdown
Collaborator

Draft. Depends on libnyanpasu/nyanpasu-utils#200. This PR pins crates/nyanpasu-utils to that PR's head commit (f57f9f077c3f1cb31da0e8261c21bee7bdd75c8f). Once #200 merges, re-point the submodule to the merged commit on nyanpasu-utils main before taking this out of draft.

Why

nyanpasu_utils::runtime::default_runtime() started one worker per logical CPU. nyanpasu-service runs on that runtime through runtime::block_on, and the app hands it to Tauri. nyanpasu-utils#200 caps it:

workers = available_parallelism().map_or(1, usize::from).min(4)

When available_parallelism() fails, the runtime starts one worker.

The app was measured on Windows 11 with 32 logical CPUs (details in nyanpasu-utils#200). Above four workers, more workers added threads and private memory without improving timer lateness or CPU time. With one worker, a single blocking operation stalled the runtime for up to seconds.

workers threads bg/heavy private MiB bg/heavy timer-late p99 / max under heavy ops
1 16/23 17.1/26.8 505–606 ms / 4092 ms
2 17/22 17.6/27.2 12.2 ms / 103 ms
4 19/24 17.5/27.8 13.0 ms / 23 ms
8 23/29 18.1/28.0 12.4 ms / 28 ms
32 49/53 20.0/31.9 12.4 ms / 25 ms

TOKIO_WORKER_THREADS no longer affects this runtime, because the explicit worker_threads takes precedence over it. Nothing here sets it.

The submodule moves from 7d923f8 to main plus the change. The only other difference is renovate's lockfile bumps to the crate's own Cargo.lock, which this workspace does not use. This workspace's Cargo.lock is unchanged.

Downstream

clash-nyanpasu will follow as a draft PR stacked on this one.

Checks

  • cargo clippy --all-targets --all-features --locked passed. The only warnings are ones already on main.
  • cargo test -p nyanpasu-utils --lib runtime passed: default_runtime_caps_its_workers.

Not tested

  • nyanpasu-service was not run or measured with the cap.
  • macOS and Linux were not run.

The shared runtime that nyanpasu-service and the app run on started one
worker per logical CPU. nyanpasu-utils now caps it at four, which keeps
the thread and memory cost flat on many-core machines without the stalls
a single worker shows when a task blocks.
@semanticdiff-com

semanticdiff-com Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/nyanpasu-utils  0% smaller

@greenhat616
greenhat616 marked this pull request as ready for review October 17, 2026 15:59
@greenhat616
greenhat616 merged commit 3061a0d into main Oct 17, 2026
11 checks passed
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.

1 participant