mirror of
https://github.com/gigablast/open-source-search-engine.git
synced 2024-10-04 04:07:13 +03:00
speed up gb by fixing excessive calling to
gettimeofday() system call.
This commit is contained in:
parent
52bf9f1ff0
commit
6e7b329cef
8
Loop.cpp
8
Loop.cpp
@ -929,9 +929,10 @@ bool Loop::init ( ) {
|
||||
|
||||
|
||||
m_realInterrupt.it_value.tv_sec = 0;
|
||||
m_realInterrupt.it_value.tv_usec = 10 * 1000;
|
||||
// 1000 microseconds in a millisecond
|
||||
m_realInterrupt.it_value.tv_usec = 1 * 1000;
|
||||
m_realInterrupt.it_interval.tv_sec = 0;
|
||||
m_realInterrupt.it_interval.tv_usec = 10 * 1000;
|
||||
m_realInterrupt.it_interval.tv_usec = 1 * 1000;
|
||||
|
||||
|
||||
m_noInterrupt.it_value.tv_sec = 0;
|
||||
@ -1148,6 +1149,9 @@ void sigvtalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
void sigalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
// so we don't call gettimeofday() thousands of times a second...
|
||||
g_clockNeedsUpdate = true;
|
||||
|
||||
// stats
|
||||
g_numAlarms++;
|
||||
// . see where we are in the code
|
||||
|
15
Profiler.cpp
15
Profiler.cpp
@ -1438,6 +1438,16 @@ extern int g_inMemcpy;
|
||||
void
|
||||
Profiler::getStackFrame(int sig) {
|
||||
|
||||
// need to interrupt every 1ms to set this to true
|
||||
g_clockNeedsUpdate = true;
|
||||
|
||||
// profile once every 5ms, not every 1ms
|
||||
static int32_t s_count = 0;
|
||||
|
||||
if ( ++s_count != 5 ) return;
|
||||
|
||||
s_count = 0;
|
||||
|
||||
// prevent cores.
|
||||
// TODO: hack this to a function somehow...
|
||||
// we set this to positive values when calling library functions like
|
||||
@ -1566,9 +1576,10 @@ Profiler::startRealTimeProfiler() {
|
||||
//signal(SIGVTALRM, Profiler::getStackFrame);
|
||||
signal(SIGALRM, Profiler::getStackFrame);
|
||||
value.it_interval.tv_sec = 0;
|
||||
value.it_interval.tv_usec = 5000;
|
||||
// 1000 microseconds is 1 millisecond
|
||||
value.it_interval.tv_usec = 1000;
|
||||
value.it_value.tv_sec = 0;
|
||||
value.it_value.tv_usec = 5000;
|
||||
value.it_value.tv_usec = 1000;
|
||||
setitimer( which, &value, &ovalue );
|
||||
m_realTimeProfilerRunning = true;
|
||||
}
|
||||
|
10
fctypes.cpp
10
fctypes.cpp
@ -10,6 +10,8 @@
|
||||
|
||||
static bool g_clockInSync = false;
|
||||
|
||||
bool g_clockNeedsUpdate = true;
|
||||
|
||||
bool isClockInSync() {
|
||||
if ( g_hostdb.m_initialized && g_hostdb.m_hostId == 0 ) return true;
|
||||
return g_clockInSync;
|
||||
@ -1938,6 +1940,14 @@ int64_t gettimeofdayInMilliseconds() {
|
||||
// a signal handler is underway in the main thread!
|
||||
if ( g_inSigHandler && ! g_threads.amThread() ) {
|
||||
char *xx = NULL; *xx = 0; }
|
||||
|
||||
// the real tiem sigalrm interrupt in Loop.cpp sets this to
|
||||
// true once per millisecond
|
||||
if ( ! g_clockNeedsUpdate )
|
||||
return g_now;
|
||||
|
||||
g_clockNeedsUpdate = false;
|
||||
|
||||
// this isn't async signal safe...
|
||||
struct timeval tv;
|
||||
//g_loop.disableTimer();
|
||||
|
Loading…
Reference in New Issue
Block a user