{"id":2485,"date":"2014-03-13T20:17:55","date_gmt":"2014-03-13T20:17:55","guid":{"rendered":"http:\/\/really.zonky.org\/?p=2485"},"modified":"2014-03-13T20:17:55","modified_gmt":"2014-03-13T20:17:55","slug":"amds-secret-32-bit-abi","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=2485","title":{"rendered":"AMD&#8217;s &#8220;Secret&#8221; 32-Bit ABI"},"content":{"rendered":"<p>This blog posting talks about\u00a0<em>machine code<\/em> and whether 32-bit code or 64-bit code is more appropriate.\u00a0When AMD released the Opteron way back in 2003, it was the first processor to support the <a href=\"http:\/\/en.wikipedia.org\/wiki\/X86-64\">x86-64<\/a> instruction set for supporting 64-bit code whilst maintaining backward compatibility with the old <a href=\"http:\/\/en.wikipedia.org\/wiki\/X86-32\">IA3<\/a><span style=\"text-decoration: underline;\">2<\/span>\u00a0code. Or in other words, the Opteron could run both 32-bit code and 64-bit code.<\/p>\n<p>Everybody leaped onto the 64-bit bandwagon without thinking too much about it &#8211; it was faster.<\/p>\n<p>But if we look at the other processors that made the transition from 32-bit code to 64-bit code &#8211; such as the <a href=\"http:\/\/en.wikipedia.org\/wiki\/SPARC\">SPARC<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/MIPS_architecture\">MIPS<\/a>, etc., we find something interesting. Much of the code running on the relevant operating systems remained 32-bit &#8211; not as a transitional measure, but because the 32-bit code was\u00a0<em>faster<\/em>. If you look at a relatively modern Solaris system the contents of\u00a0<em>\/bin<\/em> contain 500-odd binaries that are 32-bit and just 11 that are 64-bit (most of which aren&#8217;t in fact part of Solaris but another add-on package).<\/p>\n<p>It turns out that in general, 64-bit code is <i>slower<\/i> than 32-bit code. In the case of x86-64, 64-bit code is faster\u00a0<em>not<\/em> because it is 64-bit, but because of the architectural changes that were also introduced &#8211; including (probably most significantly) extra registers.<\/p>\n<p>How do we know this? Apart from it being obvious to those who have lived through the 32-bit to 64-bit transition multiple times, it turns out that people have been experimenting. As it turns out, the x86-64 architecture does allow for 32-bit code to be run with all the features of the x86-64 architecture and that architecture has been labelled as <a href=\"http:\/\/en.wikipedia.org\/wiki\/X32_ABI\">X32<\/a>.<\/p>\n<p>It turns out that X32 code can be anywhere from 5-40%\u00a0<em>faster<\/em> than 64-bit code. The largest increases come from code that makes\u00a0<em>very<\/em> heavy use of pointers, and at present no benchmarks of &#8220;ordinary&#8221; software have been released.<\/p>\n<p>The &#8220;downside&#8221; of X32 is of course that the software is limited to 4Gbytes of memory, but\u00a0<em>most<\/em> programmes don&#8217;t need that much memory because 4Gbytes is a\u00a0<em>lot<\/em>. Forget that huge video editor you&#8217;re playing with &#8211; that will quite possibly need 64-bit pointers, but what about all the other software running on your machine?<\/p>\n<p>There are over 400 processes running on my workstation, and\u00a0<em>none<\/em> of those processes really requires more than 4Gbytes of memory. Sure I run software that\u00a0<em>does<\/em> require more than 4Gbytes of memory, but not all the time.<\/p>\n<p>And running things 10% quicker would be useful &#8230; or alternatively running things quicker means the processor can spend more time asleep making battery life longer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog posting talks about\u00a0machine code and whether 32-bit code or 64-bit code is more appropriate.\u00a0When AMD released the Opteron way back in 2003, it was the first processor to support the x86-64 instruction set for supporting 64-bit code whilst maintaining backward compatibility with the old IA32\u00a0code. Or in other words, the Opteron could run <a href='https:\/\/really.zonky.org\/?p=2485' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[4],"tags":[1188,1190,1189],"class_list":["post-2485","post","type-post","status-publish","format-standard","hentry","category-it","tag-amd64","tag-x32","tag-x86-64","category-4-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-E5","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/2485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2485"}],"version-history":[{"count":1,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions"}],"predecessor-version":[{"id":3277,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions\/3277"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}