Closed Bug 558200 Opened 10 years ago Closed 6 years ago

Extension profiling mechanism for profiling bad things caused by JS


(Firefox Build System :: Source Code Analysis, defect)

Not set


(Not tracked)



(Reporter: taras.mozilla, Assigned: sfink)



(Whiteboard: [ts])


(1 file, 1 obsolete file)

sewardj helped me come up with an "easy" way to measure addon overhead. Using hooks like this provided in bug 507012, we can measure when we leave js code and call into c++(or just more js code).
The trick is to use a log to log every known expensive operation(ie nspr read operations, sqlite queries, reflows, xpconnect crossings). 
Then from the pre-execution hook one would mark the current position in the log, exit the hook. Then the post-execution hook would compare the current log position and record that particular function call as expensive.

This isn't meant to be a cheap profiling mechanism. The aim to run firefox with any given extension(or chrome js code) in a special mode that would provide a report of things that it does badly.
Whiteboard: [ts]
Blocks: 550242
OS: Linux → All
Hardware: x86 → All
tomcat has a system for doing quick tests on addons to do santity checks and find basic problems, and the "addon verifier" is run to look for evil code patterns in addon js.

Those are two possible places where a tool like this might be plugged in or experimented with.
This bug has some overlap with bug 480735 - perhaps a timer JS API is needed so ext devs can hook into our startup timeline?
(In reply to comment #1)
> tomcat has a system for doing quick tests on addons to do santity checks and
> find basic problems, and the "addon verifier" is run to look for evil code
> patterns in addon js.

yeah, just need some information what kind of addons we want to test (like the top x addons) or special kind addons (like as example toolbars etc)
Assignee: nobody → sphink
Depends on: 580063
A prototype of one cut of this is available at

Comments welcome.
Fantastically sweet.  I especially dig the SVG graph!

It might be helpful to target your data output at the GWT SpeedTracer UI before going much further on the UI.  They have a documented dump format and their UI is very polished, which I think would be useful to help polish and/or filter the data you generate.  Additionally, when I blogged about using SpeedTracer on mozilla (using systemtap-sourced data), the GWT lead seemed very willing to help me if I wanted to pursue things further.

The dump format:

The template I used to make the speedtracer extension want to open my files:

My blog post for greater context:

Note that I'm not advocating for long-term usage of SpeedTracer; I just think it's a great existing resource.  (Both ideologically and from a community resources perspective, I think it would be preferable to use a written-in-JS rather than compiled-to-JS solution.)
Ah, yes. Thank you for those posts! I had already read those a couple of months ago, and even played with it a little. I fully agree with your conclusions: (1) SpeedTracer seems like the best thing out there for a first cut at visualizing detailed performance data; and (2) it's not a great long-term solution because of the GWT layer.

But this bug is more targeted. It's about an in-browser mechanism that produces some sort of "bad behavior" report for an extension. Requiring SpeedTracer as a dependency is really stretching the builtin-ish nature of the request.

Note that the current implementation requires an external script to process the log files, and so is equally inadequate. I'm slowly working on porting it to a more internal solution. But yes, you are right that I shouldn't bother with much more UI stuff.

I should file a bug on the SpeedTracer (or equivalent) integration, since I would really like to get something like that as well.


I also followed your blog links to your earlier systemtap work, which is something else I'm working on. You've got some great stuff there that I wish I'd known about earlier. I'm surprised you didn't run into bug 574403.

Oh! You probably weren't using --enable-dtrace, were you? You don't care about the USDT probes.
Attaching the current version of my processing script here so I can point to it from
Minor formatting tweak, switch most time units to fractional ms instead of us.
Attachment #482326 - Attachment is obsolete: true
I never really deployed this anywhere, and it has long since bitrotted away, I'm sure.
Closed: 6 years ago
Resolution: --- → WONTFIX
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.