Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 262bb9f

Browse files
committed
Avoid starving UX threads
1 parent 3277b17 commit 262bb9f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

server/bleep/src/background.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,19 @@ impl BackgroundExecutor {
7575
_ = rayon::ThreadPoolBuilder::new()
7676
.spawn_handler(move |thread| {
7777
let tokio_ref = tokio_ref.clone();
78+
79+
let thread_priority = if cfg!(feature = "ee") {
80+
// 0-100 low-high
81+
// pick mid-range for worker threads so we don't starve other threads
82+
thread_priority::ThreadPriority::Crossplatform(49u8.try_into().unwrap())
83+
} else {
84+
// on the desktop it's full throttle, as number of cores is limited
85+
thread_priority::ThreadPriority::Max
86+
};
87+
7888
std::thread::Builder::new()
7989
.name("index-worker".to_owned())
80-
.spawn_with_priority(thread_priority::ThreadPriority::Max, move |_| {
90+
.spawn_with_priority(thread_priority, move |_| {
8191
let _tokio = tokio_ref.enter();
8292
thread.run()
8393
})

0 commit comments

Comments
 (0)