Skip to content

Commit

Permalink
perf(cache): reduce exclusive lock usage while dropping in-memory cac…
Browse files Browse the repository at this point in the history
…he entry (#19436)

Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx authored Nov 26, 2024
1 parent 4752db6 commit fc639fe
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 206 deletions.
77 changes: 40 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ license = "Apache-2.0"
repository = "https://github.com/risingwavelabs/risingwave"

[workspace.dependencies]
foyer = { version = "0.12.2", features = ["tracing", "nightly"] }
# foyer = { version = "0.12.2", features = ["tracing", "nightly"] }
foyer = { git = "https://github.com/mrcroxx/foyer", rev = "99005412eac1bca6aa7c73d750efc9cdb8ae176e", features = [
"tracing",
"nightly",
] }
apache-avro = { git = "https://github.com/risingwavelabs/avro", rev = "25113ba88234a9ae23296e981d8302c290fdaa4b", features = [
"snappy",
"zstandard",
Expand Down
4 changes: 2 additions & 2 deletions src/batch/src/executor/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mod tests {
use std::ops::Bound;

use assert_matches::assert_matches;
use foyer::CacheContext;
use foyer::CacheHint;
use futures::StreamExt;
use risingwave_common::array::{Array, ArrayImpl, I32Array, StructArray};
use risingwave_common::catalog::{
Expand Down Expand Up @@ -398,7 +398,7 @@ mod tests {
epoch,
None,
ReadOptions {
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
)
Expand Down
2 changes: 1 addition & 1 deletion src/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ itertools = { workspace = true }
libc = "0.2"
lz4 = "1.28.0"
memcomparable = "0.2"
metrics-prometheus = "0.7"
metrics-prometheus = "0.8"
moka = { version = "0.12.0", features = ["future", "sync"] }
more-asserts = "0.3"
num-integer = "0.1"
Expand Down
4 changes: 0 additions & 4 deletions src/storage/benches/bench_block_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ impl FoyerCache {
.with_eviction_config(foyer::LruConfig {
high_priority_pool_ratio: 0.8,
})
.with_object_pool_capacity(8 * 1024)
.build();
Self {
inner,
Expand All @@ -147,7 +146,6 @@ impl FoyerCache {
cmsketch_eps: 0.001,
cmsketch_confidence: 0.9,
})
.with_object_pool_capacity(8 * 1024)
.build();
Self {
inner,
Expand Down Expand Up @@ -187,7 +185,6 @@ impl FoyerHybridCache {
.with_eviction_config(foyer::LruConfig {
high_priority_pool_ratio: 0.8,
})
.with_object_pool_capacity(8 * 1024)
.storage(Engine::Large)
.build()
.await
Expand All @@ -208,7 +205,6 @@ impl FoyerHybridCache {
cmsketch_eps: 0.001,
cmsketch_confidence: 0.9,
})
.with_object_pool_capacity(8 * 1024)
.storage(Engine::Large)
.build()
.await
Expand Down
10 changes: 5 additions & 5 deletions src/storage/benches/bench_compactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::sync::Arc;

use criterion::async_executor::FuturesExecutor;
use criterion::{criterion_group, criterion_main, Criterion};
use foyer::{CacheContext, Engine, HybridCacheBuilder};
use foyer::{CacheHint, Engine, HybridCacheBuilder};
use risingwave_common::catalog::{ColumnDesc, ColumnId, TableId};
use risingwave_common::config::{MetricLevel, ObjectStoreConfig};
use risingwave_common::hash::VirtualNode;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn default_writer_opts() -> SstableWriterOptions {
SstableWriterOptions {
capacity_hint: None,
tracker: None,
policy: CachePolicy::Fill(CacheContext::Default),
policy: CachePolicy::Fill(CacheHint::Normal),
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ async fn build_table(
SstableWriterOptions {
capacity_hint: None,
tracker: None,
policy: CachePolicy::Fill(CacheContext::Default),
policy: CachePolicy::Fill(CacheHint::Normal),
},
);
let table_id_to_vnode = HashMap::from_iter(vec![(0, VirtualNode::COUNT_FOR_TEST)]);
Expand Down Expand Up @@ -181,7 +181,7 @@ async fn build_table_2(
SstableWriterOptions {
capacity_hint: None,
tracker: None,
policy: CachePolicy::Fill(CacheContext::Default),
policy: CachePolicy::Fill(CacheHint::Normal),
},
);

Expand Down Expand Up @@ -345,7 +345,7 @@ fn bench_merge_iterator_compactor(c: &mut Criterion) {
});
let level2 = vec![info1, info2];
let read_options = Arc::new(SstableIteratorReadOptions {
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
prefetch_for_large_query: false,
must_iterated_end_user_key: None,
max_preload_retry_times: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/storage/hummock_test/benches/bench_hummock_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::sync::Arc;

use bytes::Bytes;
use criterion::{criterion_group, criterion_main, Criterion};
use foyer::CacheContext;
use foyer::CacheHint;
use futures::pin_mut;
use risingwave_common::util::epoch::test_epoch;
use risingwave_hummock_sdk::key::TableKey;
Expand Down Expand Up @@ -109,7 +109,7 @@ fn criterion_benchmark(c: &mut Criterion) {
epoch,
ReadOptions {
prefetch_options: PrefetchOptions::default(),
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
))
Expand Down
10 changes: 5 additions & 5 deletions src/storage/hummock_test/src/compactor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) mod tests {
use std::sync::Arc;

use bytes::{BufMut, Bytes, BytesMut};
use foyer::CacheContext;
use foyer::CacheHint;
use itertools::Itertools;
use rand::{Rng, RngCore, SeedableRng};
use risingwave_common::bitmap::BitmapBuilder;
Expand Down Expand Up @@ -338,7 +338,7 @@ pub(crate) mod tests {
TableKey(key.clone()),
get_epoch,
ReadOptions {
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
)
Expand Down Expand Up @@ -668,7 +668,7 @@ pub(crate) mod tests {
ReadOptions {
table_id: TableId::from(existing_table_id),
prefetch_options: PrefetchOptions::default(),
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
)
Expand Down Expand Up @@ -874,7 +874,7 @@ pub(crate) mod tests {
ReadOptions {
table_id: TableId::from(existing_table_id),
prefetch_options: PrefetchOptions::default(),
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
)
Expand Down Expand Up @@ -1088,7 +1088,7 @@ pub(crate) mod tests {
prefix_hint: Some(Bytes::from(bloom_filter_key)),
table_id: TableId::from(existing_table_id),
prefetch_options: PrefetchOptions::default(),
cache_policy: CachePolicy::Fill(CacheContext::Default),
cache_policy: CachePolicy::Fill(CacheHint::Normal),
..Default::default()
},
)
Expand Down
Loading

0 comments on commit fc639fe

Please sign in to comment.