Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compactor): introduce dedicated config for compactor meta cache #19203

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Oct 30, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

introduce dedicated config for compactor meta cache, avoiding misuse of CN's meta cache configuration in environments that lack config map isolation

related to #19245

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@github-actions github-actions bot added the type/fix Bug fix label Oct 30, 2024
Copy link
Contributor

@MrCroxx MrCroxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if it is okay that not calculating it in the memory usage.

@@ -683,6 +683,11 @@ pub struct CacheConfig {
#[serde(default)]
#[config_doc(omitted)]
pub meta_cache_eviction: CacheEvictionConfig,

/// Configure the capacity of the meta cache in MB explicitly for compactor.
// TODO(li0k): `compactor_meta_cache_capacity_mb` is only used for compactor meta cache configuration, it is not involved in the calculation of CN reserved memory, we consider removing it in the future..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: Does this field also benefit standalone deployment?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking whether we should just not expose a config to overwrite the compactor meta cache capacity. Instead, we can just use min(128MB, node memory * some fix ratio) as the meta cache capactiy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I took patrick's suggestion and used a calculated rule to determine the compactor's meta cache.
compactor_meta_cache_capacity_mb = min(128MB, avail_memory * 2%). And I restructured the configuration into Hummock/Compactor memory config so that standalone can also benefit.

@Li0k Li0k marked this pull request as draft October 30, 2024 08:16
@@ -84,10 +84,18 @@ pub async fn prepare_start_parameters(
let non_reserved_memory_bytes = (system_memory_available_bytes() as f64
* config.storage.compactor_memory_available_proportion)
as usize;
let meta_cache_capacity_bytes = storage_opts.meta_cache_capacity_mb * (1 << 20);
let meta_cache_capacity_bytes = storage_opts.compactor_meta_cache_capacity_mb * (1 << 20);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that extract_storage_memory_config is only used by compactor, I think it is better to directly refactor and rename extract_storage_memory_config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, rename extract_storage_memory_config to extract_storage_memory_config_for_test and add a new function for compactor memory config extract

@Li0k Li0k closed this Nov 1, 2024
@Li0k Li0k reopened this Nov 1, 2024
@kwannoel kwannoel self-requested a review November 1, 2024 15:13
pub const MAX_META_CACHE_SHARD_BITS: usize = 4;
pub const MIN_BUFFER_SIZE_PER_SHARD: usize = 256;
pub const MAX_BLOCK_CACHE_SHARD_BITS: usize = 6; // It means that there will be 64 shards lru-cache to avoid lock conflict.

pub fn extract_storage_memory_config(s: &RwConfig) -> StorageMemoryConfig {
pub const COMPACTOR_MEMORY_PROPORTION: f64 = 0.1;
Copy link
Contributor

@kwannoel kwannoel Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we file an issue? I suppose more broadly across different services, their memory ratios should sum up to 1.0.

pub const COMPACTOR_MEMORY_PROPORTION: f64 = 0.1;

// calculate the compactor meta cache capacity based on capacity and memory proportion
// compactor_meta_cache_capacity_mb = min(MIN_COMPACTOR_META_CACHE_CAPACITY_MB, memory * MAX_COMPACTOR_META_CACHE_CAPACITY_PROPORTION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is memory in the docs here referring to memory used by compactor or overall standalone process memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both compactor and standalone.

  1. dedicated compactor: extract_compactor_memory_config = 1.0
  2. standalone compactor: extract_compactor_memory_config = COMPACTOR_MEMORY_PROPORTION = 0. 1

And it doesn't change the original memory ratios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants