Fix MT read memory limit defaulting to wrong size when off-heap limit is disabled - #14507
Conversation
Signed-off-by: Zach Puller <zpuller@nvidia.com>
Greptile SummaryThis PR fixes a bug where the multi-threaded read memory limit was calculated incorrectly when off-heap limit tracking is disabled ( Confidence Score: 5/5Safe to merge; the fix is minimal, well-scoped, and covered by a targeted regression test. No P0 or P1 findings. The refactoring is clean: computeEffectiveOffHeapLimit is correctly extracted as a private method, getPinnedPoolAndOffHeapLimits delegates to it, and computeMtReadLimit correctly handles the disabled-limit edge case. The test uses try/finally to clean up TestMemoryChecker state and directly validates the before/after arithmetic. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[initializePinnedPoolAndOffHeapLimits] --> B[getPinnedPoolAndOffHeapLimits]
B --> |confLimitEnabled=true| C[computeEffectiveOffHeapLimit]
C --> D{confLimit defined?}
D --> |yes| E[return confLimit]
D --> |no| F[derive from hardware memory]
B --> |confLimitEnabled=false| G[return confPinnedSize, -1]
A --> H{multiThreadReadMemoryLimit == 0?}
H --> |yes| I[computeMtReadLimit]
I --> J{nonPinnedLimit >= 0?}
J --> |yes| K[totalOffHeap = pinnedSize + nonPinnedLimit]
J --> |no -1, FIXED| L[computeEffectiveOffHeapLimit]
L --> M[hardware-derived estimate]
K --> N[return 0.9 x totalOffHeap]
M --> N
Reviews (2): Last reviewed commit: "pr comments" | Re-trigger Greptile |
|
build |
1 similar comment
|
build |
Signed-off-by: Zach Puller <zpuller@nvidia.com>
|
build |
Fixes #14292.
Description
When
spark.rapids.memory.host.offHeapLimit.enabledis false (the default),getPinnedPoolAndOffHeapLimitsreturns-1for the non-pinned limit (meaning unlimited).The code that sets the default MT read memory limit was using this
-1literally:With no pinned pool this produces
0; with a pinned pool (e.g. 2 GiB) it produces~0.9 * pinnedSize, sizing the limit off the pinned pool only and ignoring all non-pinned memory.The fix extracts the hardware-derived off-heap limit computation from
getPinnedPoolAndOffHeapLimitsinto a shared
computeEffectiveOffHeapLimitmethod, and uses it incomputeMtReadLimitwhennonPinnedLimit == -1to derive a concrete total from hardware instead.Note:
spark.rapids.sql.multiThreadedRead.memoryLimit.enableddefaults tofalse, so impact islimited to users who have explicitly enabled the feature. The hardware-derived calculation has a
known approximation limitation in certain environments (see #13628), called out in a new code
comment.
Before (2 GiB pinned pool, off-heap limit disabled): MT read limit ≈ 1.80 GiB (90% of pinned only)
After: MT read limit ≈ 78 GiB (90% of hardware-derived off-heap)
Checklists
GpuDeviceManagerSuite— "MT read limit should be 90% of total off heap when off heap limitdisabled": calls
computeMtReadLimitwithnonPinnedLimit=-1and asserts the result equals90% of the hardware-derived off-heap total. Fails against pre-fix code, passes after.