Skip to content

Commit

Permalink
chore: remove unused comments and deps, format code
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Nov 18, 2024
1 parent a85f722 commit d8190c8
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 62 deletions.
1 change: 0 additions & 1 deletion examples/hybrid_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async fn main() -> Result<()> {
})
.with_hash_builder(ahash::RandomState::default())
.with_weighter(|_key, value: &String| value.len())
.with_object_pool_capacity(4096)
.storage(Engine::Mixed(0.1))
.with_device_options(
DirectFsDeviceOptions::new(dir.path())
Expand Down
1 change: 0 additions & 1 deletion foyer-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ readme = { workspace = true }
[dependencies]
bytes = "1"
cfg-if = "1"
crossbeam = { workspace = true }
fastrace = { workspace = true }
futures = "0.3"
hashbrown = { workspace = true }
Expand Down
9 changes: 0 additions & 9 deletions foyer-common/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ pub trait EventListener: Send + Sync + 'static {
/// Associated value type.
type Value;

/// Called when a cache entry is released from the in-memory cache.
#[expect(unused_variables)]
fn on_memory_release(&self, key: Self::Key, value: Self::Value)
where
Self::Key: Key,
Self::Value: Value,
{
}

/// Called when a cache entry leaves the in-memory cache with the reason.
#[expect(unused_variables)]
fn on_leave(&self, reason: Event, key: &Self::Key, value: &Self::Value)

Check warning on line 39 in foyer-common/src/event.rs

View check run for this annotation

Codecov / codecov/patch

foyer-common/src/event.rs#L39

Added line #L39 was not covered by tests
Expand Down
6 changes: 1 addition & 5 deletions foyer-memory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ cmsketch = "0.2.1"
equivalent = { workspace = true }
fastrace = { workspace = true }
foyer-common = { workspace = true }
foyer-intrusive = { workspace = true }
futures = "0.3"
hashbrown = { workspace = true }
intrusive-collections = { git = "https://github.com/foyer-rs/intrusive-rs", rev = "94cfac4701dbc0033b7bc27e31c46bf3a12d96d7" }
Expand All @@ -42,10 +41,7 @@ zipf = "7.0.1"
deadlock = ["parking_lot/deadlock_detection"]
# FIXME: remove sanity feature
sanity = []
strict_assertions = [
"foyer-common/strict_assertions",
"foyer-intrusive/strict_assertions",
]
strict_assertions = ["foyer-common/strict_assertions"]
tracing = ["fastrace/enable", "foyer-common/tracing"]

[[bench]]
Expand Down
21 changes: 0 additions & 21 deletions foyer-memory/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ where
weighter: Arc<dyn Weighter<K, V>>,

event_listener: Option<Arc<dyn EventListener<Key = K, Value = V>>>,

object_pool_capacity: usize,
}

impl<K, V> CacheBuilder<K, V, RandomState>
Expand All @@ -301,8 +299,6 @@ where
hash_builder: RandomState::default(),
weighter: Arc::new(|_, _| 1),
event_listener: None,

object_pool_capacity: 4096,
}
}
}
Expand Down Expand Up @@ -338,18 +334,6 @@ where
self
}

/// Set object pool capacity.
///
/// The object pool is used for avoiding frequent memory allocation.
///
/// Each shard gets `object_pool_capacity / shards` slots.
///
/// Default: 4096
pub fn with_object_pool_capacity(mut self, object_pool_capacity: usize) -> Self {
self.object_pool_capacity = object_pool_capacity;
self
}

/// Set in-memory cache hash builder.
pub fn with_hash_builder<OS>(self, hash_builder: OS) -> CacheBuilder<K, V, OS>
where
Expand All @@ -363,7 +347,6 @@ where
hash_builder,
weighter: self.weighter,
event_listener: self.event_listener,
object_pool_capacity: self.object_pool_capacity,
}
}

Expand Down Expand Up @@ -398,7 +381,6 @@ where
hash_builder: self.hash_builder,
weighter: self.weighter,
event_listener: self.event_listener,
// object_pool_capacity: self.object_pool_capacity,
}))),
EvictionConfig::S3Fifo(eviction_config) => Cache::S3Fifo(Arc::new(RawCache::new(RawCacheConfig {
name: self.name,
Expand All @@ -408,7 +390,6 @@ where
hash_builder: self.hash_builder,
weighter: self.weighter,
event_listener: self.event_listener,
// object_pool_capacity: self.object_pool_capacity,
}))),
EvictionConfig::Lru(eviction_config) => Cache::Lru(Arc::new(RawCache::new(RawCacheConfig {
name: self.name,
Expand All @@ -418,7 +399,6 @@ where
hash_builder: self.hash_builder,
weighter: self.weighter,
event_listener: self.event_listener,
// object_pool_capacity: self.object_pool_capacity,
}))),
EvictionConfig::Lfu(eviction_config) => Cache::Lfu(Arc::new(RawCache::new(RawCacheConfig {
name: self.name,
Expand All @@ -428,7 +408,6 @@ where
hash_builder: self.hash_builder,
weighter: self.weighter,
event_listener: self.event_listener,
// object_pool_capacity: self.object_pool_capacity,
}))),
}
}
Expand Down
9 changes: 0 additions & 9 deletions foyer-memory/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ where
pub hash_builder: S,
pub weighter: Arc<dyn Weighter<E::Key, E::Value>>,
pub event_listener: Option<Arc<dyn EventListener<Key = E::Key, Value = E::Value>>>,
// pub object_pool_capacity: usize,
}

struct RawCacheShard<E, S, I>
Expand All @@ -124,7 +123,6 @@ where
S: HashBuilder,
I: Indexer<Eviction = E>,
{
// object_pool: VecDeque<Box<Record<E>>>,
eviction: E,
indexer: Sentry<I>,

Expand Down Expand Up @@ -171,8 +169,6 @@ where
strict_assert!(!evicted.as_ref().is_in_indexer());
strict_assert!(!evicted.as_ref().is_in_eviction());

// FIXME(MrCroxx): remove evicted entry from indexer?

self.usage -= evicted.weight();

garbages.push((Event::Evict, evicted));
Expand Down Expand Up @@ -465,13 +461,8 @@ where

let shard_capacity = config.capacity / config.shards;

// let shard_object_pool_capacity = config.object_pool_capacity / config.shards;

let shards = (0..config.shards)
.map(|_| RawCacheShard {
// object_pool: (0..shard_object_pool_capacity)
// .map(|_| Box::new(Record::empty()))
// .collect(),
eviction: E::new(shard_capacity, &config.eviction_config),
indexer: Sentry::default(),
usage: 0,
Expand Down
16 changes: 0 additions & 16 deletions foyer/src/hybrid/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,6 @@ where
}
}

/// Set object pool capacity.
///
/// The object pool is used for avoiding frequent memory allocation.
///
/// Each shard gets `object_pool_capacity / shards` slots.
///
/// Default: 4096
pub fn with_object_pool_capacity(self, object_pool_capacity: usize) -> Self {
let builder = self.builder.with_object_pool_capacity(object_pool_capacity);
HybridCacheBuilderPhaseMemory {
name: self.name,
tracing_options: self.tracing_options,
builder,
}
}

/// Continue to modify the disk cache configurations.
pub fn storage(self, engine: Engine) -> HybridCacheBuilderPhaseStorage<K, V, S> {
let memory = self.builder.build();
Expand Down

0 comments on commit d8190c8

Please sign in to comment.