Logging Firefox memory allocations
A couple years ago, when I was actively working on integrating jemalloc 3 in the Firefox build, and started investigating some memory usage regression compared to our old fork, I came up with a replace-malloc library for Firefox that would log all the allocations, and allow to replay them in a more consistent (and faster) way in a separate program, such that testing different configurations of jemalloc with the same workload can be streamlined.
A couple weeks ago, I refreshed that work, and made it work on all the tier-1 Firefox desktop platforms. That work is now in the tree instead of on my hard drive, and will allow us to test the effects of jemalloc changes in a better way.
The bulk of how to use this feature is the following:
- Start Firefox with the following environment variables:
- on Linux:
LD_PRELOAD=/path/to/memory/replace/logalloc/liblogalloc.so
- on Mac OSX:
DYLD_INSERT_LIBRARIES=/path/to/memory/replace/logalloc/liblogalloc.dylib
- on Windows:
MOZ_REPLACE_MALLOC_LIB=/path/to/memory/replace/logalloc/logalloc.dll
- on all the above:
MALLOC_LOG=/path/to/log-file
- on Linux:
- Play your workload in Firefox, then close it.
- Run the following command to prepare the log file for replay:
python /source/path/to/memory/replace/logalloc/replay/logalloc_munge.py < /path/to/log-file > /path/to/replay.log
- Replay the logged allocations with the following command:
/path/to/memory/replace/logalloc/replay/logalloc-replay < /path/to/replay.log
More information and implementation details can be found in the README accompanying the code for that functionality.
2014-12-03 03:22:57+0900
You can leave a response, or trackback from your own site.