Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit search thread pool size #5304

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions quickwit/quickwit-config/src/storage_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::ops::Deref;
use std::sync::OnceLock;
use std::{env, fmt};

use anyhow::ensure;
Expand Down Expand Up @@ -370,11 +371,14 @@ impl S3StorageConfig {
}

pub fn force_path_style_access(&self) -> Option<bool> {
let force_path_style_access = get_bool_from_env(
"QW_S3_FORCE_PATH_STYLE_ACCESS",
self.force_path_style_access,
);
Some(force_path_style_access)
static FORCE_PATH_STYLE: OnceLock<Option<bool>> = OnceLock::new();
*FORCE_PATH_STYLE.get_or_init(|| {
let force_path_style_access = get_bool_from_env(
"QW_S3_FORCE_PATH_STYLE_ACCESS",
self.force_path_style_access,
);
Some(force_path_style_access)
})
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion quickwit/quickwit-search/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub type Result<T> = std::result::Result<T, SearchError>;

use std::net::{Ipv4Addr, SocketAddr};
use std::sync::{Arc, OnceLock};
use std::thread;

pub use find_trace_ids_collector::FindTraceIdsCollector;
use quickwit_config::SearcherConfig;
Expand Down Expand Up @@ -97,7 +98,20 @@ pub type SearcherPool = Pool<SocketAddr, SearchServiceClient>;

fn search_thread_pool() -> &'static ThreadPool {
static SEARCH_THREAD_POOL: OnceLock<ThreadPool> = OnceLock::new();
SEARCH_THREAD_POOL.get_or_init(|| ThreadPool::new("search", None))
SEARCH_THREAD_POOL.get_or_init(|| {
let mut search_thread_pool_size =
quickwit_common::get_from_env_opt("QW_SEARCH_THREAD_POOL_SIZE");

if search_thread_pool_size.is_none() {
let mut thread = thread::available_parallelism()
.map(|n| n.get())
.unwrap_or(2);
thread = thread.saturating_sub(1); // reserve one thread to handle incoming requests
search_thread_pool_size = Some(thread);
}

ThreadPool::new("search", search_thread_pool_size)
})
}

/// GlobalDocAddress serves as a hit address.
Expand Down
7 changes: 7 additions & 0 deletions quickwit/quickwit-search/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,7 @@ pub fn jobs_to_leaf_request(
let mut search_request_for_leaf = request.clone();
search_request_for_leaf.start_offset = 0;
search_request_for_leaf.max_hits += request.start_offset;
search_request_for_leaf.index_id_patterns = Vec::new();

let mut leaf_search_request = LeafSearchRequest {
search_request: Some(search_request_for_leaf),
Expand All @@ -1580,6 +1581,12 @@ pub fn jobs_to_leaf_request(
// Group jobs by index uid, as the split offsets are relative to the index.
group_jobs_by_index_id(jobs, |job_group| {
let index_uid = &job_group[0].index_uid;
leaf_search_request
.search_request
.as_mut()
.unwrap()
.index_id_patterns
.push(index_uid.index_id.to_string());
let search_index_meta = search_indexes_metadatas.get(index_uid).ok_or_else(|| {
SearchError::Internal(format!(
"received job for an unknown index {index_uid}. it should never happen"
Expand Down
Loading