Performance

This page explains how optimize the performance the Firefox code base

The test documentation explains how to test for performance in Firefox. The profiler documentation explains how to use the Gecko profiler.

General Performance references

Memory profiling and leak detection tools

  • The Developer Tools Memory panel supports taking heap snapshots, diffing them, computing dominator trees to surface “heavy retainers”, and recording allocation stacks.

  • About:memory about:memory is the easiest-to-use tool for measuring memory usage in Mozilla code, and is the best place to start. It also lets you do other memory-related operations like trigger GC and CC, dump GC & CC logs, and dump DMD reports. about:memory is built on top of Firefox’s memory reporting infrastructure.

  • DMD is a tool that identifies shortcomings in about:memory’s measurements, and can also do multiple kinds of general heap profiling.

  • AWSY (are we slim yet?) is a memory usage and regression tracker.

  • Bloatview prints per-class statistics on allocations and refcounts, and provides gross numbers on the amount of memory being leaked broken down by class. It is used as part of Mozilla’s continuous integration testing.

  • Refcount Tracing and Balancing are ways to track down leaks caused by incorrect uses of reference counting. They are slow and not particular easy to use, and thus most suitable for use by expert developers.

  • GC and CC Logs

  • Leak Gauge can be generated and analyzed to in various ways. In particular, they can help you understand why a particular object is being kept alive.

  • LogAlloc is a tool that dumps a log of memory allocations in Gecko. That log can then be replayed against Firefox’s default memory allocator independently or through another replace-malloc library, allowing the testing of other allocators under the exact same workload.

  • See also the documentation on Leak-hunting strategies and tips.

Profiling and performance tools

Power Profiling

  • An overview of power profiling. It includes details about hardware, what can be measured, and recommended approaches. It should be the starting point for anybody new to power profiling.

  • (Mac, Linux) tools/power/rapl is a command-line utility in the Mozilla codebase that uses the Intel RAPL interface to gather direct power estimates for the package, cores, GPU and memory.

  • (Mac-only) powermetrics is a command-line utility that gathers and displays a wide range of global and per-process measurements, including CPU usage, GPU usage, and various wakeups frequencies.

  • (All-platforms) TimerFirings logging is a built-in logging mechanism that prints data on every time fired.

  • (Mac-only) Activity Monitor and top The battery status menu, Activity Monitor and top are three related Mac tools that have major flaws but often consulted by users, and so are worth understanding.

  • (Windows, Mac and Linux) Intel Power Gadget Intel Power Gadget provides real-time graphs for package and processor RAPL estimates. It also provides an API through which those estimates can be obtained.

  • (Linux only) perf perf is a powerful command-line utility that can measure many different things, including energy estimates and high-context measurements of things such as wakeups.

  • (Linux-only) turbostat is a command-line utility that gathers and displays various power-related measurements, with a focus on per-CPU measurements such as frequencies and C-states.

  • (Linux-only) powertop is an interactive command-line utility that gathers and displays various power-related measurements.