Unverified Commit e4b54a10 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Address persistence cleanup review feedback

Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent 4f67421d
...@@ -25,7 +25,6 @@ use nohash_hasher::BuildNoHashHasher; ...@@ -25,7 +25,6 @@ use nohash_hasher::BuildNoHashHasher;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use smallvec::SmallVec; use smallvec::SmallVec;
use tracing::span::EnteredSpan;
pub use crate::compaction::selector::CompactConfig; pub use crate::compaction::selector::CompactConfig;
#[cfg(feature = "mmap")] #[cfg(feature = "mmap")]
...@@ -2030,15 +2029,6 @@ impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES> ...@@ -2030,15 +2029,6 @@ impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES>
result_size = tracing::field::Empty result_size = tracing::field::Empty
) )
.entered(); .entered();
self.get_impl(family, key, &span)
}
fn get_impl<K: QueryKey>(
&self,
family: usize,
key: &K,
span: &EnteredSpan,
) -> Result<Option<ArcBytes>> {
let hash = hash_key(key); let hash = hash_key(key);
let inner = self.inner.read(); let inner = self.inner.read();
// Track whether we found the key in any SST (even if deleted). // Track whether we found the key in any SST (even if deleted).
......
...@@ -118,53 +118,36 @@ impl<T: KeyBase> KeyBase for &'_ T { ...@@ -118,53 +118,36 @@ impl<T: KeyBase> KeyBase for &'_ T {
/// comparison with a byte slice (total order). /// comparison with a byte slice (total order).
pub trait QueryKey: KeyBase { pub trait QueryKey: KeyBase {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering; fn cmp(&self, key: &[u8]) -> std::cmp::Ordering;
fn eq(&self, key: &[u8]) -> bool;
} }
impl QueryKey for &'_ [u8] { impl QueryKey for &'_ [u8] {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
Ord::cmp(self, &key) Ord::cmp(self, &key)
} }
fn eq(&self, key: &[u8]) -> bool {
PartialEq::eq(*self, key)
}
} }
impl<const N: usize> QueryKey for [u8; N] { impl<const N: usize> QueryKey for [u8; N] {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
Ord::cmp(&self[..], key) Ord::cmp(&self[..], key)
} }
fn eq(&self, key: &[u8]) -> bool {
PartialEq::eq(self, key)
}
} }
impl QueryKey for Vec<u8> { impl QueryKey for Vec<u8> {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
Ord::cmp(&**self, key) Ord::cmp(&**self, key)
} }
fn eq(&self, key: &[u8]) -> bool {
PartialEq::eq(self.as_slice(), key)
}
} }
impl QueryKey for Box<[u8]> { impl QueryKey for Box<[u8]> {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
Ord::cmp(&**self, key) Ord::cmp(&**self, key)
} }
fn eq(&self, key: &[u8]) -> bool {
PartialEq::eq(&**self, key)
}
} }
impl QueryKey for u8 { impl QueryKey for u8 {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
Ord::cmp(&[*self][..], key) Ord::cmp(&[*self][..], key)
} }
fn eq(&self, key: &[u8]) -> bool {
PartialEq::eq(&[*self][..], key)
}
} }
impl<A: QueryKey, B: QueryKey> QueryKey for (A, B) { impl<A: QueryKey, B: QueryKey> QueryKey for (A, B) {
...@@ -175,22 +158,12 @@ impl<A: QueryKey, B: QueryKey> QueryKey for (A, B) { ...@@ -175,22 +158,12 @@ impl<A: QueryKey, B: QueryKey> QueryKey for (A, B) {
let (key_part, value_part) = key.split_at(min(key_len, len)); let (key_part, value_part) = key.split_at(min(key_len, len));
a.cmp(key_part).then_with(|| b.cmp(value_part)) a.cmp(key_part).then_with(|| b.cmp(value_part))
} }
fn eq(&self, key: &[u8]) -> bool {
let (a, b) = self;
let len = a.len();
let key_len = key.len();
let (key_part, value_part) = &key.split_at(min(key_len, len));
a.eq(key_part) && b.eq(value_part)
}
} }
impl<T: QueryKey> QueryKey for &'_ T { impl<T: QueryKey> QueryKey for &'_ T {
fn cmp(&self, key: &[u8]) -> std::cmp::Ordering { fn cmp(&self, key: &[u8]) -> std::cmp::Ordering {
(*self).cmp(key) (*self).cmp(key)
} }
fn eq(&self, key: &[u8]) -> bool {
(*self).eq(key)
}
} }
/// A trait for keys that can be stored in the database. They need to allow hashing and comparison. /// A trait for keys that can be stored in the database. They need to allow hashing and comparison.
......
...@@ -49,19 +49,10 @@ pub enum AccessMode { ...@@ -49,19 +49,10 @@ pub enum AccessMode {
File, File,
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FamilyKind {
/// Each key maps to a single value (default LSM behavior).
/// When multiple entries have the same key, only the newest is retained during compaction or
/// returned by queries.
SingleValue,
}
/// Configuration for a single family to describe how the data is stored. /// Configuration for a single family to describe how the data is stored.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct FamilyConfig { pub struct FamilyConfig {
pub name: &'static str, pub name: &'static str,
pub kind: FamilyKind,
pub compression: Compression, pub compression: Compression,
} }
...@@ -122,7 +113,6 @@ impl<const FAMILIES: usize> DbConfig<FAMILIES> { ...@@ -122,7 +113,6 @@ impl<const FAMILIES: usize> DbConfig<FAMILIES> {
Self { Self {
family_configs: [FamilyConfig { family_configs: [FamilyConfig {
name: "unknown", name: "unknown",
kind: FamilyKind::SingleValue,
compression: Compression::Lz4, compression: Compression::Lz4,
}; FAMILIES], }; FAMILIES],
access_mode: default_access_mode(), access_mode: default_access_mode(),
......
...@@ -1358,7 +1358,6 @@ fn value_type_val_size(ty: EntryType) -> usize { ...@@ -1358,7 +1358,6 @@ fn value_type_val_size(ty: EntryType) -> usize {
KEY_BLOCK_ENTRY_TYPE_MEDIUM => MEDIUM_VALUE_REF_SIZE, KEY_BLOCK_ENTRY_TYPE_MEDIUM => MEDIUM_VALUE_REF_SIZE,
KEY_BLOCK_ENTRY_TYPE_BLOB => BLOB_VALUE_REF_SIZE, KEY_BLOCK_ENTRY_TYPE_BLOB => BLOB_VALUE_REF_SIZE,
KEY_BLOCK_ENTRY_TYPE_KEY_DELETED => KEY_DELETED_REF_SIZE, KEY_BLOCK_ENTRY_TYPE_KEY_DELETED => KEY_DELETED_REF_SIZE,
// Must precede the inline arm: both are open-ended and the tombstone range sits above it.
ty if ty >= KEY_BLOCK_ENTRY_TYPE_INLINE_MIN => { ty if ty >= KEY_BLOCK_ENTRY_TYPE_INLINE_MIN => {
(ty - KEY_BLOCK_ENTRY_TYPE_INLINE_MIN) as usize (ty - KEY_BLOCK_ENTRY_TYPE_INLINE_MIN) as usize
} }
......
use turbo_persistence::{Compression, FamilyConfig, FamilyKind}; use turbo_persistence::{Compression, FamilyConfig};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum KeySpace { pub enum KeySpace {
...@@ -37,18 +37,15 @@ impl KeySpace { ...@@ -37,18 +37,15 @@ impl KeySpace {
match self { match self {
KeySpace::Infra | KeySpace::TaskMeta => FamilyConfig { KeySpace::Infra | KeySpace::TaskMeta => FamilyConfig {
name: self.name(), name: self.name(),
kind: FamilyKind::SingleValue,
compression: Compression::Lz4, compression: Compression::Lz4,
}, },
KeySpace::TaskData => FamilyConfig { KeySpace::TaskData => FamilyConfig {
name: self.name(), name: self.name(),
kind: FamilyKind::SingleValue,
compression: Compression::Zstd3, compression: Compression::Zstd3,
}, },
KeySpace::TaskCache => FamilyConfig { KeySpace::TaskCache => FamilyConfig {
name: self.name(), name: self.name(),
// TaskCache maps each hash to one list of TaskIds to handle rare collisions. // TaskCache maps each hash to one list of TaskIds to handle rare collisions.
kind: FamilyKind::SingleValue,
compression: Compression::Lz4, compression: Compression::Lz4,
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment