-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
src: optimize usage of memory api #59260
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
Conversation
Review requested:
|
AFAIK, constrained memory can be greater than the total physical memory due to swaps/overcommitting (which usually are set explicitly). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59260 +/- ##
=======================================
Coverage 90.04% 90.04%
=======================================
Files 648 648
Lines 191200 191201 +1
Branches 37472 37473 +1
=======================================
+ Hits 172160 172170 +10
+ Misses 11665 11625 -40
- Partials 7375 7406 +31
🚀 New features to boost your workflow:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This does not seem related |
yeah, I misunderstood |
It is consistent with this. But i think you are right that the virtual memory can greater than physical memory. @bnoordhuis Hi ! could you please help take a look at this ? Thanks ! |
@@ -135,9 +135,13 @@ void PerIsolateOptions::HandleMaxOldSpaceSizePercentage( | |||
// Use uint64_t for the result to prevent data loss on 32-bit systems. | |||
uint64_t available_memory = | |||
(constrained_memory > 0 && constrained_memory != UINT64_MAX) | |||
? constrained_memory | |||
? std::min(total_memory, constrained_memory) |
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.
As you correctly noted, uv_get_total_memory
returns 0 when its value is unknown. This might become problematic if uv_get_constrained_memory
is defined but uv_get_total_memory
is not, as the min function would incorrectly return 0 despite a valid constraint being available.
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 seem we should remove std::min
in SetIsolateCreateParamsForNode
.
In summary, uv_get_constrained_memory reports the memory limit directly from cgroups—the Linux feature that orchestrators like Kubernetes and runtimes like Docker use to isolate resources. The function correctly reflects the container's configured limit, not the host's physical RAM. This behavior is essential for advanced techniques like memory overcommitment, which carries a significant risk of performance degradation if mismanaged. Given these trade-offs, I'm +0 on changing this feature. |
constrained_memory
maybe greater thanuv_get_total_memory
so we should take the minimum value.And
uv_get_total_memory
maybe 0.We should always report constrained memory in the report even though it is zero.
cc @Asaf-Federman
make -j4 test
(UNIX), orvcbuild test
(Windows) passes