[GLUTEN-9344][VL] Document dynamic offheap sizing feature#9391
[GLUTEN-9344][VL] Document dynamic offheap sizing feature#9391zhouyuan merged 5 commits intoapache:mainfrom
Conversation
Signed-off-by: Yuan Zhou <yuan.zhou@ibm.com>
|
Thanks for opening a pull request! Could you open an issue for this pull request on Github Issues? https://github.com/apache/incubator-gluten/issues Then could you also rename commit message and pull request title in the following format? See also: |
| - 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. |
There was a problem hiding this comment.
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?
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
| @@ -0,0 +1,24 @@ | |||
| ## Dynamic Off-heap Sizing | |||
| Spark 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. 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. | |||
There was a problem hiding this comment.
Nit: recommend to break this into multiple code lines, which is more readable for editors not wrapping text visually. And it can also improve the readability in diffs.
Ditto for other changes.
|
|
||
| ## Limitations | ||
|
|
||
| This feature is still under heavy development. No newline at end of file |
There was a problem hiding this comment.
Suggestion: ** is still in early development.
steveburnett
left a comment
There was a problem hiding this comment.
Just a few suggestions of formatting and phrasing.
| ## 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. |
There was a problem hiding this comment.
| 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. | |
| 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. |
|
|
||
| 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. |
There was a problem hiding this comment.
| - Spark first attempts to allocate memory based on the on-heap size. Note that the maximum memory size is controlled by spark.executor.memory. | |
| - Spark first attempts to allocate memory based on the on-heap size. Note that the maximum memory size is controlled by `spark.executor.memory`. |
| - 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() - Runtime.getRuntime().freeMemory()) plus tracked off-heap memory in TreeMemoryConsumer. If an allocation exceeds this total committed memory, the allocation fails, triggering an OOM. |
There was a problem hiding this comment.
| 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() - Runtime.getRuntime().freeMemory()) plus tracked off-heap memory in TreeMemoryConsumer. If an allocation exceeds this total committed memory, the allocation fails, triggering an OOM. | |
| 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() - Runtime.getRuntime().freeMemory()`) plus tracked off-heap memory in `TreeMemoryConsumer`. If an allocation exceeds this total committed memory, the allocation fails and triggers an OOM. |
|
|
||
| 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() - Runtime.getRuntime().freeMemory()) plus tracked off-heap memory in TreeMemoryConsumer. If an allocation exceeds this total committed memory, the allocation fails, triggering an OOM. | ||
|
|
||
| With this change, the "quota check" is performed when an allocation in the native engine is informed to Gluten. 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. |
There was a problem hiding this comment.
"is informed to " - can you find another way to describe this? I'm not sure from this phrasing what happens here.
Maybe:
"is sent to Gluten"
"is performed when Gluten receives an allocation request"
or something else you can think of.
| - 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() - Runtime.getRuntime().freeMemory()) plus tracked off-heap memory in TreeMemoryConsumer. If an allocation exceeds this total committed memory, the allocation fails, triggering an OOM. |
There was a problem hiding this comment.
I think we use only Runtime.getRuntime().totalMemory() for the calculation here.
Signed-off-by: Yuan <yuanzhou@apache.org>
What changes were proposed in this pull request?
this patch adds documentation for dynamic off-heap sizing feature
fixes: #9344
How was this patch tested?
no need to test