Skip to content
Anthony Ramine edited this page May 24, 2016 · 15 revisions

First, ensure that you are building Servo in release (optimized) mode:

 ./mach build --release

Three ways to get profiling information about Servo's runs:

##Interval Profiling

Using the -p option followed by a number (time period in seconds), you can spit out profiling information to the terminal periodically. To do so, run Servo on the desired site (URLs and local file paths are both supported) with profiling enabled:

 ./mach run --release -p 5 https://www.cnn.com/

In the example above, while Servo is still running (AND is processing new passes), the profiling information is printed to the terminal every 5 seconds.

Once the page has loaded, hit ESC (or close the app) to exit. Profiling output will be provided, broken down by area of the browser and URL. For example, if you would like to profile loading Hacker News, you might get output of the form below:

[larsberg@lbergstrom servo]$ ./mach run --release -p 5 http://news.ycombinator.com/
_category_                          _incremental?_ _iframe?_             _url_                  _mean (ms)_   _median (ms)_      _min (ms)_      _max (ms)_       _events_ 
Compositing                             N/A          N/A                  N/A                        0.0440          0.0440          0.0440          0.0440               1
Layout                                  no           no      https://news.ycombinator.com/          29.8497         29.8497         29.8497         29.8497               1
Layout                                  yes          no      https://news.ycombinator.com/          11.0412         10.9748         10.8149         11.3338               3
+ Style Recalc                          no           no      https://news.ycombinator.com/          22.8149         22.8149         22.8149         22.8149               1
+ Style Recalc                          yes          no      https://news.ycombinator.com/           5.3933          5.2915          5.2727          5.6157               3
+ Restyle Damage Propagation            no           no      https://news.ycombinator.com/           0.0135          0.0135          0.0135          0.0135               1
+ Restyle Damage Propagation            yes          no      https://news.ycombinator.com/           0.0146          0.0149          0.0115          0.0175               3
+ Primary Layout Pass                   no           no      https://news.ycombinator.com/           3.3569          3.3569          3.3569          3.3569               1
+ Primary Layout Pass                   yes          no      https://news.ycombinator.com/           2.8727          2.8472          2.8279          2.9428               3
| + Parallel Warmup                     no           no      https://news.ycombinator.com/           0.0002          0.0002          0.0002          0.0002               2
| + Parallel Warmup                     yes          no      https://news.ycombinator.com/           0.0002          0.0002          0.0001          0.0002               6
+ Display List Construction             no           no      https://news.ycombinator.com/           3.4058          3.4058          3.4058          3.4058               1
+ Display List Construction             yes          no      https://news.ycombinator.com/           2.6722          2.6523          2.6374          2.7268               3

In this example, when loading the page we performed one full layout and three incremental layout passes, for a total of (29.8497 + 11.0412 * 3) = 62.9733ms.

CSV Profiling

Using the -p option followed by a file name, you can spit out profiling information of Servo's execution to a CSV file. The information is written to the file only upon Servo's termination. This works well with the -x OR -o option so that performance information can be collected during automated runs. Example usage:

./mach run -r -o out.png -p out.csv https://www.google.com/

The formats of the profiling information in the Interval and CSV Profiling options are the essentially the same; the url names are not truncated in the CSV profiling option.

Generating Timelines

Add the --profiler-trace-path=/timeline/output/path.html flag to output the profiling data as a self contained HTML timeline. Because it is a self contained file (all CSS and JS is inline), it is easy to share, upload, or link to from bug reports.

$ ./mach run --release -p 5 --profiler-trace-path=trace.html https://reddit.com/

Profiler trace output

Usage:

  • Use the mouse wheel or trackpad scrolling, with the mouse focused along the top of the timeline, to zoom the viewport in or out.

  • Grab the selected area along the top and drag left or right to side scroll.

  • Hover over a trace to show more information.

Hacking

Code is in the components/profile/ directory.

Comparing Servo Layout to Gecko

There are no direct performance counters for the layout code in Gecko. Instead, use a sampling profiler (e.g., Instruments.app on OSX or perf on Linux) and sum the time spent in the Reflow* methods.

Comparing Servo Layout to Chrome

There are no direct performance counters for the layout code in Chrome. Instead, use a sampling profiler (e.g., Instruments.app on OSX or perf on Linux) and sum the time spent in the layout* methods.

Clone this wiki locally