Repository: incubator-trafodion Updated Branches: refs/heads/master acadd048d -> 6e6d1ea41
[TRAFODION-2420] RMS Enhancements Refactored the ESP memory management so that all the SQL memory both heap and space objects are accounted correctly in RMS With this change, the total SQL memory used by all processes involved in the query is represented in the counter "SQL Heap WM" Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/32aaad0c Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/32aaad0c Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/32aaad0c Branch: refs/heads/master Commit: 32aaad0cbc7a3ba7cd590cfb689a94573750805b Parents: 371cb71 Author: selvaganesang <selva.govindara...@esgyn.com> Authored: Fri Oct 27 15:41:26 2017 +0000 Committer: selvaganesang <selva.govindara...@esgyn.com> Committed: Fri Oct 27 15:41:26 2017 +0000 ---------------------------------------------------------------------- core/sql/bin/ex_esp_main.cpp | 1 - core/sql/executor/ExExeUtilGetStats.cpp | 6 ++-- core/sql/executor/ex_esp_frag_dir.cpp | 41 ++++++++++++---------------- core/sql/executor/ex_esp_frag_dir.h | 7 ++--- core/sql/regress/core/EXPECTEDRTS | 18 ++++++------ 5 files changed, 32 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/32aaad0c/core/sql/bin/ex_esp_main.cpp ---------------------------------------------------------------------- diff --git a/core/sql/bin/ex_esp_main.cpp b/core/sql/bin/ex_esp_main.cpp index c1dcf61..cadfa88 100644 --- a/core/sql/bin/ex_esp_main.cpp +++ b/core/sql/bin/ex_esp_main.cpp @@ -363,7 +363,6 @@ Int32 runESP(Int32 argc, char** argv, GuaReceiveFastStart *guaReceiveFastStart) ExEspFragInstanceDir espFragInstanceDir(cliGlobals, espExecutorHeap, - espExecutorHeap, (StatsGlobals *)statsGlobals); ExEspControlMessage espIpcControlMessage(&espFragInstanceDir, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/32aaad0c/core/sql/executor/ExExeUtilGetStats.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExExeUtilGetStats.cpp b/core/sql/executor/ExExeUtilGetStats.cpp index 7d86f8a..8f9a3cd 100644 --- a/core/sql/executor/ExExeUtilGetStats.cpp +++ b/core/sql/executor/ExExeUtilGetStats.cpp @@ -1644,9 +1644,9 @@ void ExExeUtilGetRTSStatisticsTcb::formatOperStats(SQLSTATS_ITEM* operStatsItems { moveRowToUpQueue(""); isHeadingDisplayed_ = TRUE; - sprintf(statsBuf_, "%5s%5s%5s%5s%5s%5s %-25s%5s%13s%19s%19s%19s %10s", - "LC","RC","Id","PaId", "ExId","Frag","TDB Name","DOP", "Dispatches","Oper CPU Time","Est. Records Used", - "Act. Records Used","Details"); + sprintf(statsBuf_, "%5s%5s%5s%5s%5s%5s %-25s%5s%13s%19s%19s%19s %s", + "LC","RC","Id","PaId", "ExId","Frag","TDBName","DOP", "Dispatches","OperCPUTime","EstRowsUsed", + "ActRowsUsed","Details"); moveRowToUpQueue(statsBuf_); moveRowToUpQueue(""); } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/32aaad0c/core/sql/executor/ex_esp_frag_dir.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ex_esp_frag_dir.cpp b/core/sql/executor/ex_esp_frag_dir.cpp index ae7a6b5..81ee824 100644 --- a/core/sql/executor/ex_esp_frag_dir.cpp +++ b/core/sql/executor/ex_esp_frag_dir.cpp @@ -75,13 +75,11 @@ // ----------------------------------------------------------------------- ExEspFragInstanceDir::ExEspFragInstanceDir(CliGlobals *cliGlobals, - CollHeap *heap, - CollHeap *exHeap, + NAHeap *heap, StatsGlobals *statsGlobals) : instances_(heap), cliGlobals_(cliGlobals), heap_(heap), - exHeap_(exHeap), statsGlobals_(statsGlobals), userIDEstablished_(FALSE), localStatsHeap_(NULL) @@ -108,8 +106,8 @@ ExEspFragInstanceDir::ExEspFragInstanceDir(CliGlobals *cliGlobals, statsGlobals_->getVersion() != StatsGlobals::CURRENT_SHARED_OBJECTS_VERSION_)) { statsGlobals_ = NULL; - statsHeap_ = new (exHeap_) - NAHeap("Process Stats Heap", (NAHeap *)exHeap_, + statsHeap_ = new (heap_) + NAHeap("Process Stats Heap", (NAHeap *)heap_, 8192, 0); semId_ = -1; @@ -121,7 +119,7 @@ ExEspFragInstanceDir::ExEspFragInstanceDir(CliGlobals *cliGlobals, if (error != 0) { statsGlobals_ = NULL; - statsHeap_ = (NAHeap *)exHeap_; + statsHeap_ = (NAHeap *)heap_; } else { @@ -227,19 +225,19 @@ ExFragInstanceHandle ExEspFragInstanceDir::addEntry(ExMsgFragment *msgFragment, if (msgFragment->getFragType() == ExFragDir::ESP) { - Space * stmtSpace = new(exHeap_) Space(Space::EXECUTOR_SPACE); - NAHeap *stmtHeap = new(exHeap_) NAHeap("Statement Heap", - (NAHeap *) exHeap_,32768); - stmtSpace->setParent(exHeap_); + NAHeap *fragHeap = new(heap_) NAHeap("ESP Fragment Heap", + (NAHeap *) heap_,32768); + Space * fragSpace = new(fragHeap) Space(Space::EXECUTOR_SPACE); + fragSpace->setParent(fragHeap); // allocate the globals in their own heap, like the master // executor does it - inst->globals_ = new(stmtHeap) ExEspStmtGlobals( + inst->globals_ = new(fragHeap) ExEspStmtGlobals( (short) msgFragment->getNumTemps(), cliGlobals_, msgFragment->getDisplayInGui(), - stmtSpace, - stmtHeap, + fragSpace, + fragHeap, this, inst->handle_, msgFragment->getInjectErrorAtExpr(), @@ -860,8 +858,8 @@ void ExEspFragInstanceDir::destroyEntry(ExFragInstanceHandle handle) entry->globals_->deleteMe(FALSE); entry->globals_ = NULL; - delete sp; - delete hp; + NADELETE(sp, Space, hp); + NADELETE(hp, NAHeap, heap_); } entry->msgFragment_->decrRefCount(); @@ -946,14 +944,11 @@ void ExEspFragInstanceDir::traceIdleMemoryUsage() success = fseek(traceFile, 0, SEEK_END); // append to end of file fprintf(traceFile, "%d:%02d:%02d,%d,%d,", localTime->tm_hour, localTime->tm_min, localTime->tm_sec, myPid, count); - fprintf(traceFile, PFSZ "," PFSZ "," PFSZ "," PFSZ "," PFSZ "," PFSZ "," PFSZ ",%ld,%ld\n", - exHeap_->getAllocSize(), - exHeap_->getAllocCnt(), - exHeap_->getTotalSize(), - exHeap_->getHighWaterMark(), + fprintf(traceFile, PFSZ "," PFSZ "," PFSZ "," PFSZ ",%ld,%ld\n", heap_->getAllocSize(), heap_->getAllocCnt(), - contextHeap->getAllocSize(), + heap_->getTotalSize(), + heap_->getHighWaterMark(), (Long)memSize * 1024, (Long)memPeak * 1024); fflush(traceFile); @@ -976,8 +971,8 @@ NAHeap *ExEspFragInstanceDir::getLocalStatsHeap() if (statsGlobals_ == NULL) localStatsHeap_ = statsHeap_; else - localStatsHeap_ = new (exHeap_) - NAHeap("Process Local Stats Heap", (NAHeap *)exHeap_, + localStatsHeap_ = new (heap_) + NAHeap("Process Local Stats Heap", (NAHeap *)heap_, 8192, 0); } return localStatsHeap_; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/32aaad0c/core/sql/executor/ex_esp_frag_dir.h ---------------------------------------------------------------------- diff --git a/core/sql/executor/ex_esp_frag_dir.h b/core/sql/executor/ex_esp_frag_dir.h index bcca8fc..b494227 100644 --- a/core/sql/executor/ex_esp_frag_dir.h +++ b/core/sql/executor/ex_esp_frag_dir.h @@ -144,8 +144,7 @@ public: }; ExEspFragInstanceDir(CliGlobals *cliGlobals, - CollHeap *heap, - CollHeap *exHeap, + NAHeap *heap, StatsGlobals *statsGlobals); ~ExEspFragInstanceDir(); @@ -294,9 +293,7 @@ private: CliGlobals *cliGlobals_; - CollHeap *heap_; - - CollHeap *exHeap_; + NAHeap *heap_; StatsGlobals *statsGlobals_; NAHeap *statsHeap_; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/32aaad0c/core/sql/regress/core/EXPECTEDRTS ---------------------------------------------------------------------- diff --git a/core/sql/regress/core/EXPECTEDRTS b/core/sql/regress/core/EXPECTEDRTS index a975e8b..f9adf52 100644 --- a/core/sql/regress/core/EXPECTEDRTS +++ b/core/sql/regress/core/EXPECTEDRTS @@ -1972,7 +1972,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2025,7 +2025,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2488,7 +2488,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2541,7 +2541,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2595,7 +2595,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2902,7 +2902,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -2958,7 +2958,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.033737 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 9 0 4 1821 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 40 2 4 @@ -3377,7 +3377,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.019772 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 6 0 4 303 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 5 2 4 @@ -3497,7 +3497,7 @@ Max. Execute Time 0.033737 secs Avg. Execute Time 0.018444 secs Stats Collection Type OPERATOR_STATS - LC RC Id PaId ExId Frag TDB Name DOP Dispatches Oper CPU Time Est. Records Used Act. Records Used Details + LC RC Id PaId ExId Frag TDBName DOP Dispatches OperCPUTime EstRowsUsed ActRowsUsed Details 10 . 11 . 5 0 EX_ROOT 1 5 6 0 4 332 9 . 10 11 4 0 EX_SPLIT_TOP 1 5 5 2 4