DTrace Mozilla - [RFE] JavaScript Tracing Framework landed :)

Happy days again - the Javascript framework patch [#388564] for Javascript tracing in mozilla has landed in CVS head :)

It's already being actively used:

"No problem -- dtrace has been a huge help for us, from what I can see. Sayre has been helping front-end hackers identify JS performance problems with it, which would be hard to find otherwise." Brendan Eich

"I don't think I can work on Mozilla without DTrace ever again. Too useful." Land of DTrace, Robert Sayre

Mike Shaver nominated the dtrace team at Sun "for giving us the first good tool we've ever had for understanding front-end performance." - Thanks Mike :)

Here are a few of the bugs it's already helped with, thanks to Robert Sayre's enthusiastic evangelism , cheers Robert :)

[#398300] instantiates livemark service on startup
[#398360] speed up onSecurityChange
[#398950] contentprefsink event registration
[#398344] utilityOverlay.js isElementVisible() is slow

I've built this from head on nevada build 74, having applied the gtk patch disconnect_handlers_and_prevent_unloading_v1.1 Unfortunately Firefox is now crashing in pango font hanlding, unrelated to the probe work :( Apparently this is ok in build 75 onwards, thanks again to Ginn Chen for the info, so will upgrade today and see how we get on. Also noticed that Johnny had to change some of the build framework to land the JavaScript patch and this has now broken the load probes patch. Ah well, bit more work for me ...

I've included some info on the JavaScript probes below. There are plenty of DTrace examples using the probes in the new 0.99 DTraceToolkit Brendan has just posted. Just unzip and look under the JavaScript subdirectory, I've referred to some of them below.

javascript provider probes

javascript\*:::function-entry  
    Args: (char \*filename, char \*classname, char \*funcname)
javascript\*:::function-return   
    Args: (char \*filename, char \*classname, char \*funcname)

The probe function-entry fires when a JavaScript function begins to execute. The probe, function-return, fires when the function completes. The probe arguments are still being designed, for now arg0 is a the file pathname, arg1 is a classname (if available), and arg2 is the function name. [See js_calls.d, js_calltime.d, js_calldist.d, js_flow.d, js_flowtime.d, js_stat.d, js_who.d]

javascript\*:::function-info     
    Args: (char \*filename, char \*classname, char \*funcname, int lineno, char \*runfilename, int runlineno)

Used to get line number information. The function-info probe is best for anonymous function tracing - since it gives line numbers for identifying the anonymous function location. [See js_flowinfo.d]

javascript\*:::function-args    
    Args: (char \*filename, char \*classname, char \*funcname, int argc, void \*argv, void \*argv0,
                     void \*argv1, void \*argv2, void \*argv3, void \*argv4)
javascript\*:::function-rval      
    Args: (char \*filename, char \*classname, char \*funcname, int lineno, void \*rval, void \*rval0)

So function-args was to provide some debugging visibility for function arguments; and function-rval was for the return value. [No examples in the toolkit as these are still  experimental].
Status: args & rval currently return zero args in error, when in-built methods hit a new performance optimization in the JS engine.  It needs fixing.  If you try using them now, you'll see that they mostly work (especially for your own functions).

javascript\*:::object-create      
    Args: (char \*filename, char \*classname, uintptr_t \*object, int rlineno)

Fires when a JavaScript object has been fully created. [See js_objgc.d]

javascript\*:::object-create-start
    Args: (char \*filename, char \*classname)
javascript\*:::object-create-done
    Args: (char \*filename, char \*classname)

Matching probes can be used to time object creation. [See js_calltime.d, js_cpudist.d, js_objcpu.d]

javascript\*:::object-finalize  
    Args: (NULL, char \*classname, uintptr_t \*object)

Fires when an object is garbage collected. [See js_objgc.d]

javascript\*:::execute-start 
    Args: (char \*filename, int lineno)
javascript\*:::execute-done  
    Args: (char \*filename, int lineno)

These trace when a JavaScript program or block of code begins execution and ends. [See js_execs.d]


Comments:

Post a Comment:
Comments are closed for this entry.
About

jmr

Search

Top Tags
Categories
Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today