Github user Ben-Zvi commented on a diff in the pull request: https://github.com/apache/drill/pull/860#discussion_r124435170 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/SortMemoryManager.java --- @@ -312,52 +488,66 @@ private void adjustForLowMemory() { * one spill batch to make progress. */ - private void lowMemorySpillBatchSize() { + private void lowMemoryInternalBatchSizes() { // The "expected" size is with power-of-two rounding in some vectors. // We later work backwards to the row count assuming average internal // fragmentation. - // Must hold two input batches. Use (most of) the rest for the spill batch. + // Must hold two input batches. Use half of the rest for the spill batch. + // In a really bad case, the number here may be negative. We'll fix + // it below. - expectedSpillBatchSize = (int) (memoryLimit - 2 * estimatedInputSize); + int spillBufferSize = (int) (memoryLimit - 2 * inputBatchSize.maxBufferSize) / 2; --- End diff -- (1) spilled "buffer" or spilled "batch" size ? (2) Where is the possible negative number fixed ? Looks like setFromWorstCase() would set all three fields to negative numbers.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---