Tracing Firefox Memory Allocation with eBPF
2025-05-31
The author used eBPF (extended Berkeley Packet Filter) to trace memory allocation in SpiderMonkey, Firefox's JavaScript engine. The initial goal was to pinpoint the source locations of frequent Rooted object creations for memory management optimization. Using the bpftrace tool and user probes (uprobes), the author successfully traced the `registerWithRootLists` function and utilized the ustack function to get call stack information. Ultimately, the author generated reports and filed several bug reports, optimizing memory allocation and reducing tens of millions of calls to `registerWithRootLists`.
Development