Skip to content

Commit 52192e6

Browse files
authored
refactor: refactor file cache metrics build, bump foyer (#12121)
Signed-off-by: MrCroxx <[email protected]>
1 parent da89875 commit 52192e6

File tree

9 files changed

+54
-80
lines changed

9 files changed

+54
-80
lines changed

Cargo.lock

Lines changed: 28 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/dashboards/risingwave-dev-dashboard.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

grafana/risingwave-dev-dashboard.dashboard.py

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,16 +1691,6 @@ def section_hummock(panels):
16911691
),
16921692
],
16931693
),
1694-
panels.timeseries_ops(
1695-
"File Cache Ops",
1696-
"",
1697-
[
1698-
panels.target(
1699-
f"sum(rate({metric('foyer_storage_latency_count')}[$__rate_interval])) by (op, extra, instance)",
1700-
"file cache {{op}} {{extra}} @ {{instance}}",
1701-
),
1702-
],
1703-
),
17041694
panels.timeseries_ops(
17051695
"Read Ops",
17061696
"",
@@ -1918,10 +1908,6 @@ def section_hummock(panels):
19181908
f"(sum(rate({table_metric('state_store_sst_store_block_request_counts', data_miss_filter)}[$__rate_interval])) by (job,instance,table_id)) / (sum(rate({table_metric('state_store_sst_store_block_request_counts', data_total_filter)}[$__rate_interval])) by (job,instance,table_id))",
19191909
"block cache miss rate - {{table_id}} @ {{job}} @ {{instance}}",
19201910
),
1921-
panels.target(
1922-
f"(sum(rate({metric('file_cache_miss')}[$__rate_interval])) by (instance)) / (sum(rate({metric('file_cache_latency_count', file_cache_get_filter)}[$__rate_interval])) by (instance))",
1923-
"file cache miss rate @ {{instance}}",
1924-
),
19251911
],
19261912
),
19271913
panels.timeseries_percentage(
@@ -2218,32 +2204,20 @@ def section_hummock_tiered_cache(outer_panels):
22182204
"",
22192205
[
22202206
panels.target(
2221-
f"sum(rate({metric('data_foyer_storage_latency_count')}[$__rate_interval])) by (op, extra, instance)",
2222-
"data file cache {{op}} {{extra}} @ {{instance}}",
2223-
),
2224-
panels.target(
2225-
f"sum(rate({metric('meta_foyer_storage_latency_count')}[$__rate_interval])) by (op, extra, instance)",
2226-
"meta cache {{op}} {{extra}} @ {{instance}}",
2207+
f"sum(rate({metric('foyer_storage_op_duration_count')}[$__rate_interval])) by (foyer, op, extra, instance)",
2208+
"{{foyer}} file cache {{op}} {{extra}} @ {{instance}}",
22272209
),
22282210
],
22292211
),
22302212
panels.timeseries_latency(
2231-
"Latency",
2213+
"Duration",
22322214
"",
22332215
[
22342216
*quantile(
22352217
lambda quantile, legend: panels.target(
2236-
f"histogram_quantile({quantile}, sum(rate({metric('data_foyer_storage_latency_bucket')}[$__rate_interval])) by (le, op, extra, instance))",
2237-
f"p{legend} - data file cache" +
2238-
" - {{op}} {{extra}} @ {{instance}}",
2239-
),
2240-
[50, 90, 99, "max"],
2241-
),
2242-
*quantile(
2243-
lambda quantile, legend: panels.target(
2244-
f"histogram_quantile({quantile}, sum(rate({metric('meta_foyer_storage_latency_bucket')}[$__rate_interval])) by (le, op, extra, instance))",
2245-
f"p{legend} - meta file cache" +
2246-
" - {{op}} {{extra}} @ {{instance}}",
2218+
f"histogram_quantile({quantile}, sum(rate({metric('foyer_storage_op_duration_bucket')}[$__rate_interval])) by (le, foyer, op, extra, instance))",
2219+
f"p{legend}" +
2220+
" - {{foyer}} file cache - {{op}} {{extra}} @ {{instance}}",
22472221
),
22482222
[50, 90, 99, "max"],
22492223
),
@@ -2254,12 +2228,8 @@ def section_hummock_tiered_cache(outer_panels):
22542228
"",
22552229
[
22562230
panels.target(
2257-
f"sum(rate({metric('data_foyer_storage_bytes')}[$__rate_interval])) by (op, extra, instance)",
2258-
"data file cache - {{op}} {{extra}} @ {{instance}}",
2259-
),
2260-
panels.target(
2261-
f"sum(rate({metric('meta_foyer_storage_bytes')}[$__rate_interval])) by (op, extra, instance)",
2262-
"meta file cache - {{op}} {{extra}} @ {{instance}}",
2231+
f"sum(rate({metric('foyer_storage_op_bytes')}[$__rate_interval])) by (foyer, op, extra, instance)",
2232+
"{{foyer}} file cache - {{op}} {{extra}} @ {{instance}}",
22632233
),
22642234
],
22652235
),
@@ -2268,10 +2238,7 @@ def section_hummock_tiered_cache(outer_panels):
22682238
"",
22692239
[
22702240
panels.target(
2271-
f"{metric('data_foyer_storage_size')}", "size @ {{instance}}"
2272-
),
2273-
panels.target(
2274-
f"{metric('meta_foyer_storage_size')}", "size @ {{instance}}"
2241+
f"sum({metric('foyer_storage_total_bytes')}) by (foyer, instance)", "{{foyer}} size @ {{instance}}"
22752242
),
22762243
],
22772244
),
@@ -2280,12 +2247,8 @@ def section_hummock_tiered_cache(outer_panels):
22802247
"",
22812248
[
22822249
panels.target(
2283-
f"sum(rate({metric('data_foyer_storage_latency_count', file_cache_hit_filter)}[$__rate_interval])) by (instance) / (sum(rate({metric('data_foyer_storage_latency_count', file_cache_hit_filter)}[$__rate_interval])) by (instance) + sum(rate({metric('data_foyer_storage_latency_count', file_cache_miss_filter)}[$__rate_interval])) by (instance))",
2284-
"data file cache hit ratio @ {{instance}}",
2285-
),
2286-
panels.target(
2287-
f"sum(rate({metric('meta_foyer_storage_latency_count', file_cache_hit_filter)}[$__rate_interval])) by (instance) / (sum(rate({metric('meta_foyer_storage_latency_count', file_cache_hit_filter)}[$__rate_interval])) by (instance) + sum(rate({metric('meta_foyer_storage_latency_count', file_cache_miss_filter)}[$__rate_interval])) by (instance))",
2288-
"meta file cache hit ratio @ {{instance}}",
2250+
f"sum(rate({metric('foyer_storage_op_duration_count', file_cache_hit_filter)}[$__rate_interval])) by (foyer, instance) / (sum(rate({metric('foyer_storage_op_duration_count', file_cache_hit_filter)}[$__rate_interval])) by (foyer, instance) + sum(rate({metric('foyer_storage_op_duration_count', file_cache_miss_filter)}[$__rate_interval])) by (foyer, instance))",
2251+
"{{foyer}} file cache hit ratio @ {{instance}}",
22892252
),
22902253
],
22912254
),
@@ -2294,7 +2257,7 @@ def section_hummock_tiered_cache(outer_panels):
22942257
"",
22952258
[
22962259
panels.target(
2297-
f"sum(refill_queue_length) by (instance)",
2260+
f"sum(refill_queue_total) by (instance)",
22982261
"refill queue length @ {{instance}}",
22992262
),
23002263
],

grafana/risingwave-dev-dashboard.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/storage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dyn-clone = "1.0.13"
2626
either = "1"
2727
enum-as-inner = "0.6"
2828
fail = "0.5"
29-
foyer = { git = "https://github.com/mrcroxx/foyer", rev = "99b21df" }
29+
foyer = { git = "https://github.com/mrcroxx/foyer", rev = "2b8907c" }
3030
futures = { version = "0.3", default-features = false, features = ["alloc"] }
3131
futures-async-stream = { workspace = true }
3232
hex = "0.4"

src/storage/src/hummock/event_handler/refiller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl CacheRefillTask {
211211
let holders = match Self::meta_cache_refill(&context, delta).await {
212212
Ok(holders) => holders,
213213
Err(e) => {
214-
tracing::warn!("meeta cache refill error: {:?}", e);
214+
tracing::warn!("meta cache refill error: {:?}", e);
215215
return;
216216
}
217217
};

src/storage/src/hummock/file_cache/store.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ use foyer::common::code::{Key, Value};
2323
use foyer::storage::admission::rated_random::RatedRandomAdmissionPolicy;
2424
use foyer::storage::admission::AdmissionPolicy;
2525
use foyer::storage::event::EventListener;
26-
use foyer::storage::store::{FetchValueFuture, PrometheusConfig};
26+
pub use foyer::storage::metrics::set_metrics_registry as set_foyer_metrics_registry;
27+
use foyer::storage::store::FetchValueFuture;
2728
use foyer::storage::LfuFsStoreConfig;
28-
use prometheus::Registry;
2929
use risingwave_common::util::runtime::BackgroundShutdownRuntime;
3030
use risingwave_hummock_sdk::HummockSstableObjectId;
3131

@@ -59,6 +59,7 @@ where
5959
K: Key,
6060
V: Value,
6161
{
62+
pub name: String,
6263
pub dir: PathBuf,
6364
pub capacity: usize,
6465
pub file_capacity: usize,
@@ -73,8 +74,6 @@ where
7374
pub lfu_window_to_cache_size_ratio: usize,
7475
pub lfu_tiny_lru_capacity_ratio: f64,
7576
pub rated_random_rate: usize,
76-
pub prometheus_registry: Option<Registry>,
77-
pub prometheus_namespace: Option<String>,
7877
pub event_listener: Vec<Arc<dyn EventListener<K = K, V = V>>>,
7978
pub enable_filter: bool,
8079
}
@@ -201,6 +200,7 @@ where
201200
}
202201

203202
let c = LfuFsStoreConfig {
203+
name: foyer_store_config.name,
204204
eviction_config: EvictionConfig {
205205
window_to_cache_size_ratio: foyer_store_config
206206
.lfu_window_to_cache_size_ratio,
@@ -222,10 +222,6 @@ where
222222
reclaim_rate_limit: foyer_store_config.reclaim_rate_limit,
223223
recover_concurrency: foyer_store_config.recover_concurrency,
224224
event_listeners: foyer_store_config.event_listener,
225-
prometheus_config: PrometheusConfig {
226-
registry: foyer_store_config.prometheus_registry,
227-
namespace: foyer_store_config.prometheus_namespace,
228-
},
229225
clean_region_threshold: foyer_store_config.reclaimers
230226
+ foyer_store_config.reclaimers / 2,
231227
};

src/storage/src/store_impl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use crate::hummock::backup_reader::BackupReaderRef;
2929
use crate::hummock::hummock_meta_client::MonitoredHummockMetaClient;
3030
use crate::hummock::sstable_store::SstableStoreRef;
3131
use crate::hummock::{
32-
FileCache, FoyerRuntimeConfig, FoyerStoreConfig, HummockError, HummockStorage, MemoryLimiter,
33-
SstableObjectIdManagerRef, SstableStore,
32+
set_foyer_metrics_registry, FileCache, FoyerRuntimeConfig, FoyerStoreConfig, HummockError,
33+
HummockStorage, MemoryLimiter, SstableObjectIdManagerRef, SstableStore,
3434
};
3535
use crate::memory::sled::SledStateStore;
3636
use crate::memory::MemoryStateStore;
@@ -542,12 +542,15 @@ impl StateStoreImpl {
542542
storage_metrics: Arc<MonitoredStorageMetrics>,
543543
compactor_metrics: Arc<CompactorMetrics>,
544544
) -> StorageResult<Self> {
545+
set_foyer_metrics_registry(GLOBAL_METRICS_REGISTRY.clone());
546+
545547
let data_file_cache = if opts.data_file_cache_dir.is_empty() {
546548
FileCache::none()
547549
} else {
548550
const MB: usize = 1024 * 1024;
549551

550552
let foyer_store_config = FoyerStoreConfig {
553+
name: "data".to_string(),
551554
dir: PathBuf::from(opts.data_file_cache_dir.clone()),
552555
capacity: opts.data_file_cache_capacity_mb * MB,
553556
file_capacity: opts.data_file_cache_file_capacity_mb * MB,
@@ -563,8 +566,6 @@ impl StateStoreImpl {
563566
reclaim_rate_limit: opts.data_file_cache_reclaim_rate_limit_mb * MB,
564567
recover_concurrency: opts.data_file_cache_recover_concurrency,
565568
event_listener: vec![],
566-
prometheus_registry: Some(GLOBAL_METRICS_REGISTRY.clone()),
567-
prometheus_namespace: Some("data".to_string()),
568569
enable_filter: !opts.cache_refill_data_refill_levels.is_empty(),
569570
};
570571
let config = FoyerRuntimeConfig {
@@ -582,6 +583,7 @@ impl StateStoreImpl {
582583
const MB: usize = 1024 * 1024;
583584

584585
let foyer_store_config = FoyerStoreConfig {
586+
name: "meta".to_string(),
585587
dir: PathBuf::from(opts.meta_file_cache_dir.clone()),
586588
capacity: opts.meta_file_cache_capacity_mb * MB,
587589
file_capacity: opts.meta_file_cache_file_capacity_mb * MB,
@@ -597,8 +599,6 @@ impl StateStoreImpl {
597599
reclaim_rate_limit: opts.meta_file_cache_reclaim_rate_limit_mb * MB,
598600
recover_concurrency: opts.meta_file_cache_recover_concurrency,
599601
event_listener: vec![],
600-
prometheus_registry: Some(GLOBAL_METRICS_REGISTRY.clone()),
601-
prometheus_namespace: Some("meta".to_string()),
602602
enable_filter: false,
603603
};
604604
let config = FoyerRuntimeConfig {

src/workspace-hack/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ memchr = { version = "2" }
6464
miniz_oxide = { version = "0.7", default-features = false, features = ["with-alloc"] }
6565
mio = { version = "0.8", features = ["net", "os-ext"] }
6666
multimap = { version = "0.8" }
67-
nix = { version = "0.26" }
6867
nom = { version = "7" }
6968
num-bigint = { version = "0.4" }
7069
num-integer = { version = "0.1", features = ["i128"] }
@@ -160,7 +159,6 @@ memchr = { version = "2" }
160159
miniz_oxide = { version = "0.7", default-features = false, features = ["with-alloc"] }
161160
mio = { version = "0.8", features = ["net", "os-ext"] }
162161
multimap = { version = "0.8" }
163-
nix = { version = "0.26" }
164162
nom = { version = "7" }
165163
num-bigint = { version = "0.4" }
166164
num-integer = { version = "0.1", features = ["i128"] }

0 commit comments

Comments
 (0)