{"id":79,"date":"2008-07-25T20:59:36","date_gmt":"2008-07-25T17:59:36","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=79"},"modified":"2012-06-24T17:22:29","modified_gmt":"2012-06-24T14:22:29","slug":"pae-whats-that-and-how-bad-for-performance","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2008\/07\/pae-whats-that-and-how-bad-for-performance\/","title":{"rendered":"PAE &#8211; what&#8217;s that, and how bad for performance?"},"content":{"rendered":"<p><span style=\"color: #888888;\"><strong>Err, what's PAE?<\/strong><\/span><\/p>\n<p><a title=\"PAE on wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Physical_Address_Extension\">PAE<\/a> (Physical Address Extension) is a \"workaround\" for letting <strong>x86-32bit(!)<\/strong> <strong>OS<\/strong> see more than 4GB of RAM. 4GB is the limit for 32bit memory addresses. PAE is not needed and not implemented on x86-64 processors when 64 bit (\"<a title=\"Long mode\" href=\"http:\/\/en.wikipedia.org\/wiki\/Long_mode\">long mode<\/a>\") is enabled.<\/p>\n<p><strong><span style=\"color: #888888;\">How does it work?<\/span><\/strong><\/p>\n<p>In short, it simply adds 4 bits to the memory addresses (32bit -&gt; 36bit) and one more level of memory-lookup-hierarchy, and: voila, OS can access <strong>up to 64GB ram<\/strong> (which is not science fiction these crazy days..). Of course, a <strong>single 32bit process<\/strong> is not aware, and would still only have a 4GB of virtual address space, even with PAE.<\/p>\n<p><span style=\"color: #888888;\"><strong>Performance penalty: yes or no, and how much?<\/strong><\/span><\/p>\n<p>I was given a task to research the PAE technology for recommending my company whether we should use it or not, especially performance-wise.<\/p>\n<p><!--more--><\/p>\n<p>PAE is <strong>hardware<\/strong> supported since Intel Pentium Pro (back in the mid 90s..). Reading \"hardware supported\" might mislead, and make one think that it's all accelerated and there's no performance penalty. But still, even in hardware, PAE adds one more hierarchy level for memory lookups, and my weak hardware knowledge tells that it might still slow something down...<\/p>\n<p>The Linux kernel of most 32bit distributions (in particular RedHat 5) ships with PAE <strong>disabled<\/strong>, while an optional PAE-enabled kernel is available. On 32bit Windows, PAE used to be disabled by default, but since WinXP SP2 windows is PAE-<strong>enabled<\/strong> by default. I've also seen some Linux distros enabling PAE in their default kernel recently.<\/p>\n<p>Googling for \"PAE performance effects\" was not easy, and that's the main reason I wrote this article: to spread the knowledge. Best articles I've found are specified at the bottom.<\/p>\n<p><span style=\"color: #888888;\"><strong>My research conclusions, then:<\/strong><\/span><\/p>\n<ol>\n<li>Main reason for PAE being disabled by default, seems to be hardware compatibility: hardware with no PAE support can't boot a PAE-enabled kernel. <strong>That's mostly history now<\/strong>, anyway, for all recent x86 processors support PAE.<\/li>\n<li><strong>Performance penalty is very low<\/strong> (according to RedHat average is 1% and no more than 10%). Of course it depends on your exact scenarios, etc etc.<\/li>\n<li>As a friend suggested me:<strong> in most cases PAE is not needed,<\/strong> for x86-64 is so widely spread. One can simply run his 32bit apps on a 64bit OS. PAE lets the OS see up to 64GB, while x86-64 (current implementations) lets the OS see at least 16TB! So my main conclusion is.. that <strong>PAE is dead<\/strong>. All modern x86 processors (since ~year 2006) have x86-64 support.<\/li>\n<li>Best thing is compiling your code as 64bit and running a 64bit OS, of course \ud83d\ude42<\/li>\n<\/ol>\n<p><strong><span style=\"color: #888888;\">Accessing beyond the 4GB on 32bit mode<\/span><\/strong><\/p>\n<p>According to the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Physical_Address_Extension\">PAE article on Wikipedia<\/a>, there are ways for accessing areas of RAM beyond the regular 4GB of virtual address space. Looks like Windows has a nice API for that: <a title=\"Wikipedia AWE article\" href=\"http:\/\/en.wikipedia.org\/wiki\/Address_Windowing_Extensions\">Address Windowing Extention<\/a>, and Linux is able to do it with <em>mmap()<\/em> system call. I couldn't figure out how, though. Any idea? \ud83d\ude42<\/p>\n<p><span style=\"color: #888888;\"><strong>References<\/strong><\/span><\/p>\n<ol>\n<li><a href=\"http:\/\/people.redhat.com\/nmurray\/RHEL-2.1-VM-whitepaper.pdf\">RedHat article<\/a> by Bob Matthews &amp; Norm Murray: page 9, last paragraph till page 10.<\/li>\n<li><a href=\"http:\/\/wiki.novell.com\/index.php\/Memory_over_3GB_on_NetWare#How_PAE_works\">Novell NetWare article<\/a> which seems relevant.<\/li>\n<\/ol>\n<p>Phewww. My longest post so far, I think \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Err, what&#8217;s PAE? PAE (Physical Address Extension) is a &#8220;workaround&#8221; for letting x86-32bit(!) OS see more than 4GB of RAM. 4GB is the limit for 32bit memory addresses. PAE is not needed and not implemented on x86-64 processors when 64 bit (&#8220;long mode&#8221;) is enabled. How does it work? In short, it simply adds 4 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[203,83,95,127],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/79"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}