You've already forked mariadb-columnstore-engine
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:
@ -2627,93 +2627,6 @@ bool BPPV::aborted()
|
||||
return sendThread->aborted();
|
||||
}
|
||||
|
||||
#ifdef PRIMPROC_STOPWATCH
|
||||
std::unordered_map<pthread_t, logging::StopWatch*> stopwatchMap;
|
||||
pthread_mutex_t stopwatchMapMutex;
|
||||
bool stopwatchThreadCreated = false;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Stays in "sleep" state for specified until passed seconds have elapsed.
|
||||
//------------------------------------------------------------------------------
|
||||
void pause_(int seconds )
|
||||
{
|
||||
struct timespec req;
|
||||
struct timespec rem;
|
||||
req.tv_sec = seconds;
|
||||
req.tv_nsec = 0;
|
||||
rem.tv_sec = 0;
|
||||
rem.tv_nsec = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (nanosleep(&req, &rem) != 0)
|
||||
{
|
||||
if (rem.tv_sec > 0 || rem.tv_nsec > 0)
|
||||
{
|
||||
req = rem;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void* autoFinishStopwatchThread(void* arg)
|
||||
{
|
||||
struct timeval tvCurrent;
|
||||
int count = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// Pause two seconds.
|
||||
pause_(2);
|
||||
count++;
|
||||
// Iterate through the stopwatch map and see how long it's been since last activity.
|
||||
auto stopwatchMapIter = stopwatchMap.begin();
|
||||
logging::StopWatch* stopwatch;
|
||||
gettimeofday(&tvCurrent, 0);
|
||||
bool primProcIdle = true;
|
||||
|
||||
while (stopwatchMapIter != stopwatchMap.end())
|
||||
{
|
||||
stopwatch = stopwatchMapIter->second;
|
||||
|
||||
// If any threads have been active in the last 5 seconds, kick out.
|
||||
if (((tvCurrent.tv_sec - stopwatch->fTvLast.tv_sec) < 5) || stopwatch->isActive())
|
||||
{
|
||||
primProcIdle = false;
|
||||
break;
|
||||
}
|
||||
|
||||
stopwatchMapIter++;
|
||||
}
|
||||
|
||||
// No activity in last five seconds, display timing results.
|
||||
// if(primProcIdle || (count%15 == 0))
|
||||
if (primProcIdle)
|
||||
{
|
||||
pthread_mutex_lock(&stopwatchMapMutex);
|
||||
stopwatchMapIter = stopwatchMap.begin();
|
||||
|
||||
while (stopwatchMapIter != stopwatchMap.end())
|
||||
{
|
||||
stopwatch = stopwatchMapIter->second;
|
||||
stopwatch->finish();
|
||||
stopwatchMapIter++;
|
||||
delete stopwatch;
|
||||
}
|
||||
|
||||
stopwatchMap.clear();
|
||||
pthread_mutex_unlock(&stopwatchMapMutex);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
#endif // PRIMPROC_STOPWATCH
|
||||
|
||||
|
||||
// end workaround
|
||||
|
||||
} // namespace primitiveprocessor
|
||||
|
Reference in New Issue
Block a user