~robcee/ more than just sandwiches

Posted
15 December 2009 @ 5pm

Tagged
Firebug, Mozilla

Firebug and the JIT

One thing we hear a lot from Firebug users is that Firebug slows down Firefox. When Firebug is active, particularly when you’ve enabled the Console/Script panels, some pages perform much more slowly. Enabling these panels turns on all of our debugging hooks, so some slowdown isn’t surprising, but what may surprise you is that, in order to get accurate debugging information, these hooks also turn off Firefox’ high-performance Javascript JIT compiler, even when Firebug is inactive. And now we have a fix for that.

First, a little terminology. Feel free to skip this paragraph if you consider yourself a master of Javascript internals or compiler run-time optimization makes your skin crawl. Tracing is the mechanism Firefox’ Javascript engine (aka, “SpiderMonkey”) uses to improve code execution performance. It provides a major speedup for code running in Firefox 3.5 and up, often an order of magnitude for certain types of operations. It is the basis of the JIT or Just-in-Time compiler. Without tracing, the JS engine can’t optimize code as well, leading to significantly slower execution.

I need to be clear here: If you have Firebug installed you are probably not getting fast Javascript. Firebug doesn’t have to be active on your current page. If you have the grey icon on your status bar, you have probably disabled the JIT. This is true if you have ever enabled the Console and consequently the Script panels and left them on. This is likely true for most recent versions of Firebug. The quick fix is to disable the Script and Console panels via the mini menu on their respective tabs.

Boris Zbarsky has been doing a lot of poking around in the belly of the JS debugger lately. Working in conjunction with John Barton, they have concocted fixes for the soon-to-be-released Firebug 1.5 and Firefox 3.6. We’re working to get testable versions out as quickly as possible, but I can say that I’ve tested development builds using the pages mentioned in the bug and can verify that these fix the problem. As a side-benefit, I got to watch Boris dissect the problem through gdb in an Xterm (yes, an Xterm) and Emacs and it was pretty impressive and fun, to boot.

When installing Firebug one of the first things most people do is enable the Console. It’s such a useful debugging tool. I myself have been using Firebug for over a year without JITted code. I probably never noticed the slowdown simply because I’m so used to running my browser this way and have pretty fast machines. After disabling the Console and Script panels there are a few pages that just load much much quicker. It’s kind of shocking.

Since the patch has landed on Firefox 3.6, I’m expecting either a beta or release candidate of that to come out shortly. I’m also hoping for another Firebug beta (or release candidate) later this week. In the meantime, if you’re not using them, I recommend disabling the Console and Script panels and find out what you’ve been missing and turn them on only as-needed. This will likely be the work-around for Firefox 3.5 users unless we decide to push this back to that branch but I have my doubts that this is something we would do.


14 Comments

Posted by
Simon
15 December 2009 @ 8pm

Interesting… that might explain a few performance issues I’ve seen…


Posted by
F1LT3R
15 December 2009 @ 9pm

This is great news!


Posted by
Ricardo Vega
15 December 2009 @ 9pm

Greeeeat news! This is really a great improvement :D


Posted by
Roland Bouman
15 December 2009 @ 11pm

Hey, this is great news!

Firebug/Firefox is still the best web development platform for me. And if js performance goes up with this fix…who knows, firefox may become my favorite casual brower again too.

Roland


Posted by
Navneet
16 December 2009 @ 3am

I am using Firebug 1.3.3 for the same reason.
Firebug 1.4.x causes drastic slowness when the net panel is enabled


Posted by
Mathis Fenne
16 December 2009 @ 9am

Hey. This is good news. We use firebug a lot when creating front-end solutions for our customers, and we have had some issues with performance :)


Posted by
Dao
16 December 2009 @ 3pm

“It provides a major speedup for code running in Firefox 3.0 and up, often an order of magnitude for certain types of operations.”

Not in 3.0, 3.5 was the first release featuring TraceMonkey.


Posted by
robcee
16 December 2009 @ 3pm

thanks for the correction, Dao. Updated the post.


Posted by
schnalle
16 December 2009 @ 6pm

recently i implemented an a* search (just for fun). benchmarks made me cry – google chrome is almost 10 times as fast as firefox 3.5.5 (naive benchmarking across a 200×200 matrix, ff takes ~3sec, chrome ~250ms).

and i thought ffs tracing jit would shine here, because it’s nothing more than some tight loops.

when i read your article, the problem was clear. so i completely deactivated the firebug addon (just to be sure), restarted the browser and … no noticeable difference.


Posted by
robcee
16 December 2009 @ 7pm

@schnalle: Would you consider posting a link to your benchmark? I know some people who might like to take a look at it.


Posted by
schnalle
16 December 2009 @ 8pm

um, actually i implemented it today (it’s a dirty hack). not a real benchmark.

i added the numbers from my system; seems i made a mistake in me previous post. deactivating FF does speed things up, from ~3.1s to ~2.4s. still i wonder: why is the difference tracemonkeys tracing JIT makes so small?

heres the demo:
http://jsastar.tapirpirates.net/


Posted by
robcee
16 December 2009 @ 9pm

thanks for pointing us to this. It’s currently fixed on trunk and I was seeing times of 250ms (compared to 7200ms) on my machine.

I filed https://bugzilla.mozilla.org/show_bug.cgi?id=535436 to track the regression. Hopefully we’ll get this into 3.6 before ship.


[...] Firebug slows down JavaScript even if it’s not active on the current page. That explains a LOT! # Facebook & Gmail run [...]


Posted by
Marcus
12 May 2010 @ 7pm

I was under the impression in Firefox 3.6 and Firebug 1.5 this issue was fixed.
However with the Firebug console and script panel enabled I’m getting over 40ms
on http://people.mozilla.com/~vladimir/ss/hosted/bitops-bitwise-and.html,
but with disabled I’m getting less than 5ms.

Firefox 3.6.4
Firebug 1.5.4

Can you offer any insight?