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/13 23:23:24 UTC
[06/15] incubator-trafodion git commit: Following changes are done in
BMO memory quota
Following changes are done in BMO memory quota
1) Enabled memory quota per node. The CQD BMO_MEMORY_LIMIT_PER_NODE
(renamed from EXE_MEMORY_LIMIT_PER_CPU) is set to 10240 MB by default.
Old attribute Old value Renamed Attribute New value
EXE_MEMORY_LIMIT_PER_CPU 0 BMO_MEMORY_LIMIT_PER_CPU 10240
EXE_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY 10 BMO_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY 25
EXE_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN 10 BMO_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN 25
EXE_MEMORY_LIMIT_LOWER_BOUND_PROBE_CACHE 10 BMO_MEMORY_LIMIT_LOWER_BOUND_PROBE_CACHE 25
EXE_MEMORY_LIMIT_LOWER_BOUND_SORT 10 BMO_MEMORY_LIMIT_LOWER_BOUND_SORT 200
2) Changes in EXPLAIN
Estimated memory per node for all BMOs at ROOT operator
Estimated memory per instance for every BMO operator
Memory quota per instance for every BMO operator
3) BMO TDB contains the memory quota per esp instance now.
4) Root TDB now contains the limit per node and estimated memory per node.
This can be used by WMS to change the memory allocation during
runtime without compilation. - Not yet implemented.
4) Added a CQD BMO_MEMORY_LIMIT_UPPER_BOUND to gap the memory
consumed by BMO by the same queries with less number of
bmos.
5) The unused memory quota is yielded to other fragments in the process
also.
6) Removed the code to limit the ESPs from being assigned to a fragement
based on the BMO memory quota.
7) Added a new CQD BMO_MEMORY_ESTIMATE_RATIO_CAP to gap the memory
estimate skew by any one BMO operator to 0.7.
8) To disable the memory quota per node, set BMO_MEMORY_LIMIT_PER_NODE to 0.
9) This memory quota is distributed proportionally based on the estimated memory
taking into consideration the number of bmo instances per operator and
the number of nodes available in the cluster to host these instances.
Hence, this memory quota should be valid in multi-fragments independent of the
number of fragments in an ESP.
10) Removed the CQD EXE_MEMORY_LIMIT_NONBMOS_PERCENT and EXE_MEMORY_RESERVED_FOR_MXOSRVR_IN_MB
11) Fixed BMO stats WM to be at least the allocated memory.
12) Changed the sort operator to account the bmo memory correctly.
(cherry picked from commit ba19c04a58890fdd845b03f8d915abdd487b6407)
Conflicts:
core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java
core/sql/cli/Context.cpp
core/sql/executor/ex_frag_rt.cpp
core/sql/executor/ex_sort.cpp
core/sql/regress/executor/EXPECTED131
core/sql/regress/executor/EXPECTED140
core/sql/regress/hive/EXPECTED009
core/sql/regress/hive/EXPECTED030
core/sql/regress/hive/FILTER009
core/sql/regress/seabase/EXPECTED010
core/sql/regress/seabase/EXPECTED011
core/sql/regress/seabase/EXPECTED016
core/sql/sqlcomp/DefaultConstants.h
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/00e3b874
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/00e3b874
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/00e3b874
Branch: refs/heads/master
Commit: 00e3b87432feb9d84455ca8d20e9899611fdb7ff
Parents: 3f9429f
Author: selvaganesang <se...@esgyn.com>
Authored: Fri Sep 1 06:31:57 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Fri Sep 1 06:31:57 2017 +0000
----------------------------------------------------------------------
core/sqf/src/seatrans/.gitignore | 2 +
.../transactional/SplitBalanceHelper.java | 394 ---
core/sql/cli/Context.cpp | 3 +-
core/sql/cli/Context.h | 18 +-
core/sql/cli/Globals.cpp | 47 +
core/sql/cli/Globals.h | 6 +-
core/sql/cli/Statement.cpp | 8 +-
core/sql/comexe/ComTdbRoot.cpp | 4 +-
core/sql/comexe/ComTdbRoot.h | 8 +
core/sql/executor/Allocator.cpp | 4 +-
core/sql/executor/ExStats.h | 2 +
core/sql/executor/cluster.cpp | 16 +-
core/sql/executor/ex_frag_rt.cpp | 45 +-
core/sql/executor/ex_mj.cpp | 2 +-
core/sql/executor/ex_sort.cpp | 3 +
core/sql/executor/ex_split_bottom.cpp | 2 +-
core/sql/generator/GenExplain.cpp | 37 +-
core/sql/generator/GenPreCode.cpp | 40 +-
core/sql/generator/GenProbeCache.cpp | 32 +-
core/sql/generator/GenRelEnforcer.cpp | 22 +-
core/sql/generator/GenRelGrby.cpp | 73 +-
core/sql/generator/GenRelJoin.cpp | 79 +-
core/sql/generator/GenRelMisc.cpp | 70 +-
core/sql/generator/GenRelSequence.cpp | 46 +-
core/sql/optimizer/RelEnforcer.h | 4 +-
core/sql/optimizer/RelExpr.cpp | 75 +-
core/sql/optimizer/RelExpr.h | 18 +-
core/sql/optimizer/RelGrby.h | 2 +-
core/sql/optimizer/RelJoin.h | 2 +-
core/sql/optimizer/RelProbeCache.h | 2 +-
core/sql/optimizer/RelSequence.h | 2 +-
core/sql/regress/executor/EXPECTED107 | 47 +
core/sql/regress/executor/EXPECTED131 | 12 +
core/sql/regress/executor/EXPECTED140 | 51 +-
core/sql/regress/executor/TEST107 | 6 +
core/sql/regress/hive/EXPECTED009 | 32 +-
core/sql/regress/hive/EXPECTED030 | 2636 ++++++++++++++++++
core/sql/regress/hive/FILTER009 | 1 +
core/sql/regress/seabase/EXPECTED010 | 460 +--
core/sql/regress/seabase/EXPECTED011 | 19 +-
core/sql/regress/seabase/EXPECTED016 | 161 +-
core/sql/sort/SortTopN.cpp | 6 +-
core/sql/sort/SortUtil.cpp | 8 +-
core/sql/sqlcomp/DefaultConstants.h | 19 +-
core/sql/sqlcomp/nadefaults.cpp | 29 +-
45 files changed, 3507 insertions(+), 1048 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sqf/src/seatrans/.gitignore
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/.gitignore b/core/sqf/src/seatrans/.gitignore
index e1dcf48..ac89993 100644
--- a/core/sqf/src/seatrans/.gitignore
+++ b/core/sqf/src/seatrans/.gitignore
@@ -15,4 +15,6 @@ hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/Trans
hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TrxTransactionState.java
hbase-trx/src/main/java/org/apache/hadoop/hbase/client/ClientScanner98.java
hbase-trx/src/main/java/org/apache/hadoop/hbase/client/TrafParallelClientScanner.java
+hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java
+hbase-trx/src/main/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionScannerHolder.java
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java
deleted file mode 100644
index 989415b..0000000
--- a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/coprocessor/transactional/SplitBalanceHelper.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/**
- * * @@@ START COPYRIGHT @@@
- * *
- * * Licensed to the Apache Software Foundation (ASF) under one
- * * or more contributor license agreements. See the NOTICE file
- * * distributed with this work for additional information
- * * regarding copyright ownership. The ASF licenses this file
- * * to you under the Apache License, Version 2.0 (the
- * * "License"); you may not use this file except in compliance
- * * with the License. You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing,
- * * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * * KIND, either express or implied. See the License for the
- * * specific language governing permissions and limitations
- * * under the License.
- * *
- * * @@@ END COPYRIGHT @@@
- * **/
-
-package org.apache.hadoop.hbase.coprocessor.transactional;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.transactional.TransactionalRegionScannerHolder;
-import org.apache.hadoop.hbase.regionserver.transactional.TrxTransactionState;
-import org.apache.hadoop.hbase.regionserver.transactional.TransactionState;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
-
-public class SplitBalanceHelper {
- private static final Log LOG = LogFactory.getLog(SplitBalanceHelper.class);
-
- private Path flushPath;
-
- private static String zkTable;
- private static String zSplitBalPath = TrxRegionObserver.zTrafPath + "splitbalance/";
- private static String zSplitBalPathNoSlash = TrxRegionObserver.zTrafPath + "splitbalance";
- private static String SPLIT = "SPLIT";
- private static String BALANCE = "BALANCE";
- private static final String FLUSH_PATH = "traf.txn.out";
- private static AtomicBoolean needsCleanup = new AtomicBoolean(true);
- private String balancePath;
- private String splitPath;
- private String regionPath;
-
- private ZooKeeperWatcher zkw;
- private HRegionInfo hri;
- private HRegion region;
- private String tablename;
-
- public SplitBalanceHelper(HRegion my_Region, ZooKeeperWatcher zkw, Configuration conf) {
-
- String parentZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
- HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
- SplitBalanceHelper.zkTable = parentZNode + "/table";
- if(LOG.isDebugEnabled()) LOG.debug("zkTable value: " + SplitBalanceHelper.zkTable);
-
- String fileName = FLUSH_PATH + getTimeStamp();
- this.region = my_Region;
- this.hri = my_Region.getRegionInfo();
- this.zkw = zkw;
- this.tablename = my_Region.getTableDesc().getNameAsString();
- try {
- if (ZKUtil.checkExists(zkw, zSplitBalPathNoSlash) == -1) {
- if (LOG.isDebugEnabled()) LOG.debug("HELPER create with parents");
- ZKUtil.createWithParents(zkw, zSplitBalPathNoSlash);
- }
- } catch (KeeperException ke) {
- LOG.error("ERROR: Zookeeper exception: " + ke);
- }
- this.flushPath = new Path(region.getRegionFileSystem().getRegionDir(), fileName);
- regionPath = zSplitBalPath + this.tablename + "/" + hri.getEncodedName();
- balancePath = regionPath + "/" + BALANCE + "/";
- splitPath = regionPath + "/" + SPLIT + "/";
-
- if (SplitBalanceHelper.needsCleanup.compareAndSet(true, false)) {
- zkCleanup();
- }
- }
-
- public Path getPath() {
- return flushPath;
- }
-
- public boolean getSplit() {
- return getSplit(null);
- }
-
- public boolean getSplit(StringBuilder path) {
- try {
- byte[] splPath = ZKUtil.getData(zkw, splitPath.substring(0, splitPath.length() - 1));
- if (splPath == null) {
- return false;
- } else {
- if (path != null)
- path.append(splPath.toString());
- if (LOG.isDebugEnabled()) LOG.debug("Split information retrieved, path is: " + splPath.toString());
- return true;
- }
- } catch (Exception e) {
- if (LOG.isErrorEnabled()) LOG.error("Keeper exception: " + e);
- return false;
- }
- }
-
- public void setSplit(HRegion leftRegion, HRegion rightRegion) throws IOException {
- String zLeftKey = zSplitBalPath + leftRegion.getRegionInfo().getEncodedName();
- String zRightKey = zSplitBalPath + rightRegion.getRegionInfo().getEncodedName();
-
- try {
- if (ZKUtil.checkExists(zkw, balancePath.substring(0, balancePath.length() - 1)) != -1) {
- clearBalance();
- }
- if (LOG.isDebugEnabled()) LOG.debug("Split checking for left key ");
- if (ZKUtil.checkExists(zkw, zLeftKey) == -1) {
- if (LOG.isDebugEnabled()) LOG.debug("Split creating left key with parents");
- ZKUtil.createWithParents(zkw, zLeftKey);
- }
- if (LOG.isDebugEnabled()) LOG.debug("Split checking for right key ");
- if (ZKUtil.checkExists(zkw, zRightKey) == -1) {
- if (LOG.isDebugEnabled()) LOG.debug("Split creating right key with parents");
- ZKUtil.createWithParents(zkw, zRightKey);
- }
- if (LOG.isDebugEnabled()) LOG.debug("Split createAndFailSilent for left key ");
- ZKUtil.createAndFailSilent(zkw, zLeftKey + "/" + SPLIT, Bytes.toBytes(flushPath.toString()));
- if (LOG.isDebugEnabled()) LOG.debug("Split createAndFailSilent for right key ");
- ZKUtil.createAndFailSilent(zkw, zRightKey + "/" + SPLIT, Bytes.toBytes(flushPath.toString()));
- if (LOG.isDebugEnabled()) LOG.debug("Split coordination node written for " + leftRegion.getRegionInfo().getRegionNameAsString() + " and " + rightRegion.getRegionInfo().getRegionNameAsString());
- } catch (KeeperException ke) {
- LOG.error("ERROR: Zookeeper exception: " + ke);
- }
- }
-
- public void setSplit() {
-
- try {
- if (ZKUtil.checkExists(zkw, balancePath.substring(0, balancePath.length() - 1)) != -1) {
- clearBalance();
- }
- if (ZKUtil.checkExists(zkw, splitPath.substring(0, splitPath.length() - 1)) == -1) {
- ZKUtil.createWithParents(zkw, splitPath.substring(0, splitPath.length() - 1));
- }
- ZKUtil.createSetData(zkw, splitPath.substring(0, splitPath.length() - 1), Bytes.toBytes(flushPath.toString()));
- if (LOG.isDebugEnabled()) LOG.debug("Setting split coordination node for " + hri.getRegionNameAsString());
- } catch (KeeperException ke) {
- LOG.error("ERROR: Zookeeper exception: " + ke);
- }
- }
-
- public void clearSplit() {
- if (LOG.isTraceEnabled()) LOG.trace("clearSplit called for region: " + this.hri.getRegionNameAsString());
- try {
- ZKUtil.deleteNodeRecursively(zkw, regionPath);
- } catch (KeeperException ke) {
- LOG.error("Zookeeper exception: " + ke);
- }
- }
-
- public boolean getBalance(StringBuilder path) {
- try {
- byte[] balPath = ZKUtil.getData(zkw, balancePath.substring(0, balancePath.length() - 1));
- if (balPath == null)
- return false;
- else {
- path.append(new String(balPath));
- if (LOG.isDebugEnabled()) LOG.debug("Balance information retrieved, path is: " + new String(balPath));
- return true;
- }
- } catch (Exception e) {
- if (LOG.isErrorEnabled())
- LOG.error("Keeper exception: " + e);
- }
- return true;
- }
-
- public void setBalance() throws IOException {
-
- try {
- if (ZKUtil.checkExists(zkw, splitPath.substring(0, splitPath.length() - 1)) != -1) {
- throw new IOException("SPLIT node already exists when trying to add BALANCE node");
- }
-
- if (ZKUtil.checkExists(zkw, balancePath.substring(0, balancePath.length() - 1)) == -1) {
- if (LOG.isDebugEnabled()) LOG.debug("setBalance createWithParents balancePath");
- ZKUtil.createWithParents(zkw, balancePath.substring(0, balancePath.length() - 1));
- }
- ZKUtil.createSetData(zkw, balancePath.substring(0, balancePath.length() - 1), Bytes.toBytes(flushPath.toString()));
- if (LOG.isDebugEnabled()) LOG.debug("Setting balance coordination node for " + hri.getRegionNameAsString());
-
- } catch (KeeperException ke) {
- LOG.error("ERROR: Zookeeper exception: " + ke);
- }
- }
-
- public void clearBalance() {
- if (LOG.isTraceEnabled()) LOG.trace("clearBalance called for region: " + this.hri.getRegionNameAsString());
- try {
- ZKUtil.deleteNodeRecursively(zkw, regionPath);
- } catch (KeeperException ke) {
- LOG.error("Zookeeper exception: " + ke);
- }
- }
-
- private long getTimeStamp() {
- return System.currentTimeMillis();
- }
-
- protected boolean pendingListClear(Set<TrxTransactionState> commitPendingTransactions) throws IOException {
- if (commitPendingTransactions.isEmpty()) {
- if (LOG.isDebugEnabled())
- LOG.debug("pendingListClear is true because commitPendingTransactions is empty " + hri.getRegionNameAsString());
- return true;
- } else {
- // Check to see if all of the TrxTransaction state objects
- // have dropTable Recorded, in which case the pending list is
- // considered clear of pending list.
- for (TrxTransactionState transactionState : commitPendingTransactions) {
- // if even one transaction state does not have drop table recorded
- // then pendingList is not yet clear.
- if (!transactionState.dropTableRecorded()) {
- if (LOG.isDebugEnabled())
- LOG.debug("pendingListClear is false commitPendingTransactions is not empty "
- + hri.getRegionNameAsString());
- return false;
- }
- }
- // Reaching here means pendingListClear.
- LOG.info("pendingListClear is true because dropTableRecorded is true " + hri.getRegionNameAsString());
- return true;
- }
- }
-
- //Returning true indicates scannerList is Clear.
- protected boolean scannersListClear(ConcurrentHashMap<Long, TransactionalRegionScannerHolder> scanners,
- ConcurrentHashMap<String, TrxTransactionState> transactionsById) throws IOException {
- if(scanners.isEmpty())
- {
- if (LOG.isDebugEnabled()) LOG.debug("scannersListClear Scanners is empty: " + hri.getRegionNameAsString());
- return true;
- }
- else
- {
- if (LOG.isDebugEnabled()) LOG.debug("scannersListClear Scanners is not empty: " + hri.getRegionNameAsString());
- Iterator<Map.Entry<Long, TransactionalRegionScannerHolder>> scannerIter = scanners.entrySet().iterator();
- TransactionalRegionScannerHolder rsh = null;
- Map.Entry<Long, TransactionalRegionScannerHolder> entry;
- while(scannerIter.hasNext())
- {
- entry = scannerIter.next();
- rsh = entry.getValue();
- if (rsh != null)
- {
- if (LOG.isDebugEnabled()) LOG.debug("scannersListClear Active Scanner is: "+ rsh.scannerId +
- " Txid: "+ rsh.transId + " Region: " + hri.getRegionNameAsString());
- String key = hri.getRegionNameAsString() + rsh.transId;
- TrxTransactionState trxState = transactionsById.get(key);
-
- //if trxState is present means there is activity with this region.
- //Hence don't return true.
- if(trxState != null)
- {
- LOG.info("scannersListClear Active Scanner found, ScannerId: " +
- rsh.scannerId + " Txid: "+ rsh.transId + " Region: " + hri.getRegionNameAsString());
- return false;
-
- }
- }
- }
- //Reaching here means, there is no active scanner.
- return true;
- }
- }
-
- protected void pendingWait(Set<TrxTransactionState> commitPendingTransactions, int pendingDelayLen) throws IOException {
- int count = 1;
- while (!pendingListClear(commitPendingTransactions)) {
- try {
- if (LOG.isDebugEnabled()) LOG.debug("pendingWait() delay, count " + count++ + " on: " + hri.getRegionNameAsString());
- Thread.sleep(pendingDelayLen);
- } catch (InterruptedException e) {
- String error = "Problem while calling sleep() on pendingWait delay, " + e;
- if (LOG.isErrorEnabled()) LOG.error("Problem while calling sleep() on preSplit delay, returning. " + e);
- throw new IOException(error);
- }
- }
- }
-
- /*
- protected void scannersWait(ConcurrentHashMap<Long, TransactionalRegionScannerHolder> scanners, int pendingDelayLen)
- throws IOException {
- int count = 1;
- while (!scannersListClear(scanners)) {
- try {
- if (LOG.isDebugEnabled()) LOG.debug("scannersWait() delay, count " + count++ + " on: " + hri.getRegionNameAsString());
- Thread.sleep(pendingDelayLen);
- } catch (InterruptedException e) {
- String error = "Problem while calling sleep() on scannersWait delay, " + e;
- if (LOG.isErrorEnabled()) LOG.error("Problem while calling sleep() on preSplit delay, returning. " + e);
- throw new IOException(error);
- }
- }
- }
- */
-
- protected void pendingAndScannersWait(Set<TrxTransactionState> commitPendingTransactions,
- ConcurrentHashMap<Long, TransactionalRegionScannerHolder> scanners,
- ConcurrentHashMap<String, TrxTransactionState> transactionsById, int pendingDelayLen) throws IOException {
- int count = 1;
- while (!scannersListClear(scanners, transactionsById) || !pendingListClear(commitPendingTransactions)) {
- try {
- if (LOG.isDebugEnabled()) LOG.debug("pendingAndScannersWait() delay, count " + count++ + " on: " + hri.getRegionNameAsString());
- Thread.sleep(pendingDelayLen);
- } catch (InterruptedException e) {
- String error = "Problem while calling sleep() on pendingAndScannersWait delay, " + e;
- if (LOG.isErrorEnabled()) LOG.error("Problem while calling sleep() on pendingAndScannersWait delay, returning. " + e);
- throw new IOException(error);
- }
- }
- }
-
- protected void activeWait(ConcurrentHashMap<String, TrxTransactionState> transactionsById, int activeDelayLen,
- int splitDelayLimit) throws IOException {
- int counter = 0;
- int minutes = 0;
- int currentMin = 0;
-
- boolean delayMsg = false;
- while (!transactionsById.isEmpty()) {
- try {
- delayMsg = true;
- Thread.sleep(activeDelayLen);
- counter++;
- currentMin = (counter * activeDelayLen) / 60000;
-
- if (currentMin > minutes) {
- minutes = currentMin;
- if (LOG.isInfoEnabled()) LOG.info("Delaying split due to transactions present. Delayed : " + minutes + " minute(s) on "
- + hri.getRegionNameAsString());
- }
- if (minutes >= splitDelayLimit) {
- if (LOG.isWarnEnabled()) LOG.warn("Surpassed split delay limit of " + splitDelayLimit + " minutes. Continuing with split");
- delayMsg = false;
- break;
- }
- } catch (InterruptedException e) {
- String error = "Problem while calling sleep() on preSplit delay - activeWait: " + e;
- if (LOG.isErrorEnabled()) LOG.error(error);
- throw new IOException(error);
- }
- }
- if (delayMsg) {
- if (LOG.isWarnEnabled()) LOG.warn("Continuing with split operation, no active transactions on: " + hri.getRegionNameAsString());
- }
- }
-
- protected void zkCleanup() {
- if (LOG.isTraceEnabled()) LOG.trace("zkCleanup -- ENTRY");
- try {
- List<String> trafTables = ZKUtil.listChildrenNoWatch(zkw, zSplitBalPathNoSlash);
- List<String> hbaseTables = ZKUtil.listChildrenNoWatch(zkw, SplitBalanceHelper.zkTable);
- if(trafTables != null && hbaseTables != null) {
- for (String tableName : trafTables) {
- if (!hbaseTables.contains(tableName)) {
- if (LOG.isTraceEnabled()) LOG.trace("zkCleanup, removing " + zSplitBalPath + tableName);
- ZKUtil.deleteNodeRecursively(zkw, zSplitBalPath + tableName);
- }
- }
- }
- } catch (KeeperException ke) {
- if (LOG.isErrorEnabled()) LOG.error("zkCleanup error, please check your ZooKeeper: " + ke);
- }
- if (LOG.isTraceEnabled()) LOG.trace("zkCleanup -- EXIT");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/cli/Context.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Context.cpp b/core/sql/cli/Context.cpp
index ac3d9d9..9e03b7d 100644
--- a/core/sql/cli/Context.cpp
+++ b/core/sql/cli/Context.cpp
@@ -186,7 +186,8 @@ ContextCli::ContextCli(CliGlobals *cliGlobals)
arkcmpInitFailed_(&exHeap_),
trustedRoutines_(&exHeap_),
roleIDs_(NULL),
- numRoles_(0)
+ numRoles_(0),
+ unusedBMOsMemoryQuota_(0)
{
exHeap_.setJmpBuf(cliGlobals->getJmpBuf());
cliSemaphore_ = new (&exHeap_) CLISemaphore();
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/cli/Context.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/Context.h b/core/sql/cli/Context.h
index ad5a0be..8a257fa 100644
--- a/core/sql/cli/Context.h
+++ b/core/sql/cli/Context.h
@@ -217,7 +217,21 @@ public:
ExSqlComp::ReturnStatus sendXnMsgToArkcmp
(char * data, Lng32 dataSize,
Lng32 xnMsgType, ComDiagsArea* &diagsArea);
-
+
+ inline NABoolean grabMemoryQuotaIfAvailable(ULng32 size)
+ {
+ if ( unusedBMOsMemoryQuota_ < size ) return FALSE;
+ unusedBMOsMemoryQuota_ -= size ;
+ return TRUE;
+ }
+
+ inline void resetMemoryQuota() { unusedBMOsMemoryQuota_ = 0 ; }
+
+ inline ULng32 unusedMemoryQuota() { return unusedBMOsMemoryQuota_; }
+
+ inline void yieldMemoryQuota(ULng32 size)
+ { unusedBMOsMemoryQuota_ += size; }
+
private:
// The heap where executor 'stuff' will be allocated from.
@@ -513,6 +527,8 @@ private:
// It points to a list of 'black box' of data allocated by user and is returned
// back whenever this context is in use.
HashQueue * trafSElist_;
+ // memory quota allocation given back by BMOs to be used by other BMOs
+ ULng32 unusedBMOsMemoryQuota_;
NABoolean deleteStats()
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/cli/Globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Globals.cpp b/core/sql/cli/Globals.cpp
index 070ed84..6f97513 100644
--- a/core/sql/cli/Globals.cpp
+++ b/core/sql/cli/Globals.cpp
@@ -121,6 +121,7 @@ CliGlobals::CliGlobals(NABoolean espProcess)
#ifdef SQ_PHANDLE_VERIFIER
, myVerifier_(-1)
#endif
+ , espProcess_(espProcess)
{
globalsAreInitialized_ = FALSE;
executorMemory_.setThreadSafe();
@@ -1141,6 +1142,52 @@ void CliGlobals::deleteContexts()
}
#endif // _DEBUG
+// The unused BMO memory quota can now be utilized by the other
+// BMO instances from the same or different fragment
+// In case of ESP process, the unused memory quota is maintained
+// at the defaultContext. In case of master process, the ununsed
+// memory quota is maintained in the context of the connection
+
+NABoolean CliGlobals::grabMemoryQuotaIfAvailable(ULng32 size)
+{
+ ContextCli *context;
+ if (espProcess_)
+ context = defaultContext_;
+ else
+ context = currContext();
+ return context->grabMemoryQuotaIfAvailable(size);
+}
+
+void CliGlobals::resetMemoryQuota()
+{
+ ContextCli *context;
+ if (espProcess_)
+ context = defaultContext_;
+ else
+ context = currContext();
+ return context->resetMemoryQuota();
+}
+
+ULng32 CliGlobals::unusedMemoryQuota()
+{
+ ContextCli *context;
+ if (espProcess_)
+ context = defaultContext_;
+ else
+ context = currContext();
+ return context->unusedMemoryQuota();
+}
+
+void CliGlobals::yieldMemoryQuota(ULng32 size)
+{
+ ContextCli *context;
+ if (espProcess_)
+ context = defaultContext_;
+ else
+ context = currContext();
+ return context->yieldMemoryQuota(size);
+}
+
void SQ_CleanupThread(void *arg)
{
HBaseClient_JNI::deleteInstance();
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/cli/Globals.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/Globals.h b/core/sql/cli/Globals.h
index 2eeb746..2af4f1b 100644
--- a/core/sql/cli/Globals.h
+++ b/core/sql/cli/Globals.h
@@ -431,10 +431,13 @@ inline
LmLanguageManagerC * getLanguageManagerC();
LmLanguageManagerJava * getLanguageManagerJava();
-
#ifdef _DEBUG
void deleteContexts();
#endif // _DEBUG
+ NABoolean grabMemoryQuotaIfAvailable(ULng32 size);
+ void resetMemoryQuota();
+ ULng32 unusedMemoryQuota();
+ void yieldMemoryQuota(ULng32 size);
private:
enum {
@@ -622,6 +625,7 @@ private:
// for trusted UDR invocations from executor and compiler
LmLanguageManagerC *langManC_;
LmLanguageManagerJava *langManJava_;
+ NABoolean espProcess_;
};
#pragma warn(1506) // warning elimination
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/cli/Statement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index a6aead5..d0e2541 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -2962,7 +2962,13 @@ RETCODE Statement::execute(CliGlobals * cliGlobals, Descriptor * input_desc,
break;
}
}
-
+ // In case of master, the unused memory quota needs to be reset
+ // with every statement execution. Hence, when there are multiple
+ // statements active in the master, the unused memory quota management
+ // may not work as expected
+ // Currently only one active statement can be assigned to an ESP
+ // So, esp unused memory quota management should work correctly.
+ context_->resetMemoryQuota();
/* execute it */
if( root_tdb )
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/comexe/ComTdbRoot.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbRoot.cpp b/core/sql/comexe/ComTdbRoot.cpp
index 511e991..c77471e 100644
--- a/core/sql/comexe/ComTdbRoot.cpp
+++ b/core/sql/comexe/ComTdbRoot.cpp
@@ -70,7 +70,9 @@ ComTdbRoot::ComTdbRoot()
rtFlags5_(0),
compilationStatsData_(NULL),
objectUidList_(NULL),
- cursorType_(SQL_READONLY_CURSOR)
+ cursorType_(SQL_READONLY_CURSOR),
+ bmoMemLimitPerNode_(0),
+ estBmoMemPerNode_(0)
{
//setPlanVersion(ComVersion_GetCurrentPlanVersion());
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/comexe/ComTdbRoot.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbRoot.h b/core/sql/comexe/ComTdbRoot.h
index b1e4662..9c40a07 100644
--- a/core/sql/comexe/ComTdbRoot.h
+++ b/core/sql/comexe/ComTdbRoot.h
@@ -577,6 +577,8 @@ protected:
NABasicPtr snapshotscanTempLocation_; // 360-367
QueuePtr listOfSnapshotScanTables_; // 368-375
+ Float64 bmoMemLimitPerNode_;
+ Float64 estBmoMemPerNode_;
public:
@@ -1312,6 +1314,12 @@ public:
Int64 getCpuLimit() { return cpuLimit_; }
+ void setBmoMemoryLimitPerNode(double limit) { bmoMemLimitPerNode_ = limit; }
+ double getBmoMemoryLimitPerNode() { return bmoMemLimitPerNode_; }
+
+ void setEstBmoMemoryPerNode(double estMem) { estBmoMemPerNode_ = estMem; }
+ double getEstBmoMemoryPerNode() { return estBmoMemPerNode_; }
+
NABoolean getQueryLimitDebug() const
{return ((rtFlags4_ & QUERY_LIMIT_DEBUG) != 0);};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/Allocator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/Allocator.cpp b/core/sql/executor/Allocator.cpp
index c9a451f..8870488 100644
--- a/core/sql/executor/Allocator.cpp
+++ b/core/sql/executor/Allocator.cpp
@@ -117,7 +117,7 @@ namespace ExOverflow
#endif
if (yieldMB)
{
- exeGlobals_->yieldMemoryQuota(yieldMB);
+ GetCliGlobals()->yieldMemoryQuota(yieldMB);
}
}
@@ -184,7 +184,7 @@ namespace ExOverflow
ByteCount quotaIncrease = (ByteCount) (totalBytes - quota_);
#endif
UInt32 quotaIncreaseMB = (quotaIncrease + ONE_MEGABYTE - 1)/ ONE_MEGABYTE;
- if (exeGlobals_->grabMemoryQuotaIfAvailable(quotaIncreaseMB))
+ if (GetCliGlobals()->grabMemoryQuotaIfAvailable(quotaIncreaseMB))
{
quota_ += (quotaIncreaseMB * ONE_MEGABYTE);
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/ExStats.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExStats.h b/core/sql/executor/ExStats.h
index f2128f7..2b1d255 100644
--- a/core/sql/executor/ExStats.h
+++ b/core/sql/executor/ExStats.h
@@ -1194,6 +1194,8 @@ public:
bmoHeapAlloc_ = (Int32)(heap->getTotalSize() >> 10);
bmoHeapUsage_ = (Int32)(heap->getAllocSize() >> 10);
bmoHeapWM_ = (Int32)(heap->getHighWaterMark() >> 10);
+ if (bmoHeapAlloc_ > bmoHeapWM_)
+ bmoHeapWM_ = bmoHeapAlloc_;
}
inline void setScratchOverflowMode(Int16 overflowMode)
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/cluster.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/cluster.cpp b/core/sql/executor/cluster.cpp
index 8e8f1e8..00492bb 100644
--- a/core/sql/executor/cluster.cpp
+++ b/core/sql/executor/cluster.cpp
@@ -503,7 +503,7 @@ void ClusterDB::yieldAllMemoryQuota()
{
if ( memoryQuotaMB_ == 0 || memoryQuotaMB_ <= minMemoryQuotaMB_ ) return;
- stmtGlobals_->yieldMemoryQuota( memoryQuotaMB_ - minMemoryQuotaMB_ );
+ GetCliGlobals()->yieldMemoryQuota( memoryQuotaMB_ - minMemoryQuotaMB_ );
if ( doLog_ ) { // LOG -- to show that memory was yielded
char msg[256];
@@ -511,7 +511,7 @@ void ClusterDB::yieldAllMemoryQuota()
"YIELDED ALL MEMORY ALLOWED: %u MB (%u). Unused pool %u MB",
memoryQuotaMB_-minMemoryQuotaMB_,
0, // NA_64BIT, use instance id later
- stmtGlobals_->unusedMemoryQuota() );
+ GetCliGlobals()->unusedMemoryQuota() );
// log an EMS event and continue
SQLMXLoggingArea::logExecRtInfo(NULL, 0, msg, explainNodeId_);
}
@@ -535,7 +535,7 @@ void ClusterDB::YieldQuota(UInt32 memNeeded)
// if there is no memory to yield - then return
if ( memToYieldMB <= 1 ) return; // 1 MB - to avoid thrashing
- stmtGlobals_->yieldMemoryQuota( memToYieldMB ); // Now yield
+ GetCliGlobals()->yieldMemoryQuota( memToYieldMB ); // Now yield
if ( doLog_ ) { // LOG -- to show that memory was yielded
char msg[256], msg1[64];
@@ -547,7 +547,7 @@ void ClusterDB::YieldQuota(UInt32 memNeeded)
hashOperator_ == HASH_GROUP_BY ? "HGB" :
hashOperator_ == SEQUENCE_OLAP ? "OLAP" : "HJ",
memToYieldMB, id, msg1, memNeededMB,
- stmtGlobals_->unusedMemoryQuota());
+ GetCliGlobals()->unusedMemoryQuota());
// log an EMS event and continue
SQLMXLoggingArea::logExecRtInfo(NULL, 0, msg, explainNodeId_);
@@ -628,7 +628,7 @@ void ClusterDB::yieldUnusedMemoryQuota(Cluster * theOFList,
// if there is no memory to yield - then return
if ( memToYieldMB <= 1 ) return; // 1 MB - to avoid thrashing
- stmtGlobals_->yieldMemoryQuota( memToYieldMB ); // Now yield
+ GetCliGlobals()->yieldMemoryQuota( memToYieldMB ); // Now yield
if ( doLog_ ) { // LOG -- to show that memory was yielded
char msg[256], msg1[64];
@@ -639,7 +639,7 @@ void ClusterDB::yieldUnusedMemoryQuota(Cluster * theOFList,
extraBuffers == 1 ? "HJ" : "HGB", memToYieldMB,
0, // NA_64BIT, use instance id later
msg1, memNeededMB,
- stmtGlobals_->unusedMemoryQuota());
+ GetCliGlobals()->unusedMemoryQuota());
// log an EMS event and continue
SQLMXLoggingArea::logExecRtInfo(NULL, 0, msg, explainNodeId_);
@@ -709,7 +709,7 @@ NABoolean ClusterDB::enoughMemory(ULng32 reqSize, NABoolean checkCompilerHints)
}
// Try to increase the memory quota (from the global "pool") to meet need
- if ( stmtGlobals_->grabMemoryQuotaIfAvailable(memNeededMB) ) {
+ if ( GetCliGlobals()->grabMemoryQuotaIfAvailable(memNeededMB) ) {
memoryQuotaMB_ += memNeededMB ; // got it
@@ -723,7 +723,7 @@ NABoolean ClusterDB::enoughMemory(ULng32 reqSize, NABoolean checkCompilerHints)
"GRABBED %u MB (%u). Memory used %u, now allowed %u MB, request size %u, unused pool %u",
memNeededMB, 0, // NA_64BIT, use instance id later
memoryUsed_,
- memoryQuotaMB_, reqSize,stmtGlobals_->unusedMemoryQuota() );
+ memoryQuotaMB_, reqSize,GetCliGlobals()->unusedMemoryQuota() );
// log an EMS event and continue
SQLMXLoggingArea::logExecRtInfo(NULL, 0, msg, explainNodeId_);
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/ex_frag_rt.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_frag_rt.cpp b/core/sql/executor/ex_frag_rt.cpp
index f468fd6..5da8ecb 100644
--- a/core/sql/executor/ex_frag_rt.cpp
+++ b/core/sql/executor/ex_frag_rt.cpp
@@ -245,12 +245,8 @@ void ExRtFragTable::setInactiveState()
// multi fragment esp - begin
static NABoolean sv_esp_multi_fragment = TRUE;
static UInt8 sv_esp_num_fragments = MAX_NUM_FRAGMENTS_PER_ESP;
-static UInt16 sv_esp_multi_fragment_vm = 4000;
-static NABoolean sv_esp_fragment_quotas = TRUE;
static char *sv_envvar_esp_multi_fragment = 0;
static char *sv_envvar_esp_num_fragments = 0;
-static char *sv_envvar_esp_multi_fragment_vm = 0;
-static char *sv_envvar_esp_fragment_quotas = 0;
static
void
@@ -264,18 +260,9 @@ getAssignedEspEnvVar()
sv_envvar_esp_multi_fragment = getenv("ESP_MULTI_FRAGMENTS");
sv_envvar_esp_num_fragments = getenv("ESP_NUM_FRAGMENTS");
- sv_envvar_esp_multi_fragment_vm = getenv("ESP_MULTI_FRAGMENT_QUOTA_VM");
- sv_envvar_esp_fragment_quotas = getenv("ESP_MULTI_FRAGMENT_QUOTAS");
lv_checked = true;
Int32 lv_i;
- if (sv_envvar_esp_fragment_quotas) {
- lv_i = atoi(sv_envvar_esp_fragment_quotas);
- if (lv_i == 0)
- sv_esp_fragment_quotas = FALSE;
- else
- sv_esp_fragment_quotas = TRUE;
- }
if (sv_envvar_esp_multi_fragment) {
lv_i = atoi(sv_envvar_esp_multi_fragment);
if (lv_i == 0)
@@ -283,21 +270,13 @@ getAssignedEspEnvVar()
else
sv_esp_multi_fragment = TRUE;
}
- if (sv_esp_fragment_quotas == TRUE)
- sv_esp_num_fragments = MAX_NUM_FRAGMENTS_PER_ESP;
+ sv_esp_num_fragments = 6;
if (sv_envvar_esp_num_fragments) {
lv_i = atoi(sv_envvar_esp_num_fragments);
if (lv_i > 0 && lv_i <= MAX_NUM_FRAGMENTS_PER_ESP) {
sv_esp_num_fragments = (UInt8)lv_i;
}
}
- if (sv_envvar_esp_multi_fragment_vm) {
- lv_i = atoi(sv_envvar_esp_multi_fragment_vm);
- if (lv_i >= 1500 && lv_i <=4000) {
- sv_esp_multi_fragment_vm = (UInt16)lv_i;
- }
- }
-
return;
}
// multi fragment esp - end
@@ -342,12 +321,8 @@ void ExRtFragTable::assignEsps(NABoolean /*checkResourceGovernor*/,
if (!sv_envvar_esp_multi_fragment)
sv_esp_multi_fragment = fragDir_->espMultiFragments();
- if (!sv_envvar_esp_fragment_quotas)
- sv_esp_fragment_quotas = fragDir_->espFragmentQuotas();
if (!sv_envvar_esp_num_fragments)
sv_esp_num_fragments = fragDir_->espNumFragments();
- if (!sv_envvar_esp_multi_fragment_vm)
- sv_esp_multi_fragment_vm = fragDir_->espMultiFragmentVm();
// de-coupling ESP with database uid if set
const char *esp_with_uid = getenv("ESP_WITH_USERID");
@@ -383,12 +358,7 @@ void ExRtFragTable::assignEsps(NABoolean /*checkResourceGovernor*/,
AssignEspArrays assignEspArrays((NAHeap *)heap, fragEntry.numEsps_);
Lng32 espLevel = fragDir_->getEspLevel(i);
NABoolean soloFragment = fragDir_->soloFrag(i);
- UInt16 fragmentMemoryQuota = fragDir_->getFragmentMemoryQuota(i);
NABoolean containsBMOs = fragDir_->containsBMOs(i);
- if (fragmentMemoryQuota == 0 && containsBMOs)
- fragmentMemoryQuota = sv_esp_multi_fragment_vm - 400;
- if (sv_esp_fragment_quotas == 0)
- fragmentMemoryQuota = 0; // sv_esp_num_fragments will apply
entryNumber = launchesStarted = 0;
for (Lng32 e = 0; e < fragEntry.numEsps_ && state_ != ERROR; e++)
@@ -401,7 +371,7 @@ void ExRtFragTable::assignEsps(NABoolean /*checkResourceGovernor*/,
assignEspArrays.instance_[e]->clusterName_ = nodeMap->getClusterName(e);
assignEspArrays.instance_[e]->cpuNum_ = cpuNum;
- assignEspArrays.instance_[e]->memoryQuota_ = fragmentMemoryQuota;
+ assignEspArrays.instance_[e]->memoryQuota_ = 0;
assignEspArrays.instance_[e]->state_ = ESP_ASSIGNED;
assignEspArrays.instance_[e]->fragmentHandle_ = NullFragInstanceHandle;
assignEspArrays.instance_[e]->numControlMessages_ = 0;
@@ -497,7 +467,7 @@ void ExRtFragTable::assignEsps(NABoolean /*checkResourceGovernor*/,
}
}
// for multi fragment esp - begin
- if (sv_esp_multi_fragment || sv_esp_fragment_quotas) {
+ if (sv_esp_multi_fragment) {
alreadyAssignedEsps.clear();
}
// for multi fragment esp - end
@@ -598,7 +568,7 @@ void ExRtFragTable::assignEsps(NABoolean /*checkResourceGovernor*/,
while (glob_->getIpcEnvironment()->getNumOpensInProgress() > 0)
glob_->getIpcEnvironment()->getAllConnections()->waitOnAll(IpcInfiniteTimeout);
// multi fragment esp - begin
- if (sv_esp_multi_fragment || sv_esp_fragment_quotas)
+ if (sv_esp_multi_fragment)
{
alreadyAssignedEsps.clear();
}
@@ -1557,7 +1527,7 @@ void ExRtFragTable::releaseEsps(NABoolean closeAllOpens)
// multi fragment esp - begin
if (fragInst->usedEsp_) {
if ((releasedEsps.insert(fragInst->usedEsp_) == FALSE) &&
- (sv_esp_multi_fragment || sv_esp_fragment_quotas)) {
+ (sv_esp_multi_fragment)) {
// decrement the usageCount_ of fragInst->usedEsp_
glob_->getEspManager( )->releaseEsp(fragInst->usedEsp_, glob_->verifyESP(), fragInst->usedEsp_->inUse());
}
@@ -3113,7 +3083,7 @@ ExEspDbEntry *ExEspManager::getEspFromCache(LIST(ExEspDbEntry *) &alreadyAssigne
ExEspDbEntry *e = espList->usedEntry(i);
- if ((e->inUse_) && (e->soloFragment_ || soloFragment || !(sv_esp_multi_fragment || sv_esp_fragment_quotas) || e->statement_ != statement))
+ if ((e->inUse_) && (e->soloFragment_ || soloFragment || !(sv_esp_multi_fragment) || e->statement_ != statement))
continue;
// don't reuse a broken ESP
@@ -3197,8 +3167,7 @@ ExEspDbEntry *ExEspManager::getEspFromCache(LIST(ExEspDbEntry *) &alreadyAssigne
// we have found a free esp for reuse
if ((2 * e->usageCount_ + 1 <= nowaitDepth) &&
- (e->usageCount_ < sv_esp_num_fragments) &&
- (e->totalMemoryQuota_ + 100 + memoryQuota < sv_esp_multi_fragment_vm))
+ (e->usageCount_ < sv_esp_num_fragments))
{
e->usageCount_++; // multi fragment esp
e->statement_ = statement;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/ex_mj.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_mj.cpp b/core/sql/executor/ex_mj.cpp
index 55a589b..d22ebcc 100644
--- a/core/sql/executor/ex_mj.cpp
+++ b/core/sql/executor/ex_mj.cpp
@@ -206,7 +206,7 @@ ex_mj_tcb::ex_mj_tcb(const ex_mj_tdb & mj_tdb,
if (assumedMaxMB < quotaMB)
{
- stmtGlobals->yieldMemoryQuota(quotaMB - assumedMaxMB);
+ GetCliGlobals()->yieldMemoryQuota(quotaMB - assumedMaxMB);
quotaMB = assumedMaxMB;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/ex_sort.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_sort.cpp b/core/sql/executor/ex_sort.cpp
index c92a38e..4ef5bc2 100644
--- a/core/sql/executor/ex_sort.cpp
+++ b/core/sql/executor/ex_sort.cpp
@@ -363,12 +363,15 @@ ExSortTcb::ExSortTcb(const ExSortTdb & sort_tdb,
sortType_.useIterQSForRunGeneration_ = 1;
break;
}
+
+ sortHeap_ = new(getHeap()) NAHeap("Sort Heap", (NAHeap *)getHeap(), 204800);
sortUtil_ = new(sortHeap_) SortUtil(sort_tdb.getExplainNodeId());
sortDiag_ = NULL;
sortCfg_ = new(sortHeap_) SortUtilConfig(sortHeap_);
+ sortCfg_ = new(sortHeap_) SortUtilConfig(sortHeap_);
sortCfg_->setSortType(sortType_);
sortCfg_->setScratchThreshold(st->sortOptions_->scratchFreeSpaceThresholdPct());
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/executor/ex_split_bottom.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_split_bottom.cpp b/core/sql/executor/ex_split_bottom.cpp
index 6dd35aa..2a7e3cc 100644
--- a/core/sql/executor/ex_split_bottom.cpp
+++ b/core/sql/executor/ex_split_bottom.cpp
@@ -736,7 +736,7 @@ ExWorkProcRetcode ex_split_bottom_tcb::work()
setWorkState(WORK_ON_REQUEST);
glob_->clearAllActivatedSendTopTcbs();
- glob_->resetMemoryQuota();
+ GetCliGlobals()->resetMemoryQuota();
glob_->incExecutionCount();
} // if (okToPush)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenExplain.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExplain.cpp b/core/sql/generator/GenExplain.cpp
index 738d95e..0177dc3 100644
--- a/core/sql/generator/GenExplain.cpp
+++ b/core/sql/generator/GenExplain.cpp
@@ -320,10 +320,10 @@ RelExpr::addExplainInfo(ComTdb * tdb,
NAString fragdescr;
NADefaults &defs = ActiveSchemaDB()->getDefaults();
- double mlimit = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU);
+ double mlimit = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE);
double quotaPerBMO = defs.getAsDouble(EXE_MEM_LIMIT_PER_BMO_IN_MB);
- const char * memory_quota_str = "memory_quota_per_esp: %d MB " ;
+ const char * memory_quota_str = "memory_quota_per_instance: %d MB " ;
if ( generator->getEspLevel() == 0 )
memory_quota_str = "memory_quota: %d MB " ;
@@ -333,12 +333,12 @@ RelExpr::addExplainInfo(ComTdb * tdb,
if ( quotaPerBMO > 0 || mlimit == 0 )
break;
- double BMOsMemoryLimit =
- generator->getBMOsMemoryLimitPerCPU().value() / (1024 * 1024);
+ double BMOsMemory =
+ generator->getTotalBMOsMemoryPerCPU().value() / (1024 * 1024);
double nBMOsTotalMemory =
(generator->getTotalNBMOsMemoryPerCPU()).value() / (1024 * 1024);
- snprintf(buf, 120, "memory_limit_per_cpu: %.2f(total), %.2f(BMOs), %.2f(nBMOs) ",
- mlimit, BMOsMemoryLimit, nBMOsTotalMemory);
+ snprintf(buf, 120, "est_memory_per_node: %.2f(Limit), %.2f(BMOs), %.2f(nBMOs) MB ",
+ mlimit, BMOsMemory, nBMOsTotalMemory);
fragdescr += buf;
}
break;
@@ -438,13 +438,13 @@ RelExpr::addExplainInfo(ComTdb * tdb,
explainTuple->setDescription(rowsetNAR);
}
-
if ( mlimit > 0 && quotaPerBMO == 0 )
{
// Report estimate memory usage per CPU (both BMOs and nBMOs)
NABoolean reportMemoryEst = TRUE;
- switch (tdb->getNodeType()) {
+ ComTdb::ex_node_type nodeType = tdb->getNodeType();
+ switch (nodeType) {
case ComTdb::ex_HASH_GRBY:
reportMemoryEst = ((ComTdbHashGrby*)tdb)->memoryQuotaMB() > 0;
break;
@@ -454,12 +454,21 @@ RelExpr::addExplainInfo(ComTdb * tdb,
default:
break;
}
-
if ( reportMemoryEst == TRUE ) {
- double memUsage = getEstimatedRunTimeMemoryUsage(TRUE).value()/1024;
- if ( memUsage > 0 ) {
- sprintf(buf, "est_memory_per_cpu: %.3f KB ", memUsage);
- explainTuple->setDescription(buf);
+ if (nodeType == ComTdb::ex_HASH_GRBY || nodeType == ComTdb::ex_HASHJ
+ || nodeType == ComTdb::ex_SORT) {
+ double memUsage = getEstimatedRunTimeMemoryUsage(FALSE).value()/1024;
+ if ( memUsage > 0 ) {
+ sprintf(buf, "est_memory_per_instance: %.3f KB ", memUsage);
+ explainTuple->setDescription(buf);
+ }
+ }
+ else {
+ double memUsage = getEstimatedRunTimeMemoryUsage(TRUE).value()/1024;
+ if ( memUsage > 0 ) {
+ sprintf(buf, "est_memory_per_node: %.3f KB ", memUsage);
+ explainTuple->setDescription(buf);
+ }
}
}
} else {
@@ -1423,7 +1432,7 @@ RelRoot::addSpecificExplainInfo(ExplainTupleMaster *explainTuple,
ComTdbRoot *rootTdb = (ComTdbRoot *)tdb;
NADefaults &defs = ActiveSchemaDB()->getDefaults();
- Lng32 mlimit = defs.getAsLong(EXE_MEMORY_LIMIT_PER_CPU);
+ Lng32 mlimit = defs.getAsLong(BMO_MEMORY_LIMIT_PER_NODE);
if (mlimit == 0 && rootTdb->getQueryCostInfo())
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 0505432..88a4194 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -2155,34 +2155,10 @@ RelExpr * RelRoot::preCodeGen(Generator * generator,
// Compute the total available memory quota for BMOs
NADefaults &defs = ActiveSchemaDB()->getDefaults();
- // total per CPU
- double m = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) * (1024*1024);
-
- // total memory usage for all nBMOs
- double m1 = (generator->getTotalNBMOsMemoryPerCPU()).value();
-
- // total memory limit for all BMOs
- double m2 = m-m1;
-
- double ratio =
- defs.getAsDouble(EXE_MEMORY_LIMIT_NONBMOS_PERCENT) / 100;
-
- if ( m2 < 0 ) {
- // EXE_MEMORY_LIMIT_PER_CPU is set too small, set the total
- // memory limit for BMOs to zero. When the memory quota for
- // each BMO is computed (via method RelExpr::computeMemoryQuota()),
- // the lower-bound for each BMO will kick in and each will receive
- // a quota equal to the lower-bound value.
- m2 = 0;
- } else {
-
- // nBMOs use more memory than the portion, adjust m2 to
- // that of (1-ratio)*m
- if (m1 > m*ratio )
- m2 = m*(1-ratio);
- }
+ // total per node
+ double m = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) * (1024*1024);
- generator->setBMOsMemoryLimitPerCPU(m2);
+ generator->setBMOsMemoryLimitPerCPU(m);
}
@@ -3758,7 +3734,7 @@ RelExpr * HashJoin::preCodeGen(Generator * generator,
// Count this BMO and add its needed memory to the total needed
generator->incrNumBMOs();
- if ((ActiveSchemaDB()->getDefaults()).getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ if ((ActiveSchemaDB()->getDefaults()).getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrBMOsMemory(getEstimatedRunTimeMemoryUsage(TRUE));
@@ -6008,7 +5984,7 @@ RelExpr * GroupByAgg::preCodeGen(Generator * generator,
// Count this BMO and add its needed memory to the total needed
generator->incrNumBMOs();
- if ((ActiveSchemaDB()->getDefaults()).getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ if ((ActiveSchemaDB()->getDefaults()).getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrBMOsMemory(getEstimatedRunTimeMemoryUsage(TRUE));
}
@@ -6651,7 +6627,7 @@ RelExpr * Sort::preCodeGen(Generator * generator,
if (CmpCommon::getDefault(SORT_MEMORY_QUOTA_SYSTEM) != DF_OFF) {
generator->incrNumBMOs();
- if ((ActiveSchemaDB()->getDefaults()).getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ if ((ActiveSchemaDB()->getDefaults()).getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrBMOsMemory(getEstimatedRunTimeMemoryUsage(TRUE));
}
}
@@ -6753,7 +6729,7 @@ RelExpr *ProbeCache::preCodeGen(Generator * generator,
generator->incrNumBMOs();
*/
- if ((ActiveSchemaDB()->getDefaults()).getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ if ((ActiveSchemaDB()->getDefaults()).getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrNBMOsMemoryPerCPU(getEstimatedRunTimeMemoryUsage(TRUE));
markAsPreCodeGenned();
@@ -7258,7 +7234,7 @@ RelExpr * Exchange::preCodeGen(Generator * generator,
} // isEspExchange() && !eliminateThisExchange
- if ((ActiveSchemaDB()->getDefaults()).getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ if ((ActiveSchemaDB()->getDefaults()).getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrNBMOsMemoryPerCPU(getEstimatedRunTimeMemoryUsage(TRUE));
return result;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenProbeCache.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenProbeCache.cpp b/core/sql/generator/GenProbeCache.cpp
index 9228e10..63035e9 100644
--- a/core/sql/generator/GenProbeCache.cpp
+++ b/core/sql/generator/GenProbeCache.cpp
@@ -450,7 +450,7 @@ short ProbeCache::codeGen(Generator *generator)
return 0;
}
-CostScalar ProbeCache::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar ProbeCache::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
const Lng32 probeSize =
getGroupAttr()->getCharacteristicInputs().getRowLength();
@@ -470,18 +470,25 @@ CostScalar ProbeCache::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
}
const double outputBufferSize = resultSize * numBufferPoolEntries; // in bytes
- // totalMemory is perCPU at this point of time.
+ // totalMemory is perNode at this point of time.
double totalMemory = cacheSize + outputBufferSize;
- if ( perCPU == FALSE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
-
- if (phyProp != NULL)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
- totalMemory *= partFunc->getCountOfPartitions();
- }
+ Lng32 numOfStreams = 1;
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ if (phyProp)
+ {
+ PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
+ numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
+ totalMemory *= numOfStreams;
}
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalMemory /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numOfStreams);
+ else
+ totalMemory /= numOfStreams;
double memoryLimitPerCpu =
ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_FOR_PROBE_CACHE_IN_MB) * 1024 * 1024;
@@ -494,6 +501,9 @@ double ProbeCache::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
// tdb is ignored for ProbeCache because this operator
// does not participate in the BMO quota system.
- return getEstimatedRunTimeMemoryUsage(FALSE).value();
+ Lng32 numOfStreams = 1;
+ CostScalar totalMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalMemory = totalMemory * numOfStreams ;
+ return totalMemory.value();
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenRelEnforcer.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelEnforcer.cpp b/core/sql/generator/GenRelEnforcer.cpp
index 6067711..52ff9ed 100644
--- a/core/sql/generator/GenRelEnforcer.cpp
+++ b/core/sql/generator/GenRelEnforcer.cpp
@@ -1328,7 +1328,7 @@ ExpTupleDesc::TupleDataFormat Exchange::determineInternalFormat( const ValueIdLi
considerBufferDefrag);
}
-CostScalar Exchange::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar Exchange::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
//////////////////////////////////////
// compute the buffer length (for both
@@ -1393,20 +1393,26 @@ CostScalar Exchange::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
// split top.
}
- if ( perCPU == FALSE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
- if (phyProp != NULL) {
- memoryRequired = numTopEsps * memoryRequired;
- }
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ if (phyProp != NULL) {
+ memoryRequired = numTopEsps * memoryRequired;
}
-
+ if (numStreams != NULL)
+ *numStreams = numTopEsps;
+ if ( perNode == TRUE )
+ memoryRequired /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numTopEsps);
+ else
+ memoryRequired /= numTopEsps;
return memoryRequired;
}
double Exchange::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
- return (getEstimatedRunTimeMemoryUsage(FALSE)).value();
+ Lng32 numOfStreams = 1;
+ CostScalar totalMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalMemory = totalMemory * numOfStreams ;
+ return totalMemory.value();
}
bool Exchange::thisExchangeCanUseSM(BindWA *bindWA) const
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenRelGrby.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelGrby.cpp b/core/sql/generator/GenRelGrby.cpp
index 69aeab4..b54777c 100644
--- a/core/sql/generator/GenRelGrby.cpp
+++ b/core/sql/generator/GenRelGrby.cpp
@@ -1474,6 +1474,7 @@ short HashGroupBy::codeGen(Generator * generator) {
hashGrbyTdb->setScratchIOVectorSize((Int16)getDefault(SCRATCH_IO_VECTOR_SIZE_HASH));
double memQuota = 0;
+ Lng32 numStreams;
if(isPartialGroupBy) {
// The Quota system does not apply to Partial GroupBy
@@ -1504,25 +1505,30 @@ short HashGroupBy::codeGen(Generator * generator) {
// Apply quota system if either one the following two is true:
// 1. the memory limit feature is turned off and more than one BMOs
// 2. the memory limit feature is turned on
- NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0;
+ NABoolean mlimitPerCPU = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0;
if ( mlimitPerCPU || numBMOsInFrag > 1 ||
(numBMOsInFrag == 1 && CmpCommon::getDefault(EXE_SINGLE_BMO_QUOTA) == DF_ON)) {
+ double bmoMemoryUsage = getEstimatedRunTimeMemoryUsage(TRUE, &numStreams).value();
memQuota =
computeMemoryQuota(generator->getEspLevel() == 0,
mlimitPerCPU,
generator->getBMOsMemoryLimitPerCPU().value(),
- generator->getTotalNumBMOsPerCPU(),
+ //generator->getTotalNumBMOsPerCPU(),
+ generator->getTotalNumBMOs(),
generator->getTotalBMOsMemoryPerCPU().value(),
numBMOsInFrag,
- generator->getFragmentDir()->getBMOsMemoryUsage()
+ bmoMemoryUsage,
+ numStreams
);
- Lng32 hjGyMemoryLowbound =
- defs.getAsLong(EXE_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY);
+ Lng32 hjGyMemoryLowbound = defs.getAsLong(BMO_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY);
+ Lng32 memoryUpperbound = defs.getAsLong(BMO_MEMORY_LIMIT_UPPER_BOUND);
if ( memQuota < hjGyMemoryLowbound )
memQuota = hjGyMemoryLowbound;
+ else if (memQuota > memoryUpperbound)
+ memQuota = memoryUpperbound;
hashGrbyTdb->setMemoryQuotaMB( UInt16(memQuota) );
}
@@ -1626,7 +1632,7 @@ ExpTupleDesc::TupleDataFormat HashGroupBy::determineInternalFormat( const ValueI
}
-CostScalar HashGroupBy::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar HashGroupBy::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
GroupAttributes * childGroupAttr = child(0).getGroupAttr();
const CostScalar childRecordSize = childGroupAttr->getCharacteristicOutputs().getRowLength();
@@ -1642,52 +1648,29 @@ CostScalar HashGroupBy::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
CostScalar totalHashTableMemory =
childRowCount * (childRecordSize + memOverheadPerRecord);
- if ( perCPU == TRUE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
- if (phyProp)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
-
- // totalHashTableMemory is per CPU at this point of time.
- totalHashTableMemory /= partFunc->getCountOfPartitions();
- }
+ Lng32 numOfStreams = 1;
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ if (phyProp)
+ {
+ PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
+ numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
}
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalHashTableMemory /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numOfStreams);
+ else
+ totalHashTableMemory /= numOfStreams;
return totalHashTableMemory;
}
double HashGroupBy::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
- CostScalar totalHashTableMemory = getEstimatedRunTimeMemoryUsage(FALSE);
-
- double memoryLimitPerCpu;
- ULng32 memoryQuotaInMB = ((ComTdbHashGrby *)tdb)->memoryQuotaMB();
- if (memoryQuotaInMB)
- memoryLimitPerCpu = memoryQuotaInMB * 1024 * 1024 ;
- else if ( isNotAPartialGroupBy() == FALSE)
- {
- memoryLimitPerCpu =
- ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_FOR_PARTIALHGB_IN_MB) * 1024 * 1024;
- }
- else
- {
- memoryLimitPerCpu =
- ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_AVAILABLE_IN_MB) * 1024 * 1024 ;
- }
-
- const PhysicalProperty* const phyProp = getPhysicalProperty();
Lng32 numOfStreams = 1;
- if (phyProp)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
- numOfStreams = partFunc->getCountOfPartitions();
- }
-
- CostScalar memoryPerCpu = totalHashTableMemory/numOfStreams ;
- if ( memoryPerCpu > memoryLimitPerCpu )
- {
- memoryPerCpu = memoryLimitPerCpu;
- }
- totalHashTableMemory = memoryPerCpu * numOfStreams ;
+ CostScalar totalHashTableMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalHashTableMemory *= numOfStreams ;
return totalHashTableMemory.value();
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenRelJoin.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelJoin.cpp b/core/sql/generator/GenRelJoin.cpp
index b38b44c..5c3617b 100644
--- a/core/sql/generator/GenRelJoin.cpp
+++ b/core/sql/generator/GenRelJoin.cpp
@@ -1784,7 +1784,7 @@ short HashJoin::codeGen(Generator * generator) {
UInt16 numBMOsInFrag = (UInt16)generator->getFragmentDir()->getNumBMOs();
double memQuota = 0;
-
+ Lng32 numStreams;
if (mmu != 0) {
memQuota = mmu;
hashj_tdb->setMemoryQuotaMB(mmu);
@@ -1792,25 +1792,29 @@ short HashJoin::codeGen(Generator * generator) {
// Apply quota system if either one the following two is true:
// 1. the memory limit feature is turned off and more than one BMOs
// 2. the memory limit feature is turned on
- NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0;
-
+ NABoolean mlimitPerCPU = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0;
+
if ( mlimitPerCPU || numBMOsInFrag > 1 ||
(numBMOsInFrag == 1 && CmpCommon::getDefault(EXE_SINGLE_BMO_QUOTA) == DF_ON)) {
-
+ double bmoMemoryUsage = getEstimatedRunTimeMemoryUsage(TRUE, &numStreams).value();
memQuota =
computeMemoryQuota(generator->getEspLevel() == 0,
mlimitPerCPU,
generator->getBMOsMemoryLimitPerCPU().value(),
- generator->getTotalNumBMOsPerCPU(),
+ generator->getTotalNumBMOs(),
generator->getTotalBMOsMemoryPerCPU().value(),
numBMOsInFrag,
- generator->getFragmentDir()->getBMOsMemoryUsage()
+ bmoMemoryUsage,
+ numStreams
);
- Lng32 hjMemoryLowbound = defs.getAsLong(EXE_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN);
+ Lng32 hjMemoryLowbound = defs.getAsLong(BMO_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN);
+ Lng32 memoryUpperbound = defs.getAsLong(BMO_MEMORY_LIMIT_UPPER_BOUND);
if ( memQuota < hjMemoryLowbound )
memQuota = hjMemoryLowbound;
+ else if (memQuota > memoryUpperbound)
+ memQuota = memoryUpperbound;
hashj_tdb->setMemoryQuotaMB( UInt16(memQuota) );
}
@@ -1826,10 +1830,6 @@ short HashJoin::codeGen(Generator * generator) {
double hjMemEst = getEstimatedRunTimeMemoryUsage(hashj_tdb);
generator->addToTotalEstimatedMemory(hjMemEst);
- generator->addToTotalOverflowMemory(
- getEstimatedRunTimeOverflowSize(memQuota)
- );
-
if ( generator->getRightSideOfFlow() )
hashj_tdb->setPossibleMultipleCalls(TRUE);
@@ -2064,7 +2064,7 @@ ExpTupleDesc::TupleDataFormat HashJoin::determineInternalFormat( const ValueIdLi
}
-CostScalar HashJoin::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar HashJoin::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
GroupAttributes * childGroupAttr = child(1).getGroupAttr();
const CostScalar childRecordSize = childGroupAttr->getCharacteristicOutputs().getRowLength();
@@ -2087,47 +2087,25 @@ CostScalar HashJoin::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
{
partFunc = phyProp -> getPartitioningFunction() ;
numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
if ( partFunc -> isAReplicationPartitioningFunction() == TRUE )
- {
totalHashTableMemory *= numOfStreams;
- }
}
-
- if ( perCPU == TRUE ) {
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalHashTableMemory /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numOfStreams);
+ else
totalHashTableMemory /= numOfStreams;
- }
-
return totalHashTableMemory;
}
double HashJoin::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
- CostScalar totalHashTableMemory = getEstimatedRunTimeMemoryUsage(FALSE);
-
- double memoryLimitPerCpu;
- ULng32 memoryQuotaInMB = ((ComTdbHashj *)tdb)->memoryQuotaMB();
- if (memoryQuotaInMB)
- memoryLimitPerCpu = memoryQuotaInMB * 1024 * 1024 ;
- else
- {
- memoryLimitPerCpu =
- ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_AVAILABLE_IN_MB) * 1024 * 1024 ;
- }
-
Lng32 numOfStreams = 1;
- const PhysicalProperty* const phyProp = getPhysicalProperty() ;
- if (phyProp)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
- numOfStreams = partFunc->getCountOfPartitions();
- }
-
- CostScalar memoryPerCpu = totalHashTableMemory/numOfStreams ;
- if ( memoryPerCpu > memoryLimitPerCpu )
- {
- memoryPerCpu = memoryLimitPerCpu;
- }
- totalHashTableMemory = memoryPerCpu * numOfStreams ;
+ CostScalar totalHashTableMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalHashTableMemory *= numOfStreams ;
return totalHashTableMemory.value();
}
@@ -3097,6 +3075,7 @@ short MergeJoin::codeGen(Generator * generator)
double BMOsMemoryLimit = 0;
UInt16 quotaMB = 0;
+ Lng32 numStreams;
if ( CmpCommon::getDefaultLong(MJ_BMO_QUOTA_PERCENT) != 0)
{
@@ -3104,28 +3083,34 @@ short MergeJoin::codeGen(Generator * generator)
// 1. the memory limit feature is turned off and more than one BMOs
// 2. the memory limit feature is turned on
NADefaults &defs = ActiveSchemaDB()->getDefaults();
- NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0;
+ NABoolean mlimitPerCPU = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0;
if ( mlimitPerCPU || numBMOsInFrag > 1 ||
(numBMOsInFrag == 1 && CmpCommon::getDefault(EXE_SINGLE_BMO_QUOTA) == DF_ON)) {
+ double bmoMemoryUsage = getEstimatedRunTimeMemoryUsage(TRUE, &numStreams).value();
quotaMB = (UInt16)
computeMemoryQuota(generator->getEspLevel() == 0,
mlimitPerCPU,
generator->getBMOsMemoryLimitPerCPU().value(),
- generator->getTotalNumBMOsPerCPU(),
+ // generator->getTotalNumBMOsPerCPU(),
+ generator->getTotalNumBMOs(),
generator->getTotalBMOsMemoryPerCPU().value(),
numBMOsInFrag,
- generator->getFragmentDir()->getBMOsMemoryUsage()
+ bmoMemoryUsage,
+ numStreams
);
Lng32 mjMemoryLowbound = defs.getAsLong(EXE_MEMORY_LIMIT_LOWER_BOUND_MERGEJOIN);
+ Lng32 memoryUpperbound = defs.getAsLong(BMO_MEMORY_LIMIT_UPPER_BOUND);
if ( quotaMB < mjMemoryLowbound )
quotaMB = (UInt16)mjMemoryLowbound;
+ else if (quotaMB > memoryUpperbound)
+ quotaMB = memoryUpperbound;
}
} else {
- Lng32 memoryMB = getExeMemoryAvailable(generator->getEspLevel() == 0, 0);
+ Lng32 memoryMB = getExeMemoryAvailable(generator->getEspLevel() == 0);
quotaMB = (UInt16)( (numBMOsInFrag > 1) ? (memoryMB/numBMOsInFrag) : 0 ) ;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenRelMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelMisc.cpp b/core/sql/generator/GenRelMisc.cpp
index c7ad623..98b29cc 100644
--- a/core/sql/generator/GenRelMisc.cpp
+++ b/core/sql/generator/GenRelMisc.cpp
@@ -2820,6 +2820,9 @@ short RelRoot::codeGen(Generator * generator)
if(generator->hiveAccess())
root_tdb->setHiveAccess(TRUE);
+ root_tdb->setBmoMemoryLimitPerNode(ActiveSchemaDB()->getDefaults().getAsDouble(BMO_MEMORY_LIMIT_PER_NODE));
+ root_tdb->setEstBmoMemoryPerNode(generator->getTotalBMOsMemoryPerCPU().value());
+
Int32 numSikEntries = securityKeySet_.entries();
if (numSikEntries > 0)
{
@@ -2937,7 +2940,7 @@ short RelRoot::codeGen(Generator * generator)
// now set the values of the previously allocated directory entry
- NABoolean mlimitPerCPU = CmpCommon::getDefaultLong(EXE_MEMORY_LIMIT_PER_CPU) > 0;
+ NABoolean mlimitPerCPU = CmpCommon::getDefaultLong(BMO_MEMORY_LIMIT_PER_NODE) > 0;
UInt16 BMOsMemoryUsage = 0;
if (mlimitPerCPU == TRUE)
BMOsMemoryUsage = (UInt16)compFragDir->getBMOsMemoryUsage(i);
@@ -3132,6 +3135,7 @@ short Sort::generateTdb(Generator * generator,
// The CQD EXE_MEM_LIMIT_PER_BMO_IN_MB has precedence over the mem quota sys
memoryQuotaMB = (UInt16)defs.getAsDouble(EXE_MEM_LIMIT_PER_BMO_IN_MB);
+ Lng32 numStreams;
if (memoryQuotaMB > 0) {
sort_options->memoryQuotaMB() = memoryQuotaMB;
@@ -3143,25 +3147,31 @@ short Sort::generateTdb(Generator * generator,
// 1. the memory limit feature is turned off and more than one BMOs
// 2. the memory limit feature is turned on
- NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0;
+ NABoolean mlimitPerCPU = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0;
if ( mlimitPerCPU || numBMOsInFrag > 1 ) {
+ double bmoMemoryUsage = getEstimatedRunTimeMemoryUsage(TRUE, &numStreams).value();
memoryQuotaMB = (short)
computeMemoryQuota(generator->getEspLevel() == 0,
mlimitPerCPU,
generator->getBMOsMemoryLimitPerCPU().value(),
- generator->getTotalNumBMOsPerCPU(),
+ //generator->getTotalNumBMOsPerCPU(),
+ generator->getTotalNumBMOs(),
generator->getTotalBMOsMemoryPerCPU().value(),
numBMOsInFrag,
- generator->getFragmentDir()->getBMOsMemoryUsage()
+ bmoMemoryUsage,
+ numStreams
);
- Lng32 sortMemoryLowbound = defs.getAsLong(EXE_MEMORY_LIMIT_LOWER_BOUND_SORT);
+ Lng32 sortMemoryLowbound = defs.getAsLong(BMO_MEMORY_LIMIT_LOWER_BOUND_SORT);
+ Lng32 memoryUpperbound = defs.getAsLong(BMO_MEMORY_LIMIT_UPPER_BOUND);
if ( memoryQuotaMB < sortMemoryLowbound )
memoryQuotaMB = (short)sortMemoryLowbound;
+ else if (memoryQuotaMB > memoryUpperbound)
+ memoryQuotaMB = memoryUpperbound;
}
}
}
@@ -3948,52 +3958,36 @@ double Sort::getEstimatedRunTimeOverflowSize(double memoryQuotaMB)
return 0;
}
-CostScalar Sort::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar Sort::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
GroupAttributes * childGroupAttr = child(0).getGroupAttr();
Lng32 childRecordSize =
childGroupAttr->getCharacteristicOutputs().getRowLength();
CostScalar totalMemory = getEstRowsUsed() * childRecordSize;
- if ( perCPU == TRUE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
- if (phyProp != NULL)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
- totalMemory /= partFunc->getCountOfPartitions();
- }
+ Lng32 numOfStreams = 1;
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ if (phyProp != NULL)
+ {
+ PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
+ numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
}
-
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalMemory /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numOfStreams);
+ else
+ totalMemory /= numOfStreams;
return totalMemory;
}
double Sort::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
- CostScalar totalMemory = getEstimatedRunTimeMemoryUsage(FALSE);
-
- const Int32 numBuffs = ActiveSchemaDB()->getDefaults().getAsLong(GEN_SORT_MAX_NUM_BUFFERS);
- const Int32 bufSize = ActiveSchemaDB()->getDefaults().getAsLong(GEN_SORT_MAX_BUFFER_SIZE);
- double memoryLimitPerCpu;
- short memoryQuotaInMB = ((ComTdbSort *)tdb)->getSortOptions()->memoryQuotaMB();
- if (memoryQuotaInMB)
- memoryLimitPerCpu = memoryQuotaInMB * 1024 * 1024 ;
- else
- memoryLimitPerCpu = numBuffs * bufSize ;
-
- const PhysicalProperty* const phyProp = getPhysicalProperty();
Lng32 numOfStreams = 1;
- if (phyProp != NULL)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
- numOfStreams = partFunc->getCountOfPartitions();
- }
-
- CostScalar memoryPerCpu = totalMemory/numOfStreams ;
- if ( memoryPerCpu > memoryLimitPerCpu )
- {
- memoryPerCpu = memoryLimitPerCpu;
- }
- totalMemory = memoryPerCpu * numOfStreams ;
+ CostScalar totalMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalMemory = totalMemory * numOfStreams ;
return totalMemory.value();
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/generator/GenRelSequence.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelSequence.cpp b/core/sql/generator/GenRelSequence.cpp
index 52eea4f..4522344 100644
--- a/core/sql/generator/GenRelSequence.cpp
+++ b/core/sql/generator/GenRelSequence.cpp
@@ -772,13 +772,12 @@ RelExpr * PhysSequence::preCodeGen(Generator * generator,
///addCheckPartitionChangeExpr(generator->wHeap());
transformOlapFunctions(generator->wHeap());
-
if ( getUnboundedFollowing() ) {
// Count this Seq as a BMO and add its needed memory to the total needed
generator->incrNumBMOs();
if ((ActiveSchemaDB()->getDefaults()).
- getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0)
+ getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0)
generator->incrBMOsMemory(getEstimatedRunTimeMemoryUsage(TRUE));
}
else
@@ -1121,24 +1120,28 @@ PhysSequence::codeGen(Generator *generator)
NADefaults &defs = ActiveSchemaDB()->getDefaults();
UInt16 mmu = (UInt16)(defs.getAsDouble(EXE_MEM_LIMIT_PER_BMO_IN_MB));
UInt16 numBMOsInFrag = (UInt16)generator->getFragmentDir()->getNumBMOs();
+ Lng32 numStreams;
if (mmu != 0)
sequenceTdb->setMemoryQuotaMB(mmu);
else {
// Apply quota system if either one the following two is true:
// 1. the memory limit feature is turned off and more than one BMOs
// 2. the memory limit feature is turned on
- NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0;
+ NABoolean mlimitPerCPU = defs.getAsDouble(BMO_MEMORY_LIMIT_PER_NODE) > 0;
if ( mlimitPerCPU || numBMOsInFrag > 1 ) {
+ double bmoMemoryUsage = getEstimatedRunTimeMemoryUsage(TRUE, &numStreams).value();
double memQuota =
computeMemoryQuota(generator->getEspLevel() == 0,
mlimitPerCPU,
generator->getBMOsMemoryLimitPerCPU().value(),
- generator->getTotalNumBMOsPerCPU(),
+ //generator->getTotalNumBMOsPerCPU(),
+ generator->getTotalNumBMOs(),
generator->getTotalBMOsMemoryPerCPU().value(),
numBMOsInFrag,
- generator->getFragmentDir()->getBMOsMemoryUsage()
+ bmoMemoryUsage,
+ numStreams
);
sequenceTdb->setMemoryQuotaMB( UInt16(memQuota) );
@@ -1286,7 +1289,7 @@ void PhysSequence::computeHistoryParams(Lng32 histRecLength,
}
-CostScalar PhysSequence::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
+CostScalar PhysSequence::getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams)
{
// input param is not used as this operator does not participate in the
// quota system.
@@ -1303,23 +1306,32 @@ CostScalar PhysSequence::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
// totalMemory is per CPU at this point of time.
double totalMemory = historyBufferSizeInBytes;
- if ( perCPU == FALSE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
- if (phyProp != NULL)
- {
- PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
-
- // totalMemory is for all CPUs at this point of time.
- totalMemory *= partFunc->getCountOfPartitions();
- }
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ Lng32 numOfStreams = 1;
+ if (phyProp != NULL)
+ {
+ PartitioningFunction * partFunc = phyProp -> getPartitioningFunction() ;
+ numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
+ // totalMemory is for all CPUs at this point of time.
+ totalMemory *= numOfStreams;
}
-
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalMemory /= MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numOfStreams);
+ else
+ totalMemory /= numOfStreams;
return totalMemory;
}
double PhysSequence::getEstimatedRunTimeMemoryUsage(ComTdb * tdb)
{
- return getEstimatedRunTimeMemoryUsage(FALSE).value();
+ Lng32 numOfStreams = 1;
+ CostScalar totalMemory = getEstimatedRunTimeMemoryUsage(FALSE, &numOfStreams);
+ totalMemory = totalMemory * numOfStreams ;
+ return totalMemory.value();
}
ExplainTuple*
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/optimizer/RelEnforcer.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelEnforcer.h b/core/sql/optimizer/RelEnforcer.h
index 2c4a14b..8fc705c 100644
--- a/core/sql/optimizer/RelEnforcer.h
+++ b/core/sql/optimizer/RelEnforcer.h
@@ -185,7 +185,7 @@ public:
virtual NABoolean isBigMemoryOperator(const PlanWorkSpace* pws,
const Lng32 planNumber);
- virtual CostScalar getEstimatedRunTimeMemoryUsage(NABoolean perCPU);
+ virtual CostScalar getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams = NULL);
virtual double getEstimatedRunTimeMemoryUsage(ComTdb * tdb);
virtual double getEstimatedRunTimeOverflowSize(double memoryQuotaMB);
@@ -580,7 +580,7 @@ public:
inline void setBMOsMemoryUsage(CostScalar x) { BMOsMemoryUsage_ = x; }
inline CostScalar getBMOsMemoryUsage() { return BMOsMemoryUsage_ ; }
- virtual CostScalar getEstimatedRunTimeMemoryUsage(NABoolean perCPU);
+ virtual CostScalar getEstimatedRunTimeMemoryUsage(NABoolean perNode, Lng32 *numStreams = NULL);
virtual double getEstimatedRunTimeMemoryUsage(ComTdb * tdb);
void setExtractProducerFlag() { isExtractProducer_ = TRUE; }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/00e3b874/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp
index 959ecb7..8aece47 100644
--- a/core/sql/optimizer/RelExpr.cpp
+++ b/core/sql/optimizer/RelExpr.cpp
@@ -1988,41 +1988,32 @@ NABoolean RelExpr::containsNode(OperatorTypeEnum nodeType)
}
double RelExpr::computeMemoryQuota(NABoolean inMaster,
- NABoolean perCPU,
- double BMOsMemoryLimit, // in bytes
- UInt16 totalNumBMOs, // per CPU
- double totalBMOsMemoryUsage, // per CPU, in bytes
+ NABoolean perNode,
+ double BMOsMemoryLimit, // in MB
+ UInt16 totalNumBMOs, // per query
+ double totalBMOsMemoryUsage, // for all BMOs per node in bytes
UInt16 numBMOsPerFragment, // per fragment
- double BMOsMemoryUsagePerFragment // per fragment, in bytes
+ double bmoMemoryUsage, // for the current BMO/Operator per node in bytes
+ Lng32 numStreams
)
{
- if ( perCPU == TRUE ) {
+ if ( perNode == TRUE ) {
Lng32 exeMem = Lng32(BMOsMemoryLimit/(1024*1024));
- if ( inMaster && CmpCommon::getDefault(ODBC_PROCESS) == DF_ON ) {
-
- // Limiting the total memory in the master process when in both
- // the per-CPU estimation and the ODBC mode.
-
- NADefaults &defs = ActiveSchemaDB()->getDefaults();
-
- Lng32 inCpuLimitDelta =
- defs.getAsLong(EXE_MEMORY_AVAILABLE_IN_MB)
- -
- defs.getAsLong(EXE_MEMORY_RESERVED_FOR_MXOSRVR_IN_MB);
-
- if ( inCpuLimitDelta < 0 )
- inCpuLimitDelta = 50;
-
- if (exeMem > inCpuLimitDelta)
- exeMem = inCpuLimitDelta;
+ // the quota is allocated in proportion of the given BMO operator
+ // estimated memory usage to the total estimated memory usage of all BMOs
+ // The ratio can be capped by the CQD
+ double bmoMemoryRatio = bmoMemoryUsage / totalBMOsMemoryUsage;
+ double capMemoryRatio = 1;
+ if (totalNumBMOs > 1) {
+ capMemoryRatio = ActiveSchemaDB()->getDefaults().getAsDouble(BMO_MEMORY_ESTIMATE_RATIO_CAP);
+ if (capMemoryRatio > 0 && capMemoryRatio <=1 && bmoMemoryRatio > capMemoryRatio)
+ bmoMemoryRatio = capMemoryRatio;
}
-
- // the quota is propotional to both the # of BMOs and the estimated memory
- // usage in the fragment, and evenly distrbuted among BMOs in the fragment.
- return ((exeMem/2) * (BMOsMemoryUsagePerFragment/totalBMOsMemoryUsage +
- double(numBMOsPerFragment)/totalNumBMOs)
- ) / numBMOsPerFragment;
+ double bmoMemoryQuotaPerNode = exeMem * bmoMemoryRatio;
+ double numInstancesPerNode = numStreams / MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1), numStreams);
+ double bmoMemoryQuotaPerInstance = bmoMemoryQuotaPerNode / numInstancesPerNode;
+ return bmoMemoryQuotaPerInstance;
} else {
// the old way to compute quota
Lng32 exeMem = getExeMemoryAvailable(inMaster);
@@ -2030,35 +2021,11 @@ double RelExpr::computeMemoryQuota(NABoolean inMaster,
}
}
-Lng32 RelExpr::getExeMemoryAvailable(NABoolean inMaster,
- Lng32 BMOsMemoryLimit) const
-{
- Lng32 exeMemAvailMB = BMOsMemoryLimit;
-
- if ((CmpCommon::getDefault(ODBC_PROCESS) == DF_ON) &&
- inMaster &&
- (exeMemAvailMB != 0)) // if the cqd is zero, then we do not do BMO quota
- {
- // Adjustment because MXOSRVR has QIO segments in competition with
- // executor.
- exeMemAvailMB -=
- ActiveSchemaDB()->getDefaults().getAsLong(
- EXE_MEMORY_RESERVED_FOR_MXOSRVR_IN_MB);
-
- if (exeMemAvailMB < 50)
- exeMemAvailMB = 50;
- }
-
- return exeMemAvailMB;
-} // RelExpr::getExeMemoryAvailable()
-
-
Lng32 RelExpr::getExeMemoryAvailable(NABoolean inMaster) const
{
Lng32 exeMemAvailMB =
ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_AVAILABLE_IN_MB);
-
- return getExeMemoryAvailable(inMaster, exeMemAvailMB);
+ return exeMemAvailMB;
}
// -----------------------------------------------------------------------