mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
Logging of memory (#2930)
* -logging of memory WIP * -better log for cgroup case * -fix log * -display in GIB * add log for freememory for non CGROUP (to be discussed) * test repeated log entries * -added counter for every 1000 call. effectivly 15m * Name logginng period and inrease it, clear config files from PR, add .gitignore --------- Co-authored-by: pgmabv99 <alexey.vorovich@gmail.com> Co-authored-by: Leonid Fedorov <leonid.fedorov@mariadb.com>
This commit is contained in:
parent
add3a57e8d
commit
5b4f06bf0d
5
.gitignore
vendored
5
.gitignore
vendored
@ -181,4 +181,9 @@ build/.cmake
|
|||||||
*.vtg
|
*.vtg
|
||||||
*.vtg-back
|
*.vtg-back
|
||||||
'*.vtg-Stashed changes'
|
'*.vtg-Stashed changes'
|
||||||
|
versioning/BRM/brmshmimpl.h
|
||||||
|
versioning/BRM/shmkeys.cpp
|
||||||
|
obj/
|
||||||
|
build/build
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,9 +78,21 @@ CGroupConfigurator::CGroupConfigurator()
|
|||||||
cGroupDefined = false;
|
cGroupDefined = false;
|
||||||
else
|
else
|
||||||
cGroupDefined = true;
|
cGroupDefined = true;
|
||||||
|
cout << __func__ << " cGroupDefined (from getConfig)" << cGroupDefined << endl;
|
||||||
|
|
||||||
ifstream v2Check("/sys/fs/cgroup/cgroup.controllers");
|
ifstream v2Check("/sys/fs/cgroup/cgroup.controllers");
|
||||||
cGroupVersion_ = (v2Check) ? v2 : v1;
|
cGroupVersion_ = (v2Check) ? v2 : v1;
|
||||||
|
|
||||||
|
string cGroupVersion_str="";
|
||||||
|
switch(cGroupVersion_){
|
||||||
|
case v1:
|
||||||
|
cGroupVersion_str="v1";
|
||||||
|
break;
|
||||||
|
case v2:
|
||||||
|
cGroupVersion_str="v2";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cout << __func__<< " cGroupVersion_str " << cGroupVersion_str << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGroupConfigurator::~CGroupConfigurator()
|
CGroupConfigurator::~CGroupConfigurator()
|
||||||
@ -198,7 +210,7 @@ uint64_t CGroupConfigurator::getTotalMemory()
|
|||||||
ret = getTotalMemoryFromProc();
|
ret = getTotalMemoryFromProc();
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Total mem available is " << ret << endl;
|
cout <<__func__ << " Total mem available (bytes) " << ret << " (GIB) " << ret/GIB << endl;
|
||||||
totalMemory = ret;
|
totalMemory = ret;
|
||||||
return totalMemory;
|
return totalMemory;
|
||||||
}
|
}
|
||||||
@ -206,7 +218,7 @@ uint64_t CGroupConfigurator::getTotalMemory()
|
|||||||
uint64_t CGroupConfigurator::getTotalMemoryFromProc()
|
uint64_t CGroupConfigurator::getTotalMemoryFromProc()
|
||||||
{
|
{
|
||||||
size_t memTot;
|
size_t memTot;
|
||||||
|
cout << __func__ << " reading /proc/meminfo " << endl;
|
||||||
ifstream in("/proc/meminfo");
|
ifstream in("/proc/meminfo");
|
||||||
string x;
|
string x;
|
||||||
|
|
||||||
@ -233,7 +245,9 @@ uint64_t CGroupConfigurator::getTotalMemoryFromCGroup()
|
|||||||
{
|
{
|
||||||
os << "/sys/fs/cgroup/" << cGroupName << "/memory.max";
|
os << "/sys/fs/cgroup/" << cGroupName << "/memory.max";
|
||||||
}
|
}
|
||||||
|
|
||||||
string filename = os.str();
|
string filename = os.str();
|
||||||
|
cout << __func__ <<" reading " << filename << endl;
|
||||||
|
|
||||||
ifstream in(filename.c_str());
|
ifstream in(filename.c_str());
|
||||||
|
|
||||||
@ -248,6 +262,7 @@ uint64_t CGroupConfigurator::getTotalMemoryFromCGroup()
|
|||||||
{
|
{
|
||||||
RETURN_READ_ERROR(0);
|
RETURN_READ_ERROR(0);
|
||||||
}
|
}
|
||||||
|
cout << __func__<< " read into memLimitStr " << memLimitStr << endl;
|
||||||
|
|
||||||
if (cGroupVersion_ == v2 && memLimitStr == "max")
|
if (cGroupVersion_ == v2 && memLimitStr == "max")
|
||||||
{
|
{
|
||||||
@ -271,11 +286,17 @@ uint64_t CGroupConfigurator::getFreeMemory()
|
|||||||
{
|
{
|
||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
if (!cGroupDefined)
|
if (!cGroupDefined)
|
||||||
|
{
|
||||||
ret = getFreeMemoryFromProc();
|
ret = getFreeMemoryFromProc();
|
||||||
|
if (logCounter++ % logMemoryPeriod == 0)
|
||||||
|
cout <<__func__<< " : returned from getFreeMemoryFromProc " << ret << " (GIB) " << ret/GIB << endl;
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint64_t usage = getMemUsageFromCGroup();
|
uint64_t usage = getMemUsageFromCGroup();
|
||||||
cout << "usage " << usage << endl;
|
if (logCounter++ % 1000 == 0)
|
||||||
|
cout << __func__<< " : returned from getMemUsageFromCGroup : usage " << usage << " (GIB) " << usage/GIB << endl;
|
||||||
|
|
||||||
if (usage == 0)
|
if (usage == 0)
|
||||||
ret = getFreeMemoryFromProc();
|
ret = getFreeMemoryFromProc();
|
||||||
|
@ -63,8 +63,11 @@ class CGroupConfigurator
|
|||||||
config::Config* config;
|
config::Config* config;
|
||||||
uint64_t totalMemory = 0;
|
uint64_t totalMemory = 0;
|
||||||
uint64_t totalSwap = 0;
|
uint64_t totalSwap = 0;
|
||||||
|
const uint64_t GIB = 1024ULL * 1024ULL * 1024ULL;
|
||||||
bool printedWarning = false;
|
bool printedWarning = false;
|
||||||
enum CGroupVersions cGroupVersion_;
|
enum CGroupVersions cGroupVersion_;
|
||||||
|
unsigned int logCounter = 0;
|
||||||
|
static constexpr unsigned int logMemoryPeriod = 5000;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
Loading…
x
Reference in New Issue
Block a user