moar cpu efficiency

This commit is contained in:
John Spray
2024-07-20 18:22:29 +01:00
parent 425c0c314f
commit e37236fd56
2 changed files with 16 additions and 3 deletions
@@ -521,6 +521,21 @@ impl InMemoryLayer {
self.put_value_locked(&mut inner, key, lsn, buf, ctx).await
}
pub(crate) async fn put_values(
&self,
values: Vec<(Lsn, Key, smallvec::SmallVec<[u8; 256]>)>,
ctx: &RequestContext,
) -> Result<()> {
let mut inner = self.inner.write().await;
self.assert_writable();
for (lsn, key, buf) in values {
self.put_value_locked(&mut inner, key, lsn, &buf, ctx)
.await?;
}
Ok(())
}
async fn put_value_locked(
&self,
locked_inner: &mut RwLockWriteGuard<'_, InMemoryLayerInner>,
+1 -3
View File
@@ -6018,9 +6018,7 @@ impl<'a> TimelineWriter<'a> {
.handle_open_layer_action(first_lsn, action, ctx)
.await?;
for (lsn, key, buf) in serialized {
layer.put_value(key, lsn, &buf, ctx).await?;
}
layer.put_values(serialized, ctx).await?;
// Update the current size only when the entire write was ok.
// In case of failures, we may have had partial writes which