Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: Little-Wallace <[email protected]>
  • Loading branch information
Little-Wallace committed Mar 15, 2024
1 parent 2018ac3 commit d84f28f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/common/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ mod tests {

#[test]
fn test_cache_shard() {
let cache = Arc::new(LruCache::<(u64, u64), Block>::new(2, 256, 0));
let cache = Arc::new(LruCache::<(u64, u64), Block>::new(4, 256, 0));
assert_eq!(cache.shard(0), 0);
assert_eq!(cache.shard(1), 1);
assert_eq!(cache.shard(10), 2);
Expand Down Expand Up @@ -1349,7 +1349,7 @@ mod tests {

#[test]
fn test_write_request_pending() {
let cache = Arc::new(LruCache::new(0, 5, 0));
let cache = Arc::new(LruCache::new(1, 5, 0));
{
let mut shard = cache.shards[0].lock();
insert(&mut shard, "a", "v1");
Expand Down Expand Up @@ -1394,7 +1394,7 @@ mod tests {
#[test]
fn test_event_listener() {
let listener = Arc::new(TestLruCacheEventListener::default());
let cache = Arc::new(LruCache::with_event_listener(0, 2, 0, listener.clone()));
let cache = Arc::new(LruCache::with_event_listener(1, 2, 0, listener.clone()));

// full-fill cache
let h = cache.insert(
Expand Down Expand Up @@ -1489,7 +1489,7 @@ mod tests {

#[tokio::test]
async fn test_future_cancel() {
let cache: Arc<LruCache<u64, u64>> = Arc::new(LruCache::new(0, 5, 0));
let cache: Arc<LruCache<u64, u64>> = Arc::new(LruCache::new(1, 5, 0));
// do not need sender because this receiver will be cancelled.
let (_, recv) = channel::<()>();
let polled = Arc::new(AtomicBool::new(false));
Expand Down
12 changes: 7 additions & 5 deletions src/compute/src/memory/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const COMPACTOR_MEMORY_PROPORTION: f64 = 0.1;
const STORAGE_BLOCK_CACHE_MEMORY_PROPORTION: f64 = 0.3;

const STORAGE_META_CACHE_MAX_MEMORY_MB: usize = 4096;
const STORAGE_SHARED_BUFFER_MAX_MEMORY_MB: usize = 1024;
const STORAGE_SHARED_BUFFER_MAX_MEMORY_MB: usize = 4096;
const STORAGE_META_CACHE_MEMORY_PROPORTION: f64 = 0.35;
const STORAGE_SHARED_BUFFER_MEMORY_PROPORTION: f64 = 0.3;
const STORAGE_DEFAULT_HIGH_PRIORITY_BLOCK_CACHE_RATIO: usize = 50;
Expand Down Expand Up @@ -95,7 +95,8 @@ pub fn storage_memory_config(

if meta_cache_capacity_mb != default_meta_cache_capacity_mb {
default_block_cache_capacity_mb += default_meta_cache_capacity_mb;
default_block_cache_capacity_mb -= meta_cache_capacity_mb;
default_block_cache_capacity_mb =
default_block_cache_capacity_mb.saturating_sub(meta_cache_capacity_mb);
}

let default_shared_buffer_capacity_mb = ((non_reserved_memory_bytes as f64
Expand All @@ -112,7 +113,8 @@ pub fn storage_memory_config(
));
if shared_buffer_capacity_mb != default_shared_buffer_capacity_mb {
default_block_cache_capacity_mb += default_shared_buffer_capacity_mb;
default_block_cache_capacity_mb -= shared_buffer_capacity_mb;
default_block_cache_capacity_mb =
default_block_cache_capacity_mb.saturating_sub(shared_buffer_capacity_mb);
}
let block_cache_capacity_mb = storage_config
.block_cache_capacity_mb
Expand Down Expand Up @@ -170,15 +172,15 @@ pub fn storage_memory_config(

StorageMemoryConfig {
block_cache_capacity_mb,
block_shard_num,
meta_cache_capacity_mb,
meta_shard_num,
shared_buffer_capacity_mb,
data_file_cache_ring_buffer_capacity_mb,
meta_file_cache_ring_buffer_capacity_mb,
compactor_memory_limit_mb,
prefetch_buffer_capacity_mb,
high_priority_ratio_in_percent,
block_shard_num,
meta_shard_num,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/config/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ This page is automatically generated by `./risedev generate-example-config`
| Config | Description | Default |
|--------|-------------|---------|
| block_cache_capacity_mb | Capacity of sstable block cache. | |
| block_shard_num | | |
| cache_refill | | |
| check_compaction_result | | false |
| compact_iter_recreate_timeout_ms | | 600000 |
Expand All @@ -118,6 +119,7 @@ This page is automatically generated by `./risedev generate-example-config`
| mem_table_spill_threshold | The spill threshold for mem table. | 4194304 |
| meta_cache_capacity_mb | Capacity of sstable meta cache. | |
| meta_file_cache | | |
| meta_shard_num | | |
| min_sst_size_for_streaming_upload | Whether to enable streaming upload for sstable. | 33554432 |
| object_store | | |
| prefetch_buffer_capacity_mb | max memory usage for large query | |
Expand Down
2 changes: 2 additions & 0 deletions src/storage/benches/bench_compactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ pub fn mock_sstable_store() -> SstableStoreRef {
block_cache_capacity: 64 << 20,
meta_cache_capacity: 128 << 20,
high_priority_ratio: 0,
meta_shard_num: 2,
block_shard_num: 2,
prefetch_buffer_capacity: 64 << 20,
max_prefetch_block_number: 16,
data_file_cache: FileCache::none(),
Expand Down
2 changes: 2 additions & 0 deletions src/storage/benches/bench_multi_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ fn bench_builder(
block_cache_capacity: 64 << 20,
meta_cache_capacity: 128 << 20,
high_priority_ratio: 0,
meta_shard_num: 2,
block_shard_num: 2,
prefetch_buffer_capacity: 64 << 20,
max_prefetch_block_number: 16,
data_file_cache: FileCache::none(),
Expand Down

0 comments on commit d84f28f

Please sign in to comment.