You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let the app choose how many idle task-pool threads stay #3294
A long-running desktop shell uses the shared task pool in short bursts, for example while decoding launcher icons. Once it has run two tasks concurrently, the pool can retain two rune-task threads for the rest of the process. The shell would like those threads and their allocator state to go away between bursts.
On a Fedora Linux desktop with an RTX 4070 Ti, opening and closing the launcher took the UI from 7 to 12 threads. After 15 seconds, it had 9 threads with the default and 7 with zero kept workers. In five warmed reopens per setting, the first launcher buffer was committed after a median 23.37 ms with two waiting workers and 24.47 ms with zero.
Add a process-wide builder setting, App::task_pool_keep_threads(usize). The default remains two. A value of zero lets every worker retire ten seconds after its last task. The next task starts a worker on demand. The web implementation ignores the setting.
Two behaviour changes come with it, at every keep count including the default:
A worker that ends runs the task::on_idle tidy on its way out whenever it ran work since its last tidy, whether or not the tidy was due. Before, an overflow thread ended without tidying, so the allocator pages it held free stayed with its exited heap.
The ten-second linger counts from the worker's last task, not from its last wake. Before, a notify taken by another worker (or a keep change) restarted a full linger.
Tests in task::pool: a pool with zero kept workers drains and accepts more work, and a worker that ends after work runs its tidy with one kept worker and with none (the pool takes its tidy hook as a seam, so the test uses its own hook).
Added process-wide builder App::task_pool_keep_threads(usize) (default 2, ignored on wasm32), updating the shared native rune-task pool immediately and waking waiting workers so a lower keep count takes effect without waiting for new work. Passing 0 lets every worker retire 10 seconds after its last task and spawn again on demand.
Updated retiring task-pool workers at every keep count to run task::on_idle on exit whenever work ran since their last tidy (even when the periodic IDLE / IDLE_MIN_GAP tidy timer was not yet due), while skipping a duplicate tidy if the worker already tidied while idle.
Anchored the 10-second linger deadline to each worker's last completed task instead of its last wake, so spurious wakes, notifies taken by another worker, and keep-count changes do not restart a full linger.
Verification
Verified locally (Windows): focused unit tests in rune-core (task::pool::tests, 7 tests covering zero-keep drain/reuse, scale-up/scale-down floor retention, tidy-on-exit with 1 kept worker, 0 kept workers, already-tidied and IDLE_MIN_GAP cases, linger anchoring across repeated wakes, and Tidy state transitions) and rune (app::tests::task_pool_keep_threads_defaults_to_two_and_updates_pool), clippy, wasm32-unknown-unknown check, and scripts/file-size.sh.
Verified in CI:check (Linux), windows-check, clippy, Android (aarch64/x86_64/apk), and size all passed.
Not tested on real hardware: live desktop shell thread counts / allocator RSS reclamation on Linux, macOS, or a real browser runtime were not measured on hardware. Please reopen if anything is still off.
Activity
Hona commentedon Dec 2, 2026
Merged in #3307 (
a063e1d42).Design
App::task_pool_keep_threads(usize)(default2, ignored onwasm32), updating the shared nativerune-taskpool immediately and waking waiting workers so a lower keep count takes effect without waiting for new work. Passing0lets every worker retire 10 seconds after its last task and spawn again on demand.task::on_idleon exit whenever work ran since their last tidy (even when the periodicIDLE/IDLE_MIN_GAPtidy timer was not yet due), while skipping a duplicate tidy if the worker already tidied while idle.Verification
rune-core(task::pool::tests, 7 tests covering zero-keep drain/reuse, scale-up/scale-down floor retention, tidy-on-exit with 1 kept worker, 0 kept workers, already-tidied andIDLE_MIN_GAPcases, linger anchoring across repeated wakes, andTidystate transitions) andrune(app::tests::task_pool_keep_threads_defaults_to_two_and_updates_pool),clippy,wasm32-unknown-unknowncheck, andscripts/file-size.sh.check(Linux),windows-check,clippy, Android (aarch64/x86_64/apk), andsizeall passed.feat(task): add App::task_pool_keep_threads and tidy retiring workers (…