From a985b4bc29c59133e64e8b20dfcab745ac37bcde Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 28 Jan 2025 14:48:01 +0100 Subject: [PATCH] Accept the max readers param by env var and increase it --- .../index-scheduler/src/index_mapper/index_map.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/index-scheduler/src/index_mapper/index_map.rs b/crates/index-scheduler/src/index_mapper/index_map.rs index 480dafa7c..efc11d6a2 100644 --- a/crates/index-scheduler/src/index_mapper/index_map.rs +++ b/crates/index-scheduler/src/index_mapper/index_map.rs @@ -1,4 +1,5 @@ use std::collections::BTreeMap; +use std::env::VarError; use std::path::Path; use std::time::Duration; @@ -300,9 +301,19 @@ fn create_or_open_index( enable_mdb_writemap: bool, map_size: usize, ) -> Result { + use std::str::FromStr; + let mut options = EnvOpenOptions::new(); options.map_size(clamp_to_page_size(map_size)); - options.max_readers(1024); + + let max_readers = match std::env::var("MEILI_INDEX_MAX_READERS") { + Ok(value) => u32::from_str(&value).unwrap(), + Err(VarError::NotPresent) => 100 * 1024, + Err(VarError::NotUnicode(value)) => { + panic!("Invalid unicode for the `MEILI_INDEX_MAX_READERS` env var: {value:?}") + } + }; + options.max_readers(max_readers); if enable_mdb_writemap { unsafe { options.flags(EnvFlags::WRITE_MAP) }; }