Storage layer refactoring: faster id generation, automatic batching and virtual thread ids

This commit is contained in:
mdecimus
2025-04-02 17:37:14 +02:00
parent 76f085ab7c
commit fac2975a5a
152 changed files with 3489 additions and 4039 deletions

View File

@@ -13,9 +13,8 @@ use email::{
};
use jmap_proto::types::{collection::Collection, property::Property};
use store::{
IndexKey, IterateParams, SerializeInfallible, U32_LEN,
ahash::AHashMap,
write::{AlignedBytes, Archive, key::DeserializeBigEndian},
IndexKey, IterateParams, SerializeInfallible, U32_LEN, ahash::AHashMap,
write::key::DeserializeBigEndian,
};
use trc::AddContext;
@@ -66,12 +65,7 @@ impl<T: SessionStream> Session<T> {
.caused_by(trc::location!())?;
let uid_validity = u32::from(
self.server
.get_property::<Archive<AlignedBytes>>(
account_id,
Collection::Mailbox,
INBOX_ID,
&Property::Value,
)
.get_archive(account_id, Collection::Mailbox, INBOX_ID)
.await
.caused_by(trc::location!())?
.ok_or_else(|| {
@@ -130,7 +124,6 @@ impl<T: SessionStream> Session<T> {
account_id,
Collection::Email,
&message_ids,
Property::Value,
|message_id, uid_mailbox| {
// Make sure the message is still in Inbox
if let Some(item) = uid_mailbox

View File

@@ -9,8 +9,7 @@ use std::time::Instant;
use common::listener::SessionStream;
use directory::Permission;
use email::message::delete::EmailDeletion;
use jmap_proto::types::{state::StateChange, type_state::DataType};
use store::roaring::RoaringBitmap;
use store::{roaring::RoaringBitmap, write::BatchBuilder};
use trc::AddContext;
use crate::{Session, State, protocol::response::Response};
@@ -87,27 +86,18 @@ impl<T: SessionStream> Session<T> {
if !deleted.is_empty() {
let num_deleted = deleted.len();
let (changes, not_deleted) = self
let mut batch = BatchBuilder::new();
let not_deleted = self
.server
.emails_tombstone(mailbox.account_id, deleted)
.emails_tombstone(mailbox.account_id, &mut batch, deleted)
.await
.caused_by(trc::location!())?;
if !changes.is_empty() {
if let Ok(change_id) = self
.server
.commit_changes(mailbox.account_id, changes)
if !batch.is_empty() {
self.server
.commit_batch(batch)
.await
{
self.server
.broadcast_state_change(
StateChange::new(mailbox.account_id)
.with_change(DataType::Email, change_id)
.with_change(DataType::Mailbox, change_id)
.with_change(DataType::Thread, change_id),
)
.await;
}
.caused_by(trc::location!())?;
}
if not_deleted.is_empty() {
self.write_ok(format!(

View File

@@ -10,7 +10,6 @@ use common::listener::SessionStream;
use directory::Permission;
use email::message::metadata::MessageMetadata;
use jmap_proto::types::{collection::Collection, property::Property};
use store::write::{AlignedBytes, Archive};
use trc::AddContext;
use crate::{Session, protocol::response::Response};
@@ -27,11 +26,11 @@ impl<T: SessionStream> Session<T> {
if let Some(message) = mailbox.messages.get(msg.saturating_sub(1) as usize) {
if let Some(metadata_) = self
.server
.get_property::<Archive<AlignedBytes>>(
.get_archive_by_property(
mailbox.account_id,
Collection::Email,
message.id,
&Property::BodyStructure,
Property::BodyStructure,
)
.await
.caused_by(trc::location!())?