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

refactor(frontend): make frontend compute runtime configurable #14597

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 8 additions & 0 deletions src/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ pub struct BatchConfig {

#[serde(default, flatten)]
pub unrecognized: Unrecognized<Self>,

#[serde(default = "default::batch::compute_runtime_worker_threads")]
/// compute runtime worker threads
pub compute_runtime_worker_threads: usize,
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
pub compute_runtime_worker_threads: usize,
pub frontend_compute_runtime_worker_threads: usize,

I suggest to rename to this since we have also runtime for batch in compute node, adding this makes things more clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed.

}

/// The section `[streaming]` in `risingwave.toml`.
Expand Down Expand Up @@ -1426,6 +1430,10 @@ pub mod default {
// 1 hour
60 * 60
}

pub fn compute_runtime_worker_threads() -> usize {
4
}
}

pub mod compaction_config {
Expand Down
1 change: 1 addition & 0 deletions src/config/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ meta_cached_traces_memory_limit_bytes = 134217728
[batch]
enable_barrier_read = false
statement_timeout_in_sec = 3600
compute_runtime_worker_threads = 4

[batch.developer]
batch_connector_message_buffer_size = 16
Expand Down
36 changes: 23 additions & 13 deletions src/frontend/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ impl FrontendEnv {
let server_addr = HostAddr::try_from("127.0.0.1:4565").unwrap();
let client_pool = Arc::new(ComputeClientPool::default());
let creating_streaming_tracker = StreamingJobTracker::new(meta_client.clone());
let compute_runtime = Arc::new(BackgroundShutdownRuntime::from(
Builder::new_multi_thread()
.worker_threads(
load_config("", FrontendOpts::default())
.batch
.compute_runtime_worker_threads,
)
.thread_name("rw-batch-local")
.enable_all()
.build()
.unwrap(),
));
Self {
meta_client,
catalog_writer,
Expand All @@ -184,7 +196,7 @@ impl FrontendEnv {
meta_config: MetaConfig::default(),
source_metrics: Arc::new(SourceMetrics::default()),
creating_streaming_job_tracker: Arc::new(creating_streaming_tracker),
compute_runtime: Self::create_compute_runtime(),
compute_runtime,
}
}

Expand Down Expand Up @@ -325,6 +337,15 @@ impl FrontendEnv {
let creating_streaming_job_tracker =
Arc::new(StreamingJobTracker::new(frontend_meta_client.clone()));

let compute_runtime = Arc::new(BackgroundShutdownRuntime::from(
Builder::new_multi_thread()
.worker_threads(batch_config.compute_runtime_worker_threads)
.thread_name("rw-batch-local")
.enable_all()
.build()
.unwrap(),
));

Ok((
Self {
catalog_reader,
Expand All @@ -343,7 +364,7 @@ impl FrontendEnv {
meta_config,
source_metrics,
creating_streaming_job_tracker,
compute_runtime: Self::create_compute_runtime(),
compute_runtime,
},
join_handles,
shutdown_senders,
Expand Down Expand Up @@ -432,17 +453,6 @@ impl FrontendEnv {
self.compute_runtime.clone()
}

fn create_compute_runtime() -> Arc<BackgroundShutdownRuntime> {
Arc::new(BackgroundShutdownRuntime::from(
Builder::new_multi_thread()
.worker_threads(4)
.thread_name("rw-batch-local")
.enable_all()
.build()
.unwrap(),
))
}

/// Cancel queries (i.e. batch queries) in session.
/// If the session exists return true, otherwise, return false.
pub fn cancel_queries_in_session(&self, session_id: SessionId) -> bool {
Expand Down
Loading