Skip to content

Commit

Permalink
fix: don't count file cache buffer pool size if disabled (#12941)
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx authored Oct 18, 2023
1 parent f102193 commit 52f4c63
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions src/compute/src/memory_management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,30 @@ pub fn storage_memory_config(
//
// Adding more buffers can prevent allocators from waiting for buffers to be freed by flushers.

let data_file_cache_buffer_pool_capacity_mb = storage_config
.data_file_cache
.buffer_pool_size_mb
.unwrap_or(
storage_config.data_file_cache.file_capacity_mb
* (storage_config.data_file_cache.flushers
+ 2 * (1 << storage_config.data_file_cache.allocation_bits)),
);
let meta_file_cache_buffer_pool_capacity_mb = storage_config
.meta_file_cache
.buffer_pool_size_mb
.unwrap_or(
storage_config.meta_file_cache.file_capacity_mb
* (storage_config.meta_file_cache.flushers
+ 2 * (1 << storage_config.meta_file_cache.allocation_bits)),
);
let data_file_cache_buffer_pool_capacity_mb = if storage_config.data_file_cache.dir.is_empty() {
0
} else {
storage_config
.data_file_cache
.buffer_pool_size_mb
.unwrap_or(
storage_config.data_file_cache.file_capacity_mb
* (storage_config.data_file_cache.flushers
+ 2 * (1 << storage_config.data_file_cache.allocation_bits)),
)
};
let meta_file_cache_buffer_pool_capacity_mb = if storage_config.meta_file_cache.dir.is_empty() {
0
} else {
storage_config
.meta_file_cache
.buffer_pool_size_mb
.unwrap_or(
storage_config.meta_file_cache.file_capacity_mb
* (storage_config.meta_file_cache.flushers
+ 2 * (1 << storage_config.meta_file_cache.allocation_bits)),
)
};

let compactor_memory_limit_mb = storage_config.compactor_memory_limit_mb.unwrap_or(
((non_reserved_memory_bytes as f64 * compactor_memory_proportion).ceil() as usize) >> 20,
Expand Down Expand Up @@ -238,6 +246,17 @@ mod tests {
let mut storage_config = StorageConfig::default();
let total_non_reserved_memory_bytes = 8 << 30;

let memory_config =
storage_memory_config(total_non_reserved_memory_bytes, true, &storage_config);
assert_eq!(memory_config.block_cache_capacity_mb, 737);
assert_eq!(memory_config.meta_cache_capacity_mb, 860);
assert_eq!(memory_config.shared_buffer_capacity_mb, 737);
assert_eq!(memory_config.data_file_cache_buffer_pool_capacity_mb, 0);
assert_eq!(memory_config.meta_file_cache_buffer_pool_capacity_mb, 0);
assert_eq!(memory_config.compactor_memory_limit_mb, 819);

storage_config.data_file_cache.dir = "data".to_string();
storage_config.meta_file_cache.dir = "meta".to_string();
let memory_config =
storage_memory_config(total_non_reserved_memory_bytes, true, &storage_config);
assert_eq!(memory_config.block_cache_capacity_mb, 737);
Expand Down

0 comments on commit 52f4c63

Please sign in to comment.