tangled
alpha
login
or
join now
ptr.pet
/
nsid-tracker
3
fork
atom
tracks lexicons and how many times they appeared on the jetstream
3
fork
atom
overview
issues
pulls
pipelines
refactor(server): make max_last_activity Duration
ptr.pet
7 months ago
ce8f1ca0
cbc9e661
verified
This commit was signed with the committer's
known signature
.
ptr.pet
SSH Key Fingerprint:
SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw=
+14
-12
3 changed files
expand all
collapse all
unified
split
server
src
db
handle.rs
mod.rs
main.rs
+4
-2
server/src/db/handle.rs
···
76
76
self.buf.lock().len()
77
77
}
78
78
79
79
-
pub fn since_last_activity(&self) -> u64 {
80
80
-
CLOCK.delta_as_nanos(self.last_insert.load(AtomicOrdering::Relaxed), CLOCK.raw())
79
79
+
pub fn since_last_activity(&self) -> Duration {
80
80
+
Duration::from_nanos(
81
81
+
CLOCK.delta_as_nanos(self.last_insert.load(AtomicOrdering::Relaxed), CLOCK.raw()),
82
82
+
)
81
83
}
82
84
83
85
pub fn suggested_block_size(&self) -> usize {
+9
-9
server/src/db/mod.rs
···
3
3
fmt::Debug,
4
4
io::Cursor,
5
5
ops::{Bound, Deref, RangeBounds},
6
6
-
path::{Path, PathBuf},
6
6
+
path::Path,
7
7
time::Duration,
8
8
};
9
9
10
10
use byteview::StrView;
11
11
-
use fjall::{Config, Keyspace, Partition, PartitionCreateOptions};
11
11
+
use fjall::{Keyspace, Partition, PartitionCreateOptions};
12
12
use itertools::{Either, Itertools};
13
13
-
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};
13
13
+
use rayon::iter::{IntoParallelIterator, ParallelIterator};
14
14
use rclite::Arc;
15
15
use rkyv::{Archive, Deserialize, Serialize, rancor::Error};
16
16
use smol_str::{SmolStr, ToSmolStr};
···
79
79
pub ks_config: fjall::Config,
80
80
pub min_block_size: usize,
81
81
pub max_block_size: usize,
82
82
-
pub max_last_activity: u64,
82
82
+
pub max_last_activity: Duration,
83
83
}
84
84
85
85
impl DbConfig {
···
98
98
fn default() -> Self {
99
99
Self {
100
100
ks_config: fjall::Config::default(),
101
101
-
min_block_size: 512,
102
102
-
max_block_size: 500_000,
103
103
-
max_last_activity: Duration::from_secs(10).as_nanos() as u64,
101
101
+
min_block_size: 1000,
102
102
+
max_block_size: 1_000_000,
103
103
+
max_last_activity: Duration::from_secs(10),
104
104
}
105
105
}
106
106
}
···
114
114
hits: scc::HashIndex<SmolStr, Arc<LexiconHandle>>,
115
115
sync_pool: threadpool::ThreadPool,
116
116
event_broadcaster: broadcast::Sender<(SmolStr, NsidCounts)>,
117
117
-
eps: RateTracker<100>,
117
117
+
eps: RateTracker<100>, // 100 millis buckets
118
118
cancel_token: CancellationToken,
119
119
}
120
120
···
229
229
self.sync_pool
230
230
.execute(move || match handle.insert(block.key, block.data) {
231
231
Ok(_) => {
232
232
-
tracing::info!("{}: [{i}] synced {}", block.written, handle.nsid())
232
232
+
tracing::info!("{}: [{i}] synced {}", handle.nsid(), block.written)
233
233
}
234
234
Err(err) => tracing::error!("failed to sync block: {}", err),
235
235
});
+1
-1
server/src/main.rs
···
280
280
);
281
281
282
282
let nsids = from.get_nsids().collect::<Vec<_>>();
283
283
-
let eps_thread = std::thread::spawn({
283
283
+
let _eps_thread = std::thread::spawn({
284
284
let to = to.clone();
285
285
move || {
286
286
loop {