tree: 5c1b53f878ddb283df6479f857e7a0c039c528be [search]
  1. palloc_viewer/
  2. BUILD.gn
  3. compute_external_fragmentation.py
  4. compute_internal_fragmentation.py
  5. DEPS
  6. inspect_utils.cc
  7. inspect_utils.h
  8. inspect_utils_linux.cc
  9. inspect_utils_mac.cc
  10. objects_per_size.py
  11. OWNERS
  12. pa_buckets_inspect.cc
  13. pa_dump_heap.cc
  14. pa_graph_buckets.py
  15. pa_tcache_inspect.cc
  16. plot_bucket_stats.py
  17. plot_superpages.py
  18. profile_allocations.py
  19. README.md
  20. sectaskaccess_info.plist
  21. trace_utils.py
tools/memory/partition_allocator/README.md

PartitionAlloc tools

This directory contains tools useful to inspect, debug and optimize PartitionAlloc. In particular, pa_tcache_inspect is used to inspect a running Chrome instance, and report statistics on its thread caches.

pa_tcache_inspect

This tool displays data about any running Chrome process. The main constraint is that both the tool and the running instance have to be built at revisions where the allocator's layout is identical. For best results, it should be the same revision whenever possible.

It works by first identifying the address of the thread cache registry, then use it to find out all other data structures. They are then read from the remote process, and displayed live.

The tool must be able to read the remote process memory, which on some Debian configurations requires running:

sudo sh -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'

pa_dump_heap and plot_superpages.py

pa_dump_heap dumps the state of PartitionAlloc‘s heap (superpages, slot spans, buckets, and the pool’s ReservationOffsetTable) from a running Chrome process into a JSON file:

autoninja -C out/Default pa_dump_heap
out/Default/pa_dump_heap --pid=<PID> --json=output.json

plot_superpages.py parses this JSON dump and generates visualizations:

python3 tools/memory/partition_allocator/plot_superpages.py --json=output.json --output=output

GigaCage Occupancy Visualization (<output>_gigacage.png)

plot_superpages.py generates <output>_gigacage.png, displaying all superpages in the thread-cached root's pool (e.g. the 16 GiB BRP pool via ReservationOffsetTable) as a 2D grid (128 columns per row, 2 MiB per cell, 256 MiB per row), colored by state: Free, Normal Buckets, or Direct Mapped.