Skip to content

Commit 96faed6

Browse files
Disabling the lifo slot by default, and variable shard load (#5898)
Co-authored-by: Paul Masurel <paul@quickwit.io>
1 parent 9638362 commit 96faed6

File tree

3 files changed

+56
-32
lines changed

3 files changed

+56
-32
lines changed

quickwit/quickwit-common/src/lib.rs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,43 +84,42 @@ pub fn split_file(split_id: impl Display) -> String {
8484
format!("{split_id}.split")
8585
}
8686

87-
pub fn get_from_env<T: FromStr + Debug>(key: &str, default_value: T) -> T {
88-
if let Ok(value_str) = std::env::var(key) {
89-
if let Ok(value) = T::from_str(&value_str) {
90-
info!(value=?value, "using environment variable `{key}` value");
91-
return value;
92-
} else {
93-
error!(value=%value_str, "failed to parse environment variable `{key}` value");
94-
}
95-
}
96-
info!(value=?default_value, "using environment variable `{key}` default value");
97-
default_value
87+
fn get_from_env_opt_aux<T: Debug>(
88+
key: &str,
89+
parse_fn: impl FnOnce(&str) -> Option<T>,
90+
) -> Option<T> {
91+
let value_str = std::env::var(key).ok()?;
92+
let Some(value) = parse_fn(&value_str) else {
93+
error!(value=%value_str, "failed to parse environment variable `{key}` value");
94+
return None;
95+
};
96+
info!(value=?value, "using environment variable `{key}` value");
97+
Some(value)
9898
}
9999

100-
pub fn get_bool_from_env(key: &str, default_value: bool) -> bool {
101-
if let Ok(value_str) = std::env::var(key) {
102-
if let Some(value) = parse_bool_lenient(&value_str) {
103-
info!(value=%value, "using environment variable `{key}` value");
104-
return value;
105-
} else {
106-
error!(value=%value_str, "failed to parse environment variable `{key}` value");
107-
}
100+
pub fn get_from_env<T: FromStr + Debug>(key: &str, default_value: T) -> T {
101+
if let Some(value) = get_from_env_opt(key) {
102+
value
103+
} else {
104+
info!(default_value=?default_value, "using environment variable `{key}` default value");
105+
default_value
108106
}
109-
info!(value=?default_value, "using environment variable `{key}` default value");
110-
default_value
111107
}
112108

113109
pub fn get_from_env_opt<T: FromStr + Debug>(key: &str) -> Option<T> {
114-
let Some(value_str) = std::env::var(key).ok() else {
115-
info!("environment variable `{key}` is not set");
116-
return None;
117-
};
118-
if let Ok(value) = T::from_str(&value_str) {
119-
info!(value=?value, "using environment variable `{key}` value");
120-
Some(value)
110+
get_from_env_opt_aux(key, |val_str| val_str.parse().ok())
111+
}
112+
113+
pub fn get_bool_from_env_opt(key: &str) -> Option<bool> {
114+
get_from_env_opt_aux(key, parse_bool_lenient)
115+
}
116+
117+
pub fn get_bool_from_env(key: &str, default_value: bool) -> bool {
118+
if let Some(flag_value) = get_bool_from_env_opt(key) {
119+
flag_value
121120
} else {
122-
error!(value=%value_str, "failed to parse environment variable `{key}` value");
123-
None
121+
info!(default_value=%default_value, "using environment variable `{key}` default value");
122+
default_value
124123
}
125124
}
126125

quickwit/quickwit-common/src/runtimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Default for RuntimesConfig {
9797
fn start_runtimes(config: RuntimesConfig) -> HashMap<RuntimeType, Runtime> {
9898
let mut runtimes = HashMap::with_capacity(2);
9999

100-
let disable_lifo_slot = crate::get_bool_from_env("QW_DISABLE_TOKIO_LIFO_SLOT", false);
100+
let disable_lifo_slot = crate::get_bool_from_env("QW_DISABLE_TOKIO_LIFO_SLOT", true);
101101

102102
let mut blocking_runtime_builder = tokio::runtime::Builder::new_multi_thread();
103103
if disable_lifo_slot {

quickwit/quickwit-control-plane/src/indexing_scheduler/mod.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ use crate::metrics::ShardLocalityMetrics;
4242
use crate::model::{ControlPlaneModel, ShardEntry, ShardLocations};
4343
use crate::{IndexerNodeInfo, IndexerPool};
4444

45+
const DEFAULT_ENABLE_VARIABLE_SHARD_LOAD: bool = false;
46+
4547
pub(crate) const MIN_DURATION_BETWEEN_SCHEDULING: Duration =
4648
if cfg!(any(test, feature = "testsuite")) {
4749
Duration::from_millis(50)
@@ -121,7 +123,30 @@ impl fmt::Debug for IndexingScheduler {
121123
fn enable_variable_shard_load() -> bool {
122124
static IS_SHARD_LOAD_CP_ENABLED: OnceCell<bool> = OnceCell::new();
123125
*IS_SHARD_LOAD_CP_ENABLED.get_or_init(|| {
124-
!quickwit_common::get_bool_from_env("QW_DISABLE_VARIABLE_SHARD_LOAD", false)
126+
if let Some(enable_flag) =
127+
quickwit_common::get_bool_from_env_opt("QW_ENABLE_VARIABLE_SHARD_LOAD")
128+
{
129+
return enable_flag;
130+
}
131+
// For backward compatibility, if QW_DISABLE_VARIABLE_SHARD_LOAD is set, we accept this
132+
// value too.
133+
if let Some(disable_flag) =
134+
quickwit_common::get_bool_from_env_opt("QW_DISABLE_VARIABLE_SHARD_LOAD")
135+
{
136+
warn!(
137+
disable = disable_flag,
138+
"QW_DISABLE_VARIABLE_SHARD_LOAD is deprecated. Please use \
139+
QW_ENABLE_VARIABLE_SHARD_LOAD instead. We will use your setting in this version, \
140+
but will likely ignore it in future versions."
141+
);
142+
return !disable_flag;
143+
}
144+
// Defaulting to false
145+
info!(
146+
"QW_ENABLE_VARIABLE_SHARD_LOAD not set, defaulting to {}",
147+
DEFAULT_ENABLE_VARIABLE_SHARD_LOAD
148+
);
149+
DEFAULT_ENABLE_VARIABLE_SHARD_LOAD
125150
})
126151
}
127152

0 commit comments

Comments
 (0)