On 11/18/16 14:19, David Hollings wrote: > 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)
Your analysis and way to cure he bug are absolutely correct, thank you. > 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? That's how it's dome in FB3 and future versions. > Finally, for my own curiosity, what is the reason for touching the trace > file hourly? Very simple - need to coexist with cron's scripts performing housekeeping in /tmp. For details see http://tracker.firebirdsql.org/browse/CORE-2917 ------------------------------------------------------------------------------ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel