{"id":3884,"date":"2014-10-14T10:27:46","date_gmt":"2014-10-14T00:27:46","guid":{"rendered":"https:\/\/www.flamingspork.com\/blog\/?p=3884"},"modified":"2014-10-14T10:27:46","modified_gmt":"2014-10-14T00:27:46","slug":"mysql-5-7-5-on-power-thread-priority","status":"publish","type":"post","link":"https:\/\/www.flamingspork.com\/blog\/2014\/10\/14\/mysql-5-7-5-on-power-thread-priority\/","title":{"rendered":"MySQL 5.7.5 on POWER &#8211; thread priority"},"content":{"rendered":"<p>Good news everyone!<\/p>\n<p>MySQL 5.7.5 is out with a bunch more patches for running well on POWER in the tree. I haven&#8217;t yet gone and tried it all out, but since I&#8217;m me, I look at bugs database and git\/bzr history first.<\/p>\n<p>On Intel CPUs, when you&#8217;re spinning on a spin lock, you&#8217;re meant to execute the PAUSE CPU instruction. This tells the CPU that other execution threads in the same core should be given priority as you are currently not doing anything productive. Without this, you&#8217;re likely going to hurt on hyperthreaded CPUs.<\/p>\n<p>In MySQL, there are custom spinlocks in order to do interesting adaptive mutex things to attempt to squeeze the most performance possible out of modern systems.<\/p>\n<p>One of the (not 100% ready, but close) bugs with patches I submitted against MySQL 5.7 was for using the equivalent of the PAUSE instruction for POWER CPUs. On POWER, we&#8217;re a bit different, you can actually set priorities of threads (which may matter more, as POWER8 CPUs can be in SMT8 mode &#8211; where there are *eight* executing threads per core).<\/p>\n<p>So, the good news is that in MySQL 5.7.5, the magic instructions for setting thread priority are in! This should mean great things for performance on POWER systems with any of the SMT modes enabled.<\/p>\n<p>The next interesting part of this is how it interacts with other KVM guests on a system. At least on POWER (and on x86 as well, although I won&#8217;t go into details here) there&#8217;s a hypervisor call that a guest can make saying &#8220;hey, I&#8217;m spinning here, perhaps you want to make sure other vcpus execute so that at some point I can continue&#8221;. On POWER, this is the H_CONFER hcall, where you can basically do a directed yield to another vcpu (the one that holds the lock you&#8217;re trying to get is a good idea).<\/p>\n<p>Generally though, it&#8217;s only the guest kernel that does this, not userspace. You can see the H_CONFER call in __spin_yield(arch_spinlock_t*) and __rw_yield(arch_rwlock_t*) in arch\/powerpc\/lib\/locks.c in the kernel.<\/p>\n<p>It would be interesting to see what extra we could get out of a system running multiple guests with MySQL servers if InnoDB\/MySQL could properly yield to the right vcpu (well, thread I guess).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good news everyone! MySQL 5.7.5 is out with a bunch more patches for running well on POWER in the tree. I haven&#8217;t yet gone and tried it all out, but since I&#8217;m me, I look at bugs database and git\/bzr &hellip; <a href=\"https:\/\/www.flamingspork.com\/blog\/2014\/10\/14\/mysql-5-7-5-on-power-thread-priority\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[570,8],"tags":[607,589,561,141,625,628,562,608],"class_list":["post-3884","post","type-post","status-publish","format-standard","hentry","category-ibm-work-et-al","category-linux-kernel","tag-5-7-5","tag-kernel","tag-kvm","tag-linux","tag-linux-kernel","tag-mysql","tag-power","tag-smt"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5a6n8-10E","jetpack-related-posts":[{"id":3752,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/06\/03\/mysql-5-6-on-power-patch-available\/","url_meta":{"origin":3884,"position":0},"title":"MySQL 5.6 on POWER (patch available)","author":"Stewart Smith","date":"2014-06-03","format":false,"excerpt":"The following sentence is brought to you by IBM Legal. The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. Okay, now that is out of the way.... If you're the kind of person who follows the MySQL bugs database closely or subscribes\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3778,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/07\/17\/update-on-mysql-on-power8\/","url_meta":{"origin":3884,"position":1},"title":"Update on MySQL on POWER8","author":"Stewart Smith","date":"2014-07-17","format":false,"excerpt":"About 1.5 months ago I blogged on MySQL 5.6 on POWER andtalked about what I had to poke at to make modern MySQL versions run and run well on shiny POWER8 systems. One of those bugs, MySQL bug 47213 (InnoDB mutex\/rw_lock should be conscious of memory ordering other than Intel)\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3813,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/10\/08\/quick-mysql-5-7-5-thoughts\/","url_meta":{"origin":3884,"position":2},"title":"Quick MySQL 5.7.5 thoughts","author":"Stewart Smith","date":"2014-10-08","format":false,"excerpt":"It was great to see the recent announcement of MySQL 5.7.5 over at the MySQL Server Team blog. I'm looking forward to throwing this release at some of the POWER8 systems we have for a couple of really good reasons: 1) Does it work better than previous MySQL 5.7 releases\u2026","rel":"","context":"In &quot;mysql&quot;","block_context":{"text":"mysql","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3758,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/06\/03\/mysql-5-7-on-power\/","url_meta":{"origin":3884,"position":3},"title":"MySQL 5.7 on POWER","author":"Stewart Smith","date":"2014-06-03","format":false,"excerpt":"In a previous post, I covered porting MySQL 5.6 to POWER and subsequently, some new record performance numbers with MySQL 5.6.17 on POWER8. Well, those following at home will be aware that not only is the next sentence sponsored by IBM Legal, but that MySQL 5.7 alleviates a bunch of\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4035,"url":"https:\/\/www.flamingspork.com\/blog\/2016\/02\/26\/mysql-contributions-status\/","url_meta":{"origin":3884,"position":4},"title":"MySQL Contributions status","author":"Stewart Smith","date":"2016-02-26","format":false,"excerpt":"This post is an update to the status of various MySQL bugs (some with patches) that I've filed over the past couple of years (or that people around me have). I'm not looking at POWER specific ones, as there are these too, but each of these bugs here deal with\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":715,"url":"https:\/\/www.flamingspork.com\/blog\/2006\/06\/14\/arjens-mysql-community-journal-hyperthreading-not-on-a-mysql-server\/","url_meta":{"origin":3884,"position":5},"title":"Arjen&#8217;s MySQL Community Journal &#8211; HyperThreading? Not on a MySQL server&#8230;","author":"Stewart Smith","date":"2006-06-14","format":false,"excerpt":"Arjen's MySQL Community Journal - HyperThreading? Not on a MySQL server... I blame the Linux Process Scheduler. At least it's better than the earlier 2.6 days where things would get shunted a lot from one \"cpu\" to the other \"cpu\" for no real reason. Newer kernel verisons are probably better...\u2026","rel":"","context":"In &quot;linux-kernel&quot;","block_context":{"text":"linux-kernel","link":"https:\/\/www.flamingspork.com\/blog\/category\/linux-kernel\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/comments?post=3884"}],"version-history":[{"count":1,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3884\/revisions"}],"predecessor-version":[{"id":3885,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3884\/revisions\/3885"}],"wp:attachment":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/media?parent=3884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/categories?post=3884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/tags?post=3884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}