Skip to content

Commit 8908d27

Browse files
dantengskyBohuTANG
andauthored
chore: adjust table data cache population queue size (#12773)
* chore: temporarily enable disk cache for ci-benchmark * adjust queue size (by default num of cpu cores) * fix typo * adjust default cache population queue size * clean up --------- Co-authored-by: BohuTANG <overred.shuttler@gmail.com>
1 parent a237b4d commit 8908d27

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/query/config/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,10 +2298,10 @@ pub struct CacheConfig {
22982298
/// - please monitor the 'population_overflow_count' metric
22992299
/// if it keeps increasing, and disk cache hits rate is not as expected. please consider
23002300
/// increase this value.
2301-
#[clap(
2302-
long = "cache-data-cache-population-queue-size",
2303-
default_value = "65536"
2304-
)]
2301+
///
2302+
/// default value is 0, which means queue size will be adjusted automatically based on
2303+
/// number of CPU cores.
2304+
#[clap(long = "cache-data-cache-population-queue-size", default_value = "0")]
23052305
pub table_data_cache_population_queue_size: u32,
23062306

23072307
/// Storage that hold the data caches

src/query/config/src/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ impl Default for CacheConfig {
597597
table_bloom_index_filter_size: 2147483648,
598598
table_prune_partitions_count: 256,
599599
data_cache_storage: Default::default(),
600-
table_data_cache_population_queue_size: 65536,
600+
table_data_cache_population_queue_size: 0,
601601
disk_cache_config: Default::default(),
602602
table_data_deserialized_data_bytes: 0,
603603
}

src/query/service/tests/it/storages/testdata/configs_table_basic.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DB.Table: 'system'.'configs', Table: configs-table_id:1, ver:0, Engine: SystemCo
1212
| 'cache' | 'table_bloom_index_filter_count' | '0' | '' |
1313
| 'cache' | 'table_bloom_index_filter_size' | '2147483648' | '' |
1414
| 'cache' | 'table_bloom_index_meta_count' | '3000' | '' |
15-
| 'cache' | 'table_data_cache_population_queue_size' | '65536' | '' |
15+
| 'cache' | 'table_data_cache_population_queue_size' | '0' | '' |
1616
| 'cache' | 'table_data_deserialized_data_bytes' | '0' | '' |
1717
| 'cache' | 'table_meta_segment_bytes' | '1073741824' | '' |
1818
| 'cache' | 'table_meta_segment_count' | 'null' | '' |

src/query/storages/common/cache-manager/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ common-exception = { path = "../../../../common/exception" }
1818
storages-common-cache = { path = "../../common/cache" }
1919
storages-common-index = { path = "../../common/index" }
2020
storages-common-table-meta = { path = "../../common/table-meta" }
21+
22+
log = { workspace = true }

src/query/storages/common/cache-manager/src/cache_manager.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use common_cache::DefaultHashBuilder;
2121
use common_config::CacheConfig;
2222
use common_config::CacheStorageTypeInnerConfig;
2323
use common_exception::Result;
24+
use log::info;
2425
use storages_common_cache::InMemoryCacheBuilder;
2526
use storages_common_cache::InMemoryItemCacheHolder;
2627
use storages_common_cache::Named;
@@ -66,9 +67,26 @@ impl CacheManager {
6667
let real_disk_cache_root = PathBuf::from(&config.disk_cache_config.path)
6768
.join(tenant_id.into())
6869
.join("v1");
70+
71+
let queue_size: u32 = if config.table_data_cache_population_queue_size > 0 {
72+
config.table_data_cache_population_queue_size
73+
} else {
74+
std::cmp::max(
75+
1,
76+
std::thread::available_parallelism()
77+
.expect("Cannot get thread count")
78+
.get() as u32,
79+
)
80+
};
81+
82+
info!(
83+
"disk cache enabled, cache population queue size {}",
84+
queue_size
85+
);
86+
6987
Self::new_block_data_cache(
7088
&real_disk_cache_root,
71-
config.table_data_cache_population_queue_size,
89+
queue_size,
7290
config.disk_cache_config.max_bytes,
7391
)?
7492
}

0 commit comments

Comments
 (0)