-
Notifications
You must be signed in to change notification settings - Fork 595
[GLUTEN-9344][VL] Document dynamic offheap sizing feature #9391
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| layout: page | ||
| title: VeloxDynamicSizingOffheap | ||
| nav_order: 16 | ||
| parent: Developer Overview | ||
| --- | ||
|
|
||
| ## Dynamic Off-heap Sizing | ||
| Gluten requires setting both on-heap and off-heap memory sizes, which initializes different memory layouts. Improper configuration of these settings can lead to lower performance. | ||
|
|
||
| To fix this issue, dynamic off-heap sizing is an experimental feature designed to simplify this process. When enabled, off-heap settings are ignored, and Velox uses the on-heap size as the memory size. | ||
| ## Detail implementations | ||
| To understand the details, it's essential to learn the basics of JVM memory management. There are many resources discussing JVM internals: | ||
| - https://exia.dev/blog/2019-12-10/JVM-Memory-Model/ | ||
| - https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/garbage_collect.html | ||
| - https://www.scaler.com/topics/memory-management-in-java/ | ||
| - https://developers.redhat.com/articles/2021/09/09/how-jvm-uses-and-allocates-memory# | ||
|
|
||
| In general, the feature works as follows: | ||
|
|
||
| - Spark first attempts to allocate memory based on the on-heap size. Note that the maximum memory size is controlled by `spark.executor.memory`. | ||
| - When Velox tries to allocate memory, Gluten attempts to allocate from system memory and records this in the memory allocator. | ||
| - If there is sufficient memory, allocations proceed normally. | ||
| - If memory is insufficient, Spark performs garbage collection (GC) to free on-heap memory, allowing Velox to allocate memory. | ||
| - If memory remains insufficient after GC, Spark reports an out-of-memory (OOM) issue. | ||
|
|
||
| We then enforce a total memory quota, calculated as the sum of committed and in-use memory in the Java heap (using `Runtime.getRuntime().totalMemory()`) plus tracked off-heap memory in `TreeMemoryConsumer`. If an allocation exceeds this total committed memory, the allocation fails and triggers an OOM. | ||
|
|
||
| With this change, the "quota check" is performed when Gluten receives an memory allocation request. In practice, this means the Java codebase can oversubscribe memory within the on-heap quota, even if off-heap usage is sufficient to fail the allocation. | ||
|
|
||
| ## Limitations | ||
|
|
||
| This feature is in the preliminary stages of development and will be improved in future updates. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In gluten-core/src/main/java/org/apache/gluten/memory/memtarget/DynamicOffHeapSizingMemoryTarget.java the borrow code only checks for uncommitted memory (size + usedOffHeapMemory + totalHeapMemory <= TOTAL_MEMORY_SHARED).
It does not acquire memory from the TaskMemoryManager
How will this trigger spill / GC?