Skip to content

Commit 1203b13

Browse files
quark-zjufacebook-github-bot
authored andcommitted
revisionstore: make indexedlog parameters configurable
Summary: Configs like `auto_sync_threshold`, `max_bytes_per_log`, `max_log_count` are unfortunately hardcoded somehow. Make them configurable. Reviewed By: MichaelCuevas Differential Revision: D75901673 fbshipit-source-id: 989a6d7aac9516be0e174091b7e8de1e39ffd33a
1 parent 106642c commit 1203b13

6 files changed

Lines changed: 25 additions & 0 deletions

File tree

eden/scm/lib/revisionstore/src/indexedlogauxstore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ impl AuxStore {
165165
.max_log_count(4)
166166
.max_bytes_per_log(250 * 1000 * 1000 / 4)
167167
.auto_sync_threshold(10 * 1024 * 1024)
168+
.load_specific_config(config, "aux")
168169
.create(true)
169170
.index("node", |_| {
170171
vec![IndexOutput::Reference(0..HgId::len() as u64)]

eden/scm/lib/revisionstore/src/indexedlogdatastore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl IndexedLogHgIdDataStore {
225225
.max_log_count(4)
226226
.max_bytes_per_log(2500 * 1000 * 1000)
227227
.auto_sync_threshold(50 * 1024 * 1024)
228+
.load_specific_config(config, "hgdata")
228229
.create(true)
229230
.index("node", |_| {
230231
vec![IndexOutput::Reference(0..HgId::len() as u64)]

eden/scm/lib/revisionstore/src/indexedloghistorystore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ impl IndexedLogHgIdHistoryStore {
208208
.max_log_count(4)
209209
.max_bytes_per_log(500 * 1000 * 1000)
210210
.auto_sync_threshold(10 * 1024 * 1024)
211+
.load_specific_config(config, "history")
211212
.create(true)
212213
.index("node_and_path", |_| {
213214
vec![IndexOutput::Reference(0..(HgId::len() * 2) as u64)]

eden/scm/lib/revisionstore/src/indexedlogtreeauxstore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl TreeAuxStore {
9292
.max_log_count(4)
9393
.max_bytes_per_log(150_000_000)
9494
.auto_sync_threshold(1_000_000)
95+
.load_specific_config(config, "treeaux")
9596
.create(true)
9697
.index("node", |_| {
9798
vec![IndexOutput::Reference(0..HgId::len() as u64)]

eden/scm/lib/revisionstore/src/indexedlogutil.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::sync::atomic::AtomicU64;
1414
use anyhow::Result;
1515
use configmodel::Config;
1616
use configmodel::ConfigExt;
17+
use configmodel::convert::ByteCount;
1718
use indexedlog::OpenWithRepair;
1819
use indexedlog::Result as IndexedlogResult;
1920
use indexedlog::log;
@@ -234,6 +235,25 @@ impl StoreOpenOptions {
234235
}
235236
}
236237

238+
/// Load specific configs `indexedlog.{prefix}-...`.
239+
pub(crate) fn load_specific_config(mut self, config: &dyn Config, prefix: &str) -> Self {
240+
if let Ok(Some(v)) =
241+
config.get_opt::<ByteCount>("indexedlog", &format!("{prefix}.auto-sync-threshold"))
242+
{
243+
self.auto_sync_threshold = Some(v.value());
244+
}
245+
if let Ok(Some(v)) =
246+
config.get_opt::<ByteCount>("indexedlog", &format!("{prefix}.max-bytes-per-log"))
247+
{
248+
self.max_bytes_per_log = Some(v.value());
249+
}
250+
if let Ok(Some(v)) = config.get_opt::<u8>("indexedlog", &format!("{prefix}.max-log-count"))
251+
{
252+
self.max_log_count = Some(v)
253+
}
254+
self
255+
}
256+
237257
/// When the store is rotated, control how many logs will be kept in the `RotateLog`.
238258
pub fn max_log_count(mut self, count: u8) -> Self {
239259
self.max_log_count = Some(count);

eden/scm/lib/revisionstore/src/lfs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ impl LfsIndexedLogBlobsStore {
332332
.max_log_count(4)
333333
.max_bytes_per_log(20_000_000_000 / 4)
334334
.auto_sync_threshold(50 * 1024 * 1024)
335+
.load_specific_config(config, "lfs")
335336
.index("sha256", |_| {
336337
vec![IndexOutput::Reference(0..Sha256::len() as u64)]
337338
})

0 commit comments

Comments
 (0)