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

feat(memory): Separate total memory configurations for FE and Compactor #19372

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mod session;
mod stream_fragmenter;
use risingwave_common::config::{MetricLevel, OverrideConfig};
use risingwave_common::util::meta_addr::MetaAddressStrategy;
use risingwave_common::util::resource_util::memory::system_memory_available_bytes;
use risingwave_common::util::tokio_util::sync::CancellationToken;
pub use stream_fragmenter::build_graph;
mod utils;
Expand Down Expand Up @@ -159,6 +160,10 @@ pub struct FrontendOpts {
default_value = "./secrets"
)]
pub temp_secret_file_dir: String,

/// Total available memory for the frontend node in bytes. Used by both computing and storage.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Total available memory for the frontend node in bytes. Used by both computing and storage.
/// Total available memory for the frontend node in bytes. Used by frontend.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is not resolved.

Copy link
Member

Choose a reason for hiding this comment

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

Does storage run in frontend? IIRC, even in local execution mode, the TableScan is pushed to compute nodes.

#[clap(long, env = "RW_FE_TOTAL_MEMORY_BYTES", default_value_t = default_fe_total_memory_bytes())]
Li0k marked this conversation as resolved.
Show resolved Hide resolved
pub fe_total_memory_bytes: usize,
}

impl risingwave_common::opts::Opts for FrontendOpts {
Expand Down Expand Up @@ -220,3 +225,7 @@ pub fn start(
.unwrap()
})
}

pub fn default_fe_total_memory_bytes() -> usize {
system_memory_available_bytes()
}
4 changes: 2 additions & 2 deletions src/frontend/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ use risingwave_common::telemetry::manager::TelemetryManager;
use risingwave_common::telemetry::telemetry_env_enabled;
use risingwave_common::types::DataType;
use risingwave_common::util::addr::HostAddr;
use risingwave_common::util::cluster_limit;
use risingwave_common::util::cluster_limit::ActorCountPerParallelism;
use risingwave_common::util::iter_util::ZipEqFast;
use risingwave_common::util::runtime::BackgroundShutdownRuntime;
use risingwave_common::util::{cluster_limit, resource_util};
use risingwave_common::{GIT_SHA, RW_VERSION};
use risingwave_common_heap_profiling::HeapProfiler;
use risingwave_common_service::{MetricsManager, ObserverManager};
Expand Down Expand Up @@ -444,7 +444,7 @@ impl FrontendEnv {
.map_err(|err| anyhow!(err))?;
}

let total_memory_bytes = resource_util::memory::system_memory_available_bytes();
let total_memory_bytes = opts.fe_total_memory_bytes;
let heap_profiler =
HeapProfiler::new(total_memory_bytes, config.server.heap_profiling.clone());
// Run a background heap profiler
Expand Down
9 changes: 9 additions & 0 deletions src/storage/compactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use risingwave_common::config::{
AsyncStackTraceOption, CompactorMode, MetricLevel, OverrideConfig,
};
use risingwave_common::util::meta_addr::MetaAddressStrategy;
use risingwave_common::util::resource_util::memory::system_memory_available_bytes;
use risingwave_common::util::tokio_util::sync::CancellationToken;

use crate::server::{compactor_serve, shared_compactor_serve};
Expand Down Expand Up @@ -92,6 +93,10 @@ pub struct CompactorOpts {

#[clap(long, hide = true, env = "RW_PROXY_RPC_ENDPOINT", default_value = "")]
pub proxy_rpc_endpoint: String,

/// Total available memory for the frontend node in bytes. Used by both computing and storage.
#[clap(long, env = "RW_COMPACTOR_TOTAL_MEMORY_BYTES", default_value_t = default_compactor_total_memory_bytes())]
pub compactor_total_memory_bytes: usize,
}

impl risingwave_common::opts::Opts for CompactorOpts {
Expand Down Expand Up @@ -143,3 +148,7 @@ pub fn start(
}),
}
}

pub fn default_compactor_total_memory_bytes() -> usize {
system_memory_available_bytes()
}
9 changes: 5 additions & 4 deletions src/storage/compactor/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use crate::telemetry::CompactorTelemetryCreator;
use crate::CompactorOpts;

pub async fn prepare_start_parameters(
compactor_opts: &CompactorOpts,
config: RwConfig,
system_params_reader: SystemParamsReader,
) -> (
Expand All @@ -81,7 +82,7 @@ pub async fn prepare_start_parameters(
&system_params_reader,
&storage_memory_config,
)));
let non_reserved_memory_bytes = (system_memory_available_bytes() as f64
let non_reserved_memory_bytes = (compactor_opts.compactor_total_memory_bytes as f64
kwannoel marked this conversation as resolved.
Show resolved Hide resolved
* config.storage.compactor_memory_available_proportion)
as usize;
let meta_cache_capacity_bytes = storage_opts.meta_cache_capacity_mb * (1 << 20);
Expand Down Expand Up @@ -186,7 +187,7 @@ pub async fn compactor_serve(

// Register to the cluster.
let (meta_client, system_params_reader) = MetaClient::register_new(
opts.meta_address,
opts.meta_address.clone(),
WorkerType::Compactor,
&advertise_addr,
Default::default(),
Expand All @@ -210,7 +211,7 @@ pub async fn compactor_serve(
await_tree_reg,
storage_opts,
compactor_metrics,
) = prepare_start_parameters(config.clone(), system_params_reader.clone()).await;
) = prepare_start_parameters(&opts, config.clone(), system_params_reader.clone()).await;

let compaction_catalog_manager_ref = Arc::new(CompactionCatalogManager::new(Box::new(
RemoteTableAccessor::new(meta_client.clone()),
Expand Down Expand Up @@ -338,7 +339,7 @@ pub async fn shared_compactor_serve(
await_tree_reg,
storage_opts,
compactor_metrics,
) = prepare_start_parameters(config.clone(), system_params.into()).await;
) = prepare_start_parameters(&opts, config.clone(), system_params.into()).await;
let (sender, receiver) = mpsc::unbounded_channel();
let compactor_srv: CompactorServiceImpl = CompactorServiceImpl::new(sender);

Expand Down
7 changes: 3 additions & 4 deletions src/storage/src/hummock/store/hummock_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ use tokio::sync::oneshot;

use super::local_hummock_storage::LocalHummockStorage;
use super::version::{read_filter_for_version, CommittedVersion, HummockVersionReader};
use crate::compaction_catalog_manager::{
CompactionCatalogManager, CompactionCatalogManagerRef, FakeRemoteTableAccessor,
};
use crate::compaction_catalog_manager::CompactionCatalogManagerRef;
#[cfg(any(test, feature = "test"))]
use crate::compaction_catalog_manager::{CompactionCatalogManager, FakeRemoteTableAccessor};
use crate::error::StorageResult;
use crate::hummock::backup_reader::{BackupReader, BackupReaderRef};
use crate::hummock::compactor::{
Expand Down Expand Up @@ -724,7 +724,6 @@ impl HummockStorage {
}

/// Used in the compaction test tool
#[cfg(any(test, feature = "test"))]
pub async fn update_version_and_wait(&self, version: HummockVersion) {
use tokio::task::yield_now;
let version_id = version.id;
Li0k marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading