Nicholas Nethercote: A better DHAT |
DHAT is a heap profiler that comes with Valgrind. (The name is short for “Dynamic Heap Analysis Tool”.) It tells your where all your heap allocations come from, and can help you find the following: places that cause excessive numbers of allocations; leaks; unused and under-used allocations; short-lived allocations; and allocations with inefficient data layouts. This old blog post goes into some detail.
In the new Valgrind 3.15 release I have given DHAT a thorough overhaul.
The old DHAT was very useful and I have used it a lot while profiling the Rust compiler. But it had some rather annoying limitations, which the new DHAT overcomes.
First, the old DHAT dumped its data as text at program termination. The new DHAT collects its data in a file which is read by a graphical viewer that runs in a web browser. This gives several advantages.
Second, the old DHAT divided its output into records, where each record consisted of all the heap allocations that have the same allocation stack trace. The choice of stack trace depth could greatly affect the output.
In contrast, the new DHAT is based around trees of stack traces that avoid the need to choose stack trace depth. This avoids both the problem of not enough depth (when records that should be distinct are combined, and may not contain enough information to be actionable) and the problem of too much depth (when records that should be combined are separated, making them seem less important than they really are).
Third, the new DHAT also collects and/or shows data that the old DHAT did not.
Finally, the new DHAT has a better handling of realloc
. The sequence p = malloc(100); realloc(p, 200);
now increases the total block count by 2 and the total byte count by 300. In the old DHAT it increased them by 1 and 200. The new handling is a more operational view that better reflects the effect of allocations on performance. It makes a significant difference in the results, giving paths involving reallocation (e.g. repeated pushing to a growing vector) more prominence.
Overall these changes make DHAT more powerful and easier to use.
The following screenshot gives an idea of what the new graphical viewer looks like.
The new DHAT can be run using the --tool=dhat
flag, in contrast with the old DHAT, which was an “experimental” tool and so used the --tool=exp-dhat
flag. For more details see the documentation.
https://blog.mozilla.org/nnethercote/2019/04/17/a-better-dhat/
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |