Hello All, A few days ago I posted on Firebird Support "Firebird Recurring Hourly Load". The gist of the post is that we noticed that every hour all Firebird processes would wake up for a second or two causing high load, context switches etc - This using Firebird 2.5.x on Centos 6.x/7.x.
I've look into this a little bit more and notice that the issue seems to lie in the trace touch thread - specifically TouchThreadFunc in jrd/trace/TraceConfigStorage.cpp. (Please note that I'm not a c++ developer, so there's a good chance that I'm missing something) Each thread calls sem_timedwait [while (!semaphore->tryEnter(delay))] with the next touch time in seconds. The thread then blocks till seconds after epoch + current milliseconds. When it returns it compares to the touch time: if (!m_base->touch_time || m_base->touch_time < now) Since touch_time is an integer value, current seconds will be equal to it for up to a full second. This results in a delay of zero being calculated and sem_trywait being called repeatedly for up to a second per thread until current seconds > touch_time. To resolve shouldn't the comparison check for equality: if (!m_base->touch_time || m_base->touch_time <= now) I'm also curious as to why each thread is required to wake at the exact same time - would it not reduce contention if each thread blocked for a full hour? Finally, for my own curiosity, what is the reason for touching the trace file hourly? I look forward to hearing your thoughts. Thanks and regards, David ------------------------------------------------------------------------------ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel