Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0

Configure Feed

Select the types of activity you want to include in your feed.

it locks up a bit less like this

but still locks up

+17 -4
+17 -4
ufos/src/store.rs
··· 19 19 use tokio::time::sleep; 20 20 use tokio::sync::{mpsc::Receiver, Mutex}; 21 21 22 - /// Commit the RW batch immediately if this nubmer of events have been read off the mod queue 23 - const MAX_BATCHED_RW_EVENTS: usize = 3; 22 + /// Commit the RW batch immediately if this number of events have been read off the mod queue 23 + const MAX_BATCHED_RW_EVENTS: usize = 16; 24 24 25 25 /// Commit the RW batch immediately if this number of records is reached 26 26 /// ··· 29 29 /// - doing more work whenever scheduled means getting more CPU time in general 30 30 /// 31 31 /// this is higher than [MAX_BATCHED_RW_EVENTS] because account-deletes can have lots of items 32 - const MAX_BATCHED_RW_ITEMS: usize = 36; 32 + const MAX_BATCHED_RW_ITEMS: usize = 48; 33 33 34 34 35 + #[derive(Clone)] 35 36 struct SerialDb { 36 37 keyspace: Keyspace, 37 38 partition: PartitionHandle, 38 39 } 40 + 41 + // struct FakeMutex<T> { 42 + // thing: T, 43 + // } 44 + // impl<T: Clone> FakeMutex<T> { 45 + // pub fn new(thing: T) -> Self { 46 + // Self { thing } 47 + // } 48 + // pub async fn lock(&self) -> T { 49 + // self.thing.clone() 50 + // } 51 + // } 39 52 40 53 /** 41 54 * data format, roughly: ··· 155 168 pub async fn rw_loop(&self) -> anyhow::Result<()> { 156 169 // TODO: lock so that only one rw loop can possibly be run. or even better, take a mutable resource thing to enforce at compile time. 157 170 loop { 158 - sleep(Duration::from_secs_f64(0.001)).await; // todo: interval rate-limit instead 171 + sleep(Duration::from_secs_f64(0.15)).await; // todo: interval rate-limit instead 159 172 160 173 let db = self.db.lock().await; 161 174 let keyspace = db.keyspace.clone();