From c5cbe3dc5a9225d39ca3fda0845cabdb784f9a23 Mon Sep 17 00:00:00 2001 From: Dylan Chen Date: Fri, 20 Oct 2023 16:13:23 +0800 Subject: [PATCH] refine --- src/jni_core/src/jvm_runtime.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/jni_core/src/jvm_runtime.rs b/src/jni_core/src/jvm_runtime.rs index 285e77298b907..e60c17c6ec930 100644 --- a/src/jni_core/src/jvm_runtime.rs +++ b/src/jni_core/src/jvm_runtime.rs @@ -24,6 +24,9 @@ use jni::{InitArgsBuilder, JNIVersion, JavaVM, NativeMethod}; use risingwave_common::error::{ErrorCode, RwError}; use risingwave_common::util::resource_util::memory::system_memory_available_bytes; +/// Use 10% of compute total memory by default. Compute node uses 0.7 * system memory by default. +const DEFAULT_MEMORY_PROPORTION: f64 = 0.07; + pub static JVM: JavaVmWrapper = JavaVmWrapper::new(); pub struct JavaVmWrapper(OnceLock>); @@ -82,9 +85,10 @@ impl JavaVmWrapper { let jvm_heap_size = if let Ok(heap_size) = std::env::var("JVM_HEAP_SIZE") { heap_size } else { - // Use 10% of total memory by default - // TODO: should use compute-node's total_memory_bytes - format!("{}", system_memory_available_bytes() / 10) + format!( + "{}", + (system_memory_available_bytes() as f64 * DEFAULT_MEMORY_PROPORTION) as usize + ) }; // Build the VM properties