tag:blogger.com,1999:blog-9149523927864751087.post4401210621299139007..comments2024-03-26T09:43:01.052-07:00Comments on Small Datum: The InnoDB Mutex, part 3Mark Callaghanhttp://www.blogger.com/profile/09590445221922043181noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-9149523927864751087.post-37313354345425151452014-08-29T07:12:30.123-07:002014-08-29T07:12:30.123-07:00My request at this point is for performance of fut...My request at this point is for performance of futex-mutex to be better than the sync-array mutex all of the time. Today it appears to be better sometimes and worse sometimes. I opened http://bugs.mysql.com/bug.php?id=73763 for this. Mark Callaghanhttps://www.blogger.com/profile/09590445221922043181noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-85004266687752600132014-08-28T23:00:14.872-07:002014-08-28T23:00:14.872-07:00I've tried replacing the log_t::mutex with a P...I've tried replacing the log_t::mutex with a POSIX mutex and also other hot mutexes in the code. It is trivial to do that with the new infrastructure. While they perform well in synthetic benchmarks. In practice I see higher contention and a bigger drop in QPS.Sunny Bainshttps://www.blogger.com/profile/03202312916091066986noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-9014058974354072982014-08-28T20:47:56.585-07:002014-08-28T20:47:56.585-07:00ok, thanks. Let me try and reproduce the results a...ok, thanks. Let me try and reproduce the results and attempt to understand what's going on. Should help in improving the mutex code.Sunny Bainshttps://www.blogger.com/profile/03202312916091066986noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-46653438815253165102014-08-28T20:43:54.135-07:002014-08-28T20:43:54.135-07:00From my shell script the args are:
./innotsim $nt...From my shell script the args are:<br />./innotsim $nthr $nloops $thinkd $spinr $spind $y $nmux $retry_after_reserve $max_spinners<br /><br />nthr - number of user threads<br />nloops - number of loop iterations per user thread<br />thinkd - number of iterations to do the work loop (ut_busy, which is ut_delay minus the pause instruction)<br />spinr - number of rounds for the busy wait loop<br />spind - number of loop iterations for ut_busy<br />y - inno, futex, posixadapt, etc<br />nmux - number of mutexes, threads evenly distributed across mutexes<br />retry_after_reserve - number of times to try to get the lock after reserving sync array slot, 4 is what innodb uses<br />max_spinners - max number of concurrent spinners for the new mutex variations I added that can limit max spinning threads -- posixgnspin, posixlnspin<br /><br />Also, I compile via: g++ -DFUTEX_ON -Wall -O2 -g -o innotsim innotsim.c -lpthread -lmMark Callaghanhttps://www.blogger.com/profile/09590445221922043181noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-16247178568067587832014-08-28T20:32:12.864-07:002014-08-28T20:32:12.864-07:00I like this little program you've written, ext...I like this little program you've written, extremely useful. I'm still trying to figure out if I'm running it correctly. I want to run the test in the first graph. This is my take.<br /><br />./innotsim 64 1000000 0 4 1 (futex | inno2) 1 0 1<br /><br /><br />Sunny Bainshttps://www.blogger.com/profile/03202312916091066986noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-7412044580779187892014-08-28T19:24:00.234-07:002014-08-28T19:24:00.234-07:00Compare it to the old-style InnoDB mutex, "in...Compare it to the old-style InnoDB mutex, "inno syncarray" in the graph above:<br />* they have similar busy-wait loops<br />* inno syncarray suffers from broadcast on unlock, inno futex only waits one waiter<br /><br />So inno futex should be strictly better than inno syncarry on the graphs from part2 and part3 (here), ignoring some variance that occurs, but it definitely is not and I don't think variance explains it. Mark Callaghanhttps://www.blogger.com/profile/09590445221922043181noreply@blogger.comtag:blogger.com,1999:blog-9149523927864751087.post-91411648453915099122014-08-28T17:32:49.536-07:002014-08-28T17:32:49.536-07:00The futex makes a kernel call, if the think time i...The futex makes a kernel call, if the think time is 0 then the spin and loop must be increased. Otherwise the cost shifts to the kernel.Sunny Bainshttps://www.blogger.com/profile/03202312916091066986noreply@blogger.com