-
Notifications
You must be signed in to change notification settings - Fork 595
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): add jvm memory to compute node memory control #12965
Conversation
src/jni_core/src/jvm_runtime.rs
Outdated
@@ -134,3 +136,35 @@ pub fn register_native_method_for_jvm(jvm: &JavaVM) -> Result<(), jni::errors::E | |||
tracing::info!("register native methods for jvm successfully"); | |||
Ok(()) | |||
} | |||
|
|||
pub fn load_jvm_memory_stats() -> (usize, usize) { | |||
let mut env = JVM.as_ref().unwrap().attach_current_thread().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the JVM is not loaded before, will this trigger JVM to load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It will, so I set the initial heap memory of the JVM to be 16M.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds not good. 😕 I have no idea why LazyLock
does not expose its get() -> Option<_>
method. Maybe we can use a global atomic value as an indicator? cc @wangrunji0408
UPDATE: We can combine OnceLock::get_or_init
with OnceLock::get
as a workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
)) | ||
.into()); | ||
pub fn get_or_init(&self) -> Result<&JavaVM, &RwError> { | ||
self.0.get_or_init(Self::inner_new).as_ref() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: What about get_or_try_init
here? So that the failure will not be "permanent".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the JVM initialization failure would be permanent unless we restart and provide the correct configuration like CONNECTOR_LIBS_PATH
.🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Codecov Report
@@ Coverage Diff @@
## main #12965 +/- ##
==========================================
- Coverage 68.70% 68.62% -0.09%
==========================================
Files 1496 1496
Lines 250386 250460 +74
==========================================
- Hits 172035 171869 -166
- Misses 78351 78591 +240
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 20 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.