Skip to content

Commit 690f80f

Browse files
committed
more constants to configs
1 parent bc92dc4 commit 690f80f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

rust/log-service/src/lib.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,7 @@ impl LogServer {
876876
&self,
877877
request: GetAllCollectionInfoToCompactRequest,
878878
) -> Result<Response<GetAllCollectionInfoToCompactResponse>, Status> {
879-
// TODO(rescrv): Realistically we could make this configurable.
880-
// TODO(rescrv): Magic constant.
881-
const MAX_COLLECTION_INFO_NUMBER: usize = 10000;
882-
let mut selected_rollups = Vec::with_capacity(MAX_COLLECTION_INFO_NUMBER);
879+
let mut selected_rollups = Vec::with_capacity(self.config.rollup_max_size);
883880
// Do a non-allocating pass here.
884881
{
885882
let need_to_compact = self.need_to_compact.lock();
@@ -889,6 +886,9 @@ impl LogServer {
889886
>= request.min_compaction_size
890887
{
891888
selected_rollups.push((*collection_id, *rollup));
889+
if selected_rollups.len() >= self.config.rollup_max_size {
890+
break;
891+
}
892892
}
893893
}
894894
}
@@ -997,17 +997,16 @@ impl LogServer {
997997
.scan(
998998
cursor.position,
999999
Limits {
1000-
max_files: Some(10_000),
1000+
max_files: Some(self.config.rollup_max_size as u64),
10011001
max_bytes: Some(1_000_000_000),
1002-
max_records: Some(10_000),
1002+
max_records: Some(self.config.rollup_max_size as u64),
10031003
},
10041004
)
10051005
.await?;
10061006
if dirty_fragments.is_empty() {
10071007
return Ok((witness, cursor, vec![]));
10081008
}
1009-
// TODO(rescrv): Magic constant.
1010-
if dirty_fragments.len() >= 1_000 {
1009+
if dirty_fragments.len() >= self.config.rollup_max_size / 10 {
10111010
tracing::error!("Too many dirty fragments: {}", dirty_fragments.len());
10121011
}
10131012
let dirty_futures = dirty_fragments
@@ -2048,6 +2047,8 @@ pub struct LogServerConfig {
20482047
pub reinsert_threshold: u64,
20492048
#[serde(default = "LogServerConfig::default_rollup_interval")]
20502049
pub rollup_interval: Duration,
2050+
#[serde(default = "LogServerConfig::default_rollup_max_size")]
2051+
pub rollup_max_size: usize,
20512052
#[serde(default = "LogServerConfig::default_log_keepalive")]
20522053
pub log_keep_alive: Duration,
20532054
#[serde(default = "LogServerConfig::default_effectuate_log_transfer_batch_size")]
@@ -2085,6 +2086,11 @@ impl LogServerConfig {
20852086
Duration::from_secs(10)
20862087
}
20872088

2089+
/// return at most 10k collection infos from get all collections to compact
2090+
fn default_rollup_max_size() -> usize {
2091+
10_000
2092+
}
2093+
20882094
/// keep logs in-memory for 60 seconds
20892095
fn default_log_keepalive() -> Duration {
20902096
Duration::from_secs(60)
@@ -2120,6 +2126,7 @@ impl Default for LogServerConfig {
21202126
num_records_before_backpressure: Self::default_num_records_before_backpressure(),
21212127
reinsert_threshold: Self::default_reinsert_threshold(),
21222128
rollup_interval: Self::default_rollup_interval(),
2129+
rollup_max_size: Self::default_rollup_max_size(),
21232130
log_keep_alive: Self::default_log_keepalive(),
21242131
effectuate_log_transfer_batch_size: Self::default_effectuate_log_transfer_batch_size(),
21252132
effectuate_log_transfer_retries: Self::default_effectuate_log_transfer_retries(),

0 commit comments

Comments
 (0)