upvote
It samples the heap via Poisson sampling (https://perfetto.dev/docs/design-docs/heapprofd-sampling) so that large allocations are certain to be sampled and small allocations are more likely to be dropped.

If you do play around with the config directly, you can actually configure a "track all allocaitons" mode but in practice this is not super useful: either you end up slowing the device to a complete crawl or you drop lots of data as you just cannot keep up. [1]

In practice, we've found a sampling of 4096 (the default) to provide a very good tradeoff between accuracy and performance.

[1] The option is called `sampling_interval_bytes` and, as the documentation describes (https://perfetto.dev/docs/reference/trace-config-proto#Heapp...), setting it to `1` means perfect accuracy. You usually will also want `block_client` so that the data isn't dropped (but as noted there it slows down the device a lot).

reply
Ah, neat, I will play around with this! I am generally ok with Poisson sampling but there are some cases where I'm trying to correlate specific allocations to each other (for example, a code path where I am trying to check that it does in fact make exactly n of a certain object) where I am ok with running things slower, so I'll try this to see if it can help.
reply