global: delay compaction

This commit is contained in:
nym21
2026-03-27 23:02:31 +01:00
parent d24f3691cb
commit 45c77a4c3b
24 changed files with 44 additions and 38 deletions

View File

@@ -8195,7 +8195,7 @@ pub struct BrkClient {
impl BrkClient {
/// Client version.
pub const VERSION: &'static str = "v0.2.3";
pub const VERSION: &'static str = "v0.2.4";
/// Create a new client with the given base URL.
pub fn new(base_url: impl Into<String>) -> Self {

View File

@@ -53,7 +53,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -85,7 +85,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -504,7 +504,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -217,7 +217,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(starting_indexes)
}

View File

@@ -204,7 +204,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -25,7 +25,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -275,7 +275,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -57,7 +57,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -44,7 +44,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -34,7 +34,7 @@ impl Vecs {
.compute(indexer, inputs, starting_indexes, exit)?;
self.db.run_bg(move |db| {
let _lock = lock;
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -108,7 +108,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -51,7 +51,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -52,7 +52,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -25,7 +25,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -81,7 +81,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())

View File

@@ -62,7 +62,7 @@ impl Vecs {
let exit = exit.clone();
self.db.run_bg(move |db| {
let _lock = exit.lock();
db.compact()
db.compact_deferred_default()
});
Ok(())
}

View File

@@ -1,6 +1,11 @@
#![doc = include_str!("../README.md")]
use std::{fs, path::Path, thread, time::Instant};
use std::{
fs,
path::Path,
thread::{self, sleep},
time::{Duration, Instant},
};
use brk_error::Result;
use brk_iterator::Blocks;
@@ -8,7 +13,7 @@ use brk_rpc::Client;
use brk_types::Height;
use fjall::PersistMode;
use tracing::{debug, info};
use vecdb::{Exit, ReadOnlyClone, ReadableVec, Ro, Rw, StorageMode};
use vecdb::{Exit, RawDBError, ReadOnlyClone, ReadableVec, Ro, Rw, StorageMode};
mod constants;
mod indexes;
mod processor;
@@ -259,6 +264,8 @@ impl Indexer {
self.vecs.db.run_bg(move |db| {
let _lock = lock;
sleep(Duration::from_secs(5));
if !tasks.is_empty() {
let i = Instant::now();
for task in tasks {
@@ -269,11 +276,10 @@ impl Indexer {
let i = Instant::now();
fjall_db
.persist(PersistMode::SyncData)
.map_err(vecdb::RawDBError::other)?;
.map_err(RawDBError::other)?;
info!("Stores persisted in {:?}", i.elapsed());
}
db.flush()?;
db.compact()?;
Ok(())
});