{"id":1762,"date":"2011-02-11T16:22:09","date_gmt":"2011-02-11T15:22:09","guid":{"rendered":"http:\/\/glandium.org\/blog\/?p=1762"},"modified":"2011-02-11T16:22:09","modified_gmt":"2011-02-11T15:22:09","slug":"preloading-reloaded","status":"publish","type":"post","link":"https:\/\/glandium.org\/blog\/?p=1762","title":{"rendered":"Preloading, reloaded"},"content":{"rendered":"<p>As <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=632404#c5\">David Baron reminded me<\/a> in the corresponding bug, the <a href=\"https:\/\/bug632404.bugzilla.mozilla.org\/attachment.cgi?id=510621\">stupid preloading trick<\/a> is just too stupid, and would actually severely impact builds with debugging symbols, as these would be preloaded as well. And debugging symbols on libxul.so are pretty massive (several hundreds of megabytes vs. around twenty without).<\/p>\n<p>So I came up with a <a href=\"https:\/\/bugzilla.mozilla.org\/attachment.cgi?id=511329\">smarter preloader<\/a> that would only load the more or less relevant parts (all those that the dynamic linker would load), and use the <code>readahead()<\/code> system call instead of <code>read()<\/code>.<\/p>\n<p>The latter has a double advantage: it limits the number of system calls (<code>cat<\/code> would read by 32KB chunks), and it avoids copying memory from the page cache to a memory buffer to <code>write()<\/code> it to <code>\/dev\/null<\/code>, because <code>readahead()<\/code> only populates the page cache without returning anything to userspace.<\/p>\n<p>And as such, it makes preloading even (slightly) faster.<\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2011\/02\/preload_libs_reloaded.png\" style=\"border: 0\" \/><\/p>\n<table class=\"table\">\n<tr>\n<th><\/th>\n<th>x86<\/th>\n<th>x86-64<\/th>\n<\/tr>\n<tr>\n<th>4.0b8<\/th>\n<td>3,228.76 \u00c2\u00b1 0.57%<\/td>\n<td>3,382.0 \u00c2\u00b1 0.51%<\/td>\n<\/tr>\n<tr>\n<th>4.0b8 with preload<\/th>\n<td>2,347.18 \u00c2\u00b1 0.67%<\/td>\n<td>2,709.82 \u00c2\u00b1 0.54%<\/td>\n<\/tr>\n<tr>\n<th>Difference<\/th>\n<td>881.58 (27.30%)<\/td>\n<td>672.18 (19.86%)<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<th>4.0b8 with better preload<\/th>\n<td>2,231.16 \u00c2\u00b1 0.73%<\/td>\n<td>2,636.76 \u00c2\u00b1 0.42%<\/td>\n<\/tr>\n<tr>\n<th>Difference<\/th>\n<td>997.6 (30.89%)<\/td>\n<td>745.24 (22.04%)<\/td>\n<\/tr>\n<\/table>\n<p>When <a href=\"\/blog\/?p=1719\">I first talked about this stupid hack<\/a>, I mentioned this wouldn't work on OSX, since we are using (fat) universal binaries. Well, with an approach like this one, we should be able to only load the parts relevant to the runtime architecture. In the course of next week, I'll check if that would work out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As David Baron reminded me in the corresponding bug, the stupid preloading trick is just too stupid, and would actually severely impact builds with debugging symbols, as these would be preloaded as well. And debugging symbols on libxul.so are pretty massive (several hundreds of megabytes vs. around twenty without). So I came up with a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[23],"class_list":["post-1762","post","type-post","status-publish","format-standard","hentry","category-planet-mozilla","tag-en"],"_links":{"self":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1762"}],"version-history":[{"count":21,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1762\/revisions"}],"predecessor-version":[{"id":1793,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1762\/revisions\/1793"}],"wp:attachment":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}