1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

A plugable PoorManProfiler singleton

This commit is contained in:
Roman Nozdrin
2021-04-13 16:27:24 +00:00
parent f4b02a7aca
commit 757f8d00a5
5 changed files with 151 additions and 131 deletions

View File

@ -70,6 +70,11 @@ using namespace joblist;
namespace primitiveprocessor
{
#ifdef PRIMPROC_STOPWATCH
#include "poormanprofiler.inc"
#endif
// these are config parms defined in primitiveserver.cpp, initialized by PrimProc main().
extern uint32_t blocksReadAhead;
extern uint32_t dictBufferSize;
@ -2157,42 +2162,14 @@ int BatchPrimitiveProcessor::operator()()
utils::setThreadName("PPBatchPrimProc");
#ifdef PRIMPROC_STOPWATCH
const static std::string msg{"BatchPrimitiveProcessor::operator()"};
logging::StopWatch* stopwatch = nullptr;
logging::StopWatch* stopwatch = profiler.getTimer();
#endif
if (currentBlockOffset == 0)
{
#ifdef PRIMPROC_STOPWATCH
auto stopwatchMapIter = stopwatchMap.find(pthread_self());
if (stopwatchMapIter != stopwatchMap.end())
{
stopwatch = stopwatchMapIter->second;
}
else
{
pthread_mutex_lock(&stopwatchMapMutex);
stopwatch = new logging::StopWatch(stopwatchMap.size());
stopwatchMap.insert({pthread_self(), stopwatch});
// Create the thread that will show timing results after five seconds of idle time.
if (!stopwatchThreadCreated)
{
pthread_t timerThread;
int err = pthread_create(&timerThread, NULL, autoFinishStopwatchThread, NULL);
if (err)
cout << "Error creating thread to complete Stopwatches." << endl;
stopwatchThreadCreated = true;
}
pthread_mutex_unlock(&stopwatchMapMutex);
}
stopwatch->start(msg);
#endif
idbassert(count > 0);
}
@ -2272,7 +2249,6 @@ int BatchPrimitiveProcessor::operator()()
<< " blockNum=" << blockNum << endl;
*/
}
vssCache.clear();
#ifndef __FreeBSD__
pthread_mutex_unlock(&objLock);