Using XPerf

From MozillaWiki
Jump to: navigation, search

Note: This page is not for general xperf use. It is specific to the ETW integrated into SpiderMonkey, and is currently a disorganized collection of notes while I figure out what all this crazy stuff is.

Oh, and it turns out there is already an xperf usage page on MDC:

Random Notes

  • To use custom events like the MozillaSpiderMonkey provider ones, you will start a session using that provider, and then probably start an additional concurrent session for the kernel events of interest. You will merge the event logs together at the end before analyzing them.
  • xperf start command syntax: starts multiple sessions at once (but maybe at most one kernel?)
 xperf -on latency -start sess1 -on MozillaSpiderMonkey

will start a kernel session with the 'latency' group of events, and a user session 'sess1' with the MozillaSpiderMonkey provider's events.


 xperf -stop sess1 -stop

will stop both the kernel session and the user session 'sess1'.

  • Seeing what sessions are logging (?):
 xperf -Loggers | grep Name

will dump out all active loggers. There will be several that you didn't start.

Or, the nice way: run perfmon. Go to "Data Collector Sets"/"Event Trace Sessions". The names here even make sense!

  • when xperf stops a trace, it injects some custom information (string event names?) into the trace to allow cross-machine decoding (so a manifest is not needed), but only xperf knows how to read that data.

Installation Notes

logman, tracerpt, wevtutil, and mofcomp are all installed by default on Windows. (wevtutil only exists for Vista+.)

xperf and xperfview come with the SDK. You can also get a standalone installation from

On a 64-bit system, to allow stack traces:

REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" -v DisablePagingExecutive -d 0x1 -t REG_DWORD -f

and reboot.

wevtutil im path/to/ -rf:c:/windows/path/to/firefox.exe

or perhaps path to ETWProvider.res. (asuth says: I think for the "rf" setting you want to point at your mozjs.dll (or whatever it has been lumped into) since that's what the manifest defines as the resourceFileName. At least, when I did this, it no longer gave an error message about resources not being accessible.)


xperf -start test1 -on MozillaSpiderMonkey
dist/bin/firefox.exe -no-remote -P Blank ...
xperf -stop test1

(do stuff)
xperf -d foo.etl
xperfview foo.etl


 xperf -on Latency -stackwalk profile -start browse -on MozillaSpiderMonkey:::'stack'
 rem Your scenario goes here...
 xperf -stop browse -stop -d mytrace.etl

using logman:

 logman start mysession -p MozillaSpiderMonkey -o test1.etl -ets
 logman stop mysession -ets


 tracerpt events.etl -import path/to/

will generate dump files of the traces. Very useful for figuring out whether your data got logged. But it seems to mismatch the descriptive strings -- I am getting my provider message ("Event traces for Mozilla SpiderMonkey (Javascript engine)") in place of all event names. The OpCodes are fortunately getting the right names, which is really the most useful thing anyway.

You can't do much with custom events in the current xperfview:

More Links

This page covers XP and Windows 7 registration, and talks about logman and tracerpt, which are both nice and simple and just about all I can understand right now.

Description of profiling IE, including some IE ETW providers. (We might want to borrow their event sets...)