[
https://issues.apache.org/jira/browse/TRAFODION-2326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15635514#comment-15635514
]
ASF GitHub Bot commented on TRAFODION-2326:
-------------------------------------------
Github user prashanth-vasudev commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/815#discussion_r86497128
--- Diff: core/sql/executor/ex_sort.cpp ---
@@ -96,6 +96,72 @@ ExOperStats * ExSortTcb::doAllocateStatsEntry(CollHeap
*heap,
return stat;
}
+void ExSortTcb::setupPoolBuffers(ex_queue_entry *pentry_down)
+{
+ CollHeap *space = getGlobals()->getSpace();
+
+ // Allocate the buffer pool.
+ // Note that when memoryQuota system is enabled, we initialize the
+ // pool with atleast 2 buffer. This is to accomodate sort to progress
+ // even under extremely loaded environment(memory pressure)irrespective
+ // of memory quota system. The buffer size is calculated taking into
+ // account the estimate number of rows by the compiler and limited by
+ // maximum of GEN_SORT_MAX_BUFFER_SIZE. The memory quota system will
+ // come into force for additional buffers following this initial buffer.
+ Lng32 numBuffs = (sortTdb().sortOptions_->memoryQuotaMB()<=
0)?sortTdb().numBuffers_:2;
+ Lng32 numSortBuffs = 0;
+
+ // need separate pools for sorting and saving result rows
+ if (sortTdb().partialSort())
+ {
+ // give result pool and sort pool each half of the space
+ numSortBuffs = numBuffs = (numBuffs + 1)/2;
--- End diff --
numBuffs is the initial number to start with. There is another constant
max_num_buffs that determine the max buffers that can be used, controlled by
cqd. In the current case, the thinking is to divide the numbuffs to two halfs.
This is done only for partialSort feature which is not enabled by default.
> TopN sort consumes more memory than needed.
> -------------------------------------------
>
> Key: TRAFODION-2326
> URL: https://issues.apache.org/jira/browse/TRAFODION-2326
> Project: Apache Trafodion
> Issue Type: Bug
> Components: sql-exe
> Affects Versions: 2.1-incubating
> Reporter: Prashanth Vasudev
> Assignee: Prashanth Vasudev
>
> Records that get discarded , those that do not belong to TopN rows, release
> reference to the tupp descriptor, however the released tuple memory does not
> get reused for new records from child nodes.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)