performance tests
This commit is contained in:
parent
afa5d449c6
commit
c1dd19265d
3 changed files with 18 additions and 16 deletions
|
@ -314,11 +314,11 @@ impl Database {
|
|||
.try_into()
|
||||
.expect("pdu cache capacity fits into usize"),
|
||||
)),
|
||||
auth_chain_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||
shorteventid_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||
eventidshort_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||
shortstatekey_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||
statekeyshort_cache: Mutex::new(LruCache::new(1_000_000)),
|
||||
auth_chain_cache: Mutex::new(LruCache::new(10_000_000)),
|
||||
shorteventid_cache: Mutex::new(LruCache::new(10_000_000)),
|
||||
eventidshort_cache: Mutex::new(LruCache::new(10_000_000)),
|
||||
shortstatekey_cache: Mutex::new(LruCache::new(10_000_000)),
|
||||
statekeyshort_cache: Mutex::new(LruCache::new(10_000_000)),
|
||||
our_real_users_cache: RwLock::new(HashMap::new()),
|
||||
appservice_in_room_cache: RwLock::new(HashMap::new()),
|
||||
stateinfo_cache: Mutex::new(LruCache::new(1000)),
|
||||
|
|
|
@ -21,7 +21,7 @@ thread_local! {
|
|||
|
||||
struct PreparedStatementIterator<'a> {
|
||||
pub iterator: Box<dyn Iterator<Item = TupleOfBytes> + 'a>,
|
||||
pub statement_ref: NonAliasingBox<rusqlite::Statement<'a>>,
|
||||
pub statement_ref: NonAliasingBox<rusqlite::CachedStatement<'a>>,
|
||||
}
|
||||
|
||||
impl Iterator for PreparedStatementIterator<'_> {
|
||||
|
@ -52,7 +52,7 @@ impl Engine {
|
|||
fn prepare_conn(path: &Path, cache_size_kb: u32) -> Result<Connection> {
|
||||
let conn = Connection::open(&path)?;
|
||||
|
||||
conn.pragma_update(Some(Main), "page_size", &2048)?;
|
||||
conn.pragma_update(Some(Main), "page_size", &32768)?;
|
||||
conn.pragma_update(Some(Main), "journal_mode", &"WAL")?;
|
||||
conn.pragma_update(Some(Main), "synchronous", &"NORMAL")?;
|
||||
conn.pragma_update(Some(Main), "cache_size", &(-i64::from(cache_size_kb)))?;
|
||||
|
@ -136,7 +136,7 @@ impl SqliteTable {
|
|||
fn get_with_guard(&self, guard: &Connection, key: &[u8]) -> Result<Option<Vec<u8>>> {
|
||||
//dbg!(&self.name);
|
||||
Ok(guard
|
||||
.prepare(format!("SELECT value FROM {} WHERE key = ?", self.name).as_str())?
|
||||
.prepare_cached(format!("SELECT value FROM {} WHERE key = ?", self.name).as_str())?
|
||||
.query_row([key], |row| row.get(0))
|
||||
.optional()?)
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ impl SqliteTable {
|
|||
) -> Box<dyn Iterator<Item = TupleOfBytes> + 'a> {
|
||||
let statement = Box::leak(Box::new(
|
||||
guard
|
||||
.prepare(&format!(
|
||||
.prepare_cached(&format!(
|
||||
"SELECT key, value FROM {} ORDER BY key ASC",
|
||||
&self.name
|
||||
))
|
||||
|
@ -290,7 +290,7 @@ impl Tree for SqliteTable {
|
|||
if backwards {
|
||||
let statement = Box::leak(Box::new(
|
||||
guard
|
||||
.prepare(&format!(
|
||||
.prepare_cached(&format!(
|
||||
"SELECT key, value FROM {} WHERE key <= ? ORDER BY key DESC",
|
||||
&self.name
|
||||
))
|
||||
|
@ -315,7 +315,7 @@ impl Tree for SqliteTable {
|
|||
} else {
|
||||
let statement = Box::leak(Box::new(
|
||||
guard
|
||||
.prepare(&format!(
|
||||
.prepare_cached(&format!(
|
||||
"SELECT key, value FROM {} WHERE key >= ? ORDER BY key ASC",
|
||||
&self.name
|
||||
))
|
||||
|
|
|
@ -47,7 +47,6 @@ use ruma::{
|
|||
},
|
||||
AnyEphemeralRoomEvent, EventType,
|
||||
},
|
||||
int,
|
||||
receipt::ReceiptType,
|
||||
serde::JsonObject,
|
||||
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
||||
|
@ -751,14 +750,14 @@ pub async fn send_transaction_message_route(
|
|||
.roomid_mutex_federation
|
||||
.write()
|
||||
.unwrap()
|
||||
.entry(room_id.clone())
|
||||
.entry(RoomId::try_from("!asdf:asfd.asdf").unwrap())
|
||||
.or_default(),
|
||||
);
|
||||
let mutex_lock = mutex.lock().await;
|
||||
let start_time = Instant::now();
|
||||
resolved_map.insert(
|
||||
event_id.clone(),
|
||||
handle_incoming_pdu(
|
||||
dbg!(handle_incoming_pdu(
|
||||
&body.origin,
|
||||
&event_id,
|
||||
&room_id,
|
||||
|
@ -767,7 +766,7 @@ pub async fn send_transaction_message_route(
|
|||
&db,
|
||||
&pub_key_map,
|
||||
)
|
||||
.await
|
||||
.await)
|
||||
.map(|_| ()),
|
||||
);
|
||||
drop(mutex_lock);
|
||||
|
@ -956,6 +955,7 @@ pub(crate) async fn handle_incoming_pdu<'a>(
|
|||
db: &'a Database,
|
||||
pub_key_map: &'a RwLock<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
) -> Result<Option<Vec<u8>>, String> {
|
||||
warn!("Handling incoming pdu: {:?}", value);
|
||||
match db.rooms.exists(room_id) {
|
||||
Ok(true) => {}
|
||||
_ => {
|
||||
|
@ -1000,6 +1000,7 @@ pub(crate) async fn handle_incoming_pdu<'a>(
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
/* stop fetching prev events for now
|
||||
// 9. Fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
|
||||
let mut graph = HashMap::new();
|
||||
let mut eventid_info = HashMap::new();
|
||||
|
@ -1114,6 +1115,7 @@ pub(crate) async fn handle_incoming_pdu<'a>(
|
|||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
upgrade_outlier_to_timeline_pdu(
|
||||
incoming_pdu,
|
||||
|
@ -2838,7 +2840,7 @@ async fn create_join_event(
|
|||
.roomid_mutex_federation
|
||||
.write()
|
||||
.unwrap()
|
||||
.entry(room_id.clone())
|
||||
.entry(RoomId::try_from("!asdf:asfd.asdf").unwrap()) // make all rooms share the same lock for now
|
||||
.or_default(),
|
||||
);
|
||||
let mutex_lock = mutex.lock().await;
|
||||
|
|
Loading…
Add table
Reference in a new issue