{"id":848,"date":"2011-05-31T14:06:23","date_gmt":"2011-05-31T03:06:23","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=848"},"modified":"2011-05-31T14:06:23","modified_gmt":"2011-05-31T03:06:23","slug":"you-lose-more-when-slow-than-you-gain-when-fast","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2011\/05\/31\/you-lose-more-when-slow-than-you-gain-when-fast\/","title":{"rendered":"You lose more when slow than you gain when fast"},"content":{"rendered":"<p>SpiderMonkey is Firefox&#8217;s JavaScript engine.\u00a0 In Firefox 3.0 and earlier versions, it was just an interpreter.\u00a0 In Firefox 3.5, a tracing JIT called TraceMonkey was added.\u00a0 TraceMonkey was able to massively speed up certain parts of programs, such as tight loops;\u00a0 parts of programs it couldn&#8217;t speed up continued to be interpreted.\u00a0 TraceMonkey provided large speed improvements, but JavaScript performance overall still didn&#8217;t compare that well against that of Safari and Chrome, both of which used method JITs that had worse best-case performance than TraceMonkey, but much better worst-case performance.<\/p>\n<p>If you look at the numbers, this isn&#8217;t so surprising.\u00a0 If you&#8217;re 10x faster than the competition on half the cases, and 10x slower on half the cases, you end up being 5.05x slower overall.\u00a0 Firefox 4.0 added a method JIT, JaegerMonkey, which avoided those really slow cases, and Firefox&#8217;s JavaScript performance is now very competitive with other browsers.<\/p>\n<p>The take-away message:\u00a0 <em>you lose more when slow than you gain when fast.<\/em> Your performance is determined primarily by your slowest operations.\u00a0 This is true for two reasons.\u00a0 First, in software you can easily get such large differences in performance: 10x, 100x, 1000x and more aren&#8217;t uncommon.\u00a0 Second, in complex programs like a web browser, overall performance (i.e. what a user feels when browsing day-to-day) is determined by a huge range of different operations, some of which will be relatively fast and some of which will be relatively slow.<\/p>\n<p>Once you realize this, you start to look for the really slow cases. You know, the ones where the browser slows to a crawl and user starts cursing and clicking wildly and holy crap if this happens again I&#8217;m switching to another browser.\u00a0 Those are the performance effects that most users care about, not whether their browser is 2x slower on some benchmark.\u00a0 When they say &#8220;it&#8217;s really fast&#8221;, the probably actually mean &#8220;it&#8217;s never really slow&#8221;.<\/p>\n<p>That&#8217;s why memory leaks are so bad &#8212; because they lead to paging, which utterly destroys performance, probably more than anything else.<\/p>\n<p>It also makes me think that the single most important metric when considering browser performance is page fault counts.\u00a0 Hmm, I think it&#8217;s time to look again at <a href=\"http:\/\/blog.mozilla.org\/jseward\/2011\/01\/27\/profiling-the-browsers-virtual-memory-behaviour\/\">Julian Seward&#8217;s VM profiler<\/a> and the Linux <a href=\"https:\/\/perf.wiki.kernel.org\/index.php\/Main_Page\">perf<\/a> tools.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SpiderMonkey is Firefox&#8217;s JavaScript engine.\u00a0 In Firefox 3.0 and earlier versions, it was just an interpreter.\u00a0 In Firefox 3.5, a tracing JIT called TraceMonkey was added.\u00a0 TraceMonkey was able to massively speed up certain parts of programs, such as tight loops;\u00a0 parts of programs it couldn&#8217;t speed up continued to be interpreted.\u00a0 TraceMonkey provided large [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,4544,311,467],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/848"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}