tracks lexicons and how many times they appeared on the jetstream

refactor(server): make max_last_activity Duration

ptr.pet ce8f1ca0 cbc9e661

verified
Changed files
+14 -12
server
+4 -2
server/src/db/handle.rs
···
self.buf.lock().len()
}
-
pub fn since_last_activity(&self) -> u64 {
-
CLOCK.delta_as_nanos(self.last_insert.load(AtomicOrdering::Relaxed), CLOCK.raw())
+
pub fn since_last_activity(&self) -> Duration {
+
Duration::from_nanos(
+
CLOCK.delta_as_nanos(self.last_insert.load(AtomicOrdering::Relaxed), CLOCK.raw()),
+
)
}
pub fn suggested_block_size(&self) -> usize {
+9 -9
server/src/db/mod.rs
···
fmt::Debug,
io::Cursor,
ops::{Bound, Deref, RangeBounds},
-
path::{Path, PathBuf},
+
path::Path,
time::Duration,
};
use byteview::StrView;
-
use fjall::{Config, Keyspace, Partition, PartitionCreateOptions};
+
use fjall::{Keyspace, Partition, PartitionCreateOptions};
use itertools::{Either, Itertools};
-
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};
+
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rclite::Arc;
use rkyv::{Archive, Deserialize, Serialize, rancor::Error};
use smol_str::{SmolStr, ToSmolStr};
···
pub ks_config: fjall::Config,
pub min_block_size: usize,
pub max_block_size: usize,
-
pub max_last_activity: u64,
+
pub max_last_activity: Duration,
}
impl DbConfig {
···
fn default() -> Self {
Self {
ks_config: fjall::Config::default(),
-
min_block_size: 512,
-
max_block_size: 500_000,
-
max_last_activity: Duration::from_secs(10).as_nanos() as u64,
+
min_block_size: 1000,
+
max_block_size: 1_000_000,
+
max_last_activity: Duration::from_secs(10),
}
}
}
···
hits: scc::HashIndex<SmolStr, Arc<LexiconHandle>>,
sync_pool: threadpool::ThreadPool,
event_broadcaster: broadcast::Sender<(SmolStr, NsidCounts)>,
-
eps: RateTracker<100>,
+
eps: RateTracker<100>, // 100 millis buckets
cancel_token: CancellationToken,
}
···
self.sync_pool
.execute(move || match handle.insert(block.key, block.data) {
Ok(_) => {
-
tracing::info!("{}: [{i}] synced {}", block.written, handle.nsid())
+
tracing::info!("{}: [{i}] synced {}", handle.nsid(), block.written)
}
Err(err) => tracing::error!("failed to sync block: {}", err),
});
+1 -1
server/src/main.rs
···
);
let nsids = from.get_nsids().collect::<Vec<_>>();
-
let eps_thread = std::thread::spawn({
+
let _eps_thread = std::thread::spawn({
let to = to.clone();
move || {
loop {