ndb - add support for periodic mem-reporting

parent b7deb4dc
......@@ -96,6 +96,8 @@
#define CFG_DB_CHECKPOINT_SPEED 164
#define CFG_DB_CHECKPOINT_SPEED_SR 165
#define CFG_DB_MEMREPORT_FREQUENCY 166
#define CFG_DB_SGA 198 /* super pool mem */
#define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */
......
......@@ -1100,6 +1100,7 @@ private:
};
Uint32 c_errorInsert3000_TableId;
Uint32 c_memusage_report_frequency;
};
#endif
......@@ -112,6 +112,7 @@ void Dbacc::execCONTINUEB(Signal* signal)
}
case ZREPORT_MEMORY_USAGE:{
jam();
Uint32 cnt = signal->theData[1];
static int c_currentMemUsed = 0;
int now = cpagesize ? (cnoOfAllocatedPages * 100)/cpagesize : 0;
const int thresholds[] = { 99, 90, 80, 0};
......@@ -125,14 +126,22 @@ void Dbacc::execCONTINUEB(Signal* signal)
}
}
if(now != c_currentMemUsed){
reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1);
if(now != c_currentMemUsed ||
(c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency))
{
reportMemoryUsage(signal,
now > c_currentMemUsed ? 1 :
now < c_currentMemUsed ? -1 : 0);
cnt = 0;
c_currentMemUsed = now;
}
else
{
cnt ++;
}
c_currentMemUsed = now;
signal->theData[0] = ZREPORT_MEMORY_USAGE;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
signal->theData[1] = cnt;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
return;
}
......@@ -199,7 +208,8 @@ void Dbacc::execNDB_STTOR(Signal* signal)
csystemRestart = ZFALSE;
signal->theData[0] = ZREPORT_MEMORY_USAGE;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
signal->theData[1] = 0;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
break;
default:
jam();
......@@ -353,6 +363,10 @@ void Dbacc::execREAD_CONFIG_REQ(Signal* signal)
initRecords();
ndbrestart1Lab(signal);
c_memusage_report_frequency = 0;
ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
&c_memusage_report_frequency);
tdata0 = 0;
initialiseRecordsLab(signal, ref, senderData);
return;
......
......@@ -2571,6 +2571,7 @@ private:
// Trigger variables
Uint32 c_maxTriggersPerTable;
Uint32 c_memusage_report_frequency;
Uint32 c_errorInsert4000TableId;
Uint32 c_min_list_size[MAX_FREE_LIST + 1];
......
......@@ -169,6 +169,7 @@ void Dbtup::execCONTINUEB(Signal* signal)
case ZREPORT_MEMORY_USAGE:{
ljam();
static int c_currentMemUsed = 0;
Uint32 cnt = signal->theData[1];
Uint32 tmp = c_page_pool.getSize();
int now = tmp ? (cnoOfAllocatedPages * 100)/tmp : 0;
const int thresholds[] = { 100, 90, 80, 0 };
......@@ -182,12 +183,22 @@ void Dbtup::execCONTINUEB(Signal* signal)
}
}
if(now != c_currentMemUsed){
reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1);
if(now != c_currentMemUsed ||
(c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency))
{
reportMemoryUsage(signal,
now > c_currentMemUsed ? 1 :
now < c_currentMemUsed ? -1 : 0);
cnt = 0;
c_currentMemUsed = now;
}
else
{
cnt++;
}
signal->theData[0] = ZREPORT_MEMORY_USAGE;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
signal->theData[1] = cnt;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
return;
}
case ZBUILD_INDEX:
......@@ -337,6 +348,10 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal)
clastBitMask = 1;
clastBitMask = clastBitMask << 31;
c_memusage_report_frequency = 0;
ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
&c_memusage_report_frequency);
initialiseRecordsLab(signal, 0, ref, senderData);
}//Dbtup::execSIZEALT_REP()
......@@ -499,7 +514,8 @@ void Dbtup::execNDB_STTOR(Signal* signal)
/* RESTART. */
/*****************************************/
signal->theData[0] = ZREPORT_MEMORY_USAGE;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
signal->theData[1] = 0;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1);
break;
default:
ljam();
......
......@@ -1298,6 +1298,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0",
"0",
STR_VALUE(MAX_INT_RNIL) },
{
CFG_DB_MEMREPORT_FREQUENCY,
"MemReportFrequency",
DB_TOKEN,
"Frequency of mem reports in seconds, 0 = only when passing %-limits",
ConfigInfo::CI_USED,
false,
ConfigInfo::CI_INT,
"0",
"0",
STR_VALUE(MAX_INT_RNIL) },
/***************************************************************************
* API
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment