You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2017/09/18 17:01:37 UTC

[2/3] incubator-trafodion git commit: [TRAFODION-2738] Rowset buffer size during insert/upsert should be limited

[TRAFODION-2738] Rowset buffer size during insert/upsert should be limited

Ensured that up queue size is set to proper value in ExUnPackRowsTcb


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4534b2b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4534b2b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4534b2b2

Branch: refs/heads/master
Commit: 4534b2b26af1800902531d612d4a2fdca3453208
Parents: 3a15d7c
Author: selvaganesang <se...@esgyn.com>
Authored: Fri Sep 15 22:49:27 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Fri Sep 15 22:49:27 2017 +0000

----------------------------------------------------------------------
 core/sql/executor/ex_queue.cpp          | 26 +++++++++++++++-----------
 core/sql/executor/ex_queue.h            |  3 ++-
 core/sql/generator/GenRelPackedRows.cpp | 11 +++++------
 3 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4534b2b2/core/sql/executor/ex_queue.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_queue.cpp b/core/sql/executor/ex_queue.cpp
index 460aa60..3bd10d3 100644
--- a/core/sql/executor/ex_queue.cpp
+++ b/core/sql/executor/ex_queue.cpp
@@ -66,17 +66,7 @@ ex_queue::ex_queue(const queue_type    type,
   
   // make size a power of 2 and greater than 1.
   //
-  ULng32 count = 1;     
-  queue_index s = size_ - 1;
-  while (s > 1) {
-    count++;
-    s = s >> 1;
-  };
-
-  if (count > (sizeof(queue_index) * 8))
-    size_ = maxQueueSize;
-  else
-    size_ = (1 << count);
+  size_ = roundUp2Power(size_);
 
   ex_assert(size_ > 1, "invalid queue size");
 
@@ -950,7 +940,21 @@ void ex_queue::logRemoveHead()
 #endif
 }
 
+queue_index ex_queue::roundUp2Power(queue_index i)
+{
+  ULng32 count = 1;     
+  queue_index s = i - 1;
+  while (s > 1) {
+    count++;
+    s = s >> 1;
+  };
 
+  if (count > (sizeof(queue_index) * 8))
+    s  = maxQueueSize;
+  else
+    s = (1 << count);
+  return s;
+}
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4534b2b2/core/sql/executor/ex_queue.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_queue.h b/core/sql/executor/ex_queue.h
index 6e4d82a..2b51c52 100644
--- a/core/sql/executor/ex_queue.h
+++ b/core/sql/executor/ex_queue.h
@@ -324,6 +324,7 @@ inline
   { ExQueueAssert(upDown_ == DOWN_QUEUE,""); nextSubtask_ = nextSubtask; }
 //?johannes??
 
+  static queue_index roundUp2Power(queue_index i);
 
 private:
 
@@ -444,7 +445,7 @@ private:
     }
 
     void logRemoveHead();  
-
+  
 };  // ex_queue
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4534b2b2/core/sql/generator/GenRelPackedRows.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelPackedRows.cpp b/core/sql/generator/GenRelPackedRows.cpp
index 1f34b72..4088035 100644
--- a/core/sql/generator/GenRelPackedRows.cpp
+++ b/core/sql/generator/GenRelPackedRows.cpp
@@ -27,6 +27,7 @@
 #include "GenExpGenerator.h"
 #include "ExpCriDesc.h"
 #include "ComTdbUnPackRows.h"
+#include "ex_queue.h"
 
 // PhysUnPackRows::preCodeGen() -------------------------------------------
 // Perform local query rewrites such as for the creation and
@@ -418,20 +419,18 @@ PhysUnPackRows::codeGen(Generator *generator)
           getGroupAttr()->getOutputLogPropList()[0]->getResultCardinality().value();
       double  memoryLimitPerInstance =
               ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_FOR_UNPACK_ROWS_IN_MB) * 1024 * 1024;
+
+      rowsetSize = (rowsetSize < 1024 ? 1024 : rowsetSize);
       double estimatedMemory = rowsetSize * unPackColsTupleLen;
  
       if (estimatedMemory > memoryLimitPerInstance)
       {
          estimatedMemory = memoryLimitPerInstance;
          rowsetSize = estimatedMemory / unPackColsTupleLen;
+         rowsetSize = MAXOF(rowsetSize, 1);
       }
-      queue_index upQueueSize = rowsetSize; 
-
-      // Make sure it is at least 1024.
-      upQueueSize = (upQueueSize < 1024 ? 1024 : upQueueSize);
 
-      // Make sure that it is not more the 64K.
-      upQueueSize = (upQueueSize > 65536 ? 65536 : upQueueSize);
+      queue_index upQueueSize = ex_queue::roundUp2Power((queue_index)rowsetSize);
 
       unPackTdb =
 	new (space) ComTdbUnPackRows(childTdb,