Closed
Bug 676724
(DMD)
Opened 13 years ago
Closed 12 years ago
DMD: A Valgrind tool to find dark matter
Categories
(Core :: General, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: n.nethercote, Assigned: n.nethercote)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file, 8 obsolete files)
(deleted),
patch
|
Details | Diff | Splinter Review |
[The following text is from bug 563700 comment 23]
I was thinking some more about how to get *serious* about hunting down all the heap-unclassified bytes.
You'd add instrumentation code to maintain a data structure that records 1 bit of information for every malloc'd byte. A 0 means "not reported", a 1 means "reported". You'd also add instrumentation code to record, for every heap block, the stack trace at its allocation point.
Then, you'd modify every heap memory reporter so that when it is queried, it sets the "reported" bits of all the heap bytes it counts.
Once about:memory was loaded, you'd iterate over all the heap blocks. Any heap block fully reported would be ignored. Any heap block partially or not-at-all reported would be recorded. You'd aggregate repeated stack traces for recorded heap blocks and present the stack traces in order so that the ones responsible for the most unreported bytes are shown first.
Also, while the memory reporters are doing their thing, you'd complain about any byte on the heap whose "reported" bit was set more than once -- such bytes are double-counted. You could print out its stack trace and the name of the reporter that was second to count it.
Tracking one-bit-per-byte metadata and per-heap-block stack traces is something that Valgrind excels at, BTW. A Valgrind tool that implemented this analysis would have to use its own heap allocator rather than jemalloc (that's just how Valgrind works), so it would have to be careful about the rounding up of request sizes, but it could definitely be made to work. Memory reporters would use client requests to tell the tool which bytes have been accounted for. A client request would also be used to tell the tool when all the memory reporters have been consulted.
Assignee | ||
Updated•13 years ago
|
Blocks: DarkMatter
Assignee | ||
Comment 1•13 years ago
|
||
In addition to the Valgrind tool, each memory reporter will have to be modified to include annotations that tell the tool which heap bytes have been accounted for. These annotations wouldn't be landed.
Assignee | ||
Updated•13 years ago
|
Summary: Write a Valgrind tool to accurately identify what's missing from about:memory's "heap-unclassified" value → Write a Valgrind tool to find dark matter
Comment 2•13 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #1)
> In addition to the Valgrind tool, each memory reporter will have to be
> modified to include annotations that tell the tool which heap bytes have
> been accounted for. These annotations wouldn't be landed.
Why not? If they're not landed, then:
* I have to patch FF to run the tool, and
* that patch probably will bitrot.
I presume this is something we're going to want to run every once in a while; it's not fix once and forget.
Assignee | ||
Comment 3•13 years ago
|
||
Well, let's see how intrusive they are.
Assignee | ||
Updated•13 years ago
|
Alias: DMD
Assignee | ||
Updated•13 years ago
|
Summary: Write a Valgrind tool to find dark matter → A Valgrind tool to find dark matter
Updated•13 years ago
|
Hardware: x86_64 → All
Version: unspecified → Trunk
Assignee | ||
Updated•13 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P1]
Assignee | ||
Comment 4•13 years ago
|
||
This is an in-progress version of DMD. Features:
- Reports unreported heap blocks.
- Reports double-reported heap blocks.
- Reports how many bytes each annotated reporter reported. This is useful for cross-checking with about:memory.
- Tracks both requested and slop bytes; emulates jemalloc's round-up behaviour.
- Has a couple of regression tests.
This patch applies to an SVN trunk version of Valgrind (I have r11976). If you want to use it, you'll need to follow the usual Valgrind tricks for Firefox, see https://developer.mozilla.org/en/Debugging_Mozilla_with_Valgrind. Trunk builds of Valgrind are easy, follow the instructions in Valgrind's top-level README file.
You'll need the --tool=exp-dmd flag, and you probably want to set --num-callers to something low like 6, otherwise lots of records that could be sensibly merged won't be. (Even with 6 you'll still get some like that, but if you ask for fewer than 6 sometimes the stack traces will be too shallow to be useful.)
Assignee | ||
Comment 5•13 years ago
|
||
Some DMD annotations for Firefox. Many more need to be done.
Assignee | ||
Comment 6•13 years ago
|
||
Assignee | ||
Comment 7•13 years ago
|
||
Attachment #553103 -
Attachment is obsolete: true
Attachment #553104 -
Attachment is obsolete: true
Updated•13 years ago
|
Blocks: MemShrinkTools
Assignee | ||
Updated•13 years ago
|
Whiteboard: [MemShrink:P1] → [MemShrink]
Comment 8•13 years ago
|
||
Did you mean to change this from [MemShrink:P1] to [MemShrink]? If so, why?
Assignee | ||
Comment 9•13 years ago
|
||
I did, I want to re-triage it. The bug obviously shouldn't be closed, but I don't think it needs to be a P1 any more now that it's in a state where it's spitting out useful numbers.
(In reply to Nicholas Nethercote [:njn] from comment #9)
> I did, I want to re-triage it. The bug obviously shouldn't be closed, but I
> don't think it needs to be a P1 any more now that it's in a state where it's
> spitting out useful numbers.
Might we call it fixed?
Assignee | ||
Updated•13 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P2]
Assignee | ||
Comment 11•13 years ago
|
||
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #10)
>
> Might we call it fixed?
I'll still be posting new versions of it, as well as new versions of the patch annotating Firefox. Marking it closed when I'll still be working on it doesn't feel right.
Assignee | ||
Updated•13 years ago
|
Summary: A Valgrind tool to find dark matter → DMD: A Valgrind tool to find dark matter
Assignee | ||
Comment 12•13 years ago
|
||
This version also tracks allocations done with mmap, which led me to bug 696690.
Attachment #554346 -
Attachment is obsolete: true
Assignee | ||
Comment 13•13 years ago
|
||
Attachment #554347 -
Attachment is obsolete: true
Assignee | ||
Comment 14•13 years ago
|
||
Attachment #569249 -
Attachment is obsolete: true
Assignee | ||
Comment 15•13 years ago
|
||
Attachment #570932 -
Attachment is obsolete: true
Assignee | ||
Updated•13 years ago
|
Assignee | ||
Comment 16•13 years ago
|
||
Comment on attachment 571888 [details] [diff] [review]
DMD, v4
Bug 704400 folded DMD into the tree, so this patch is no longer needed.
Attachment #571888 -
Attachment is obsolete: true
Assignee | ||
Comment 17•13 years ago
|
||
Comment on attachment 571889 [details] [diff] [review]
Firefox annotations, v4
Ugh, wrong patch.
Attachment #571889 -
Attachment is obsolete: true
Assignee | ||
Comment 18•13 years ago
|
||
Assignee | ||
Updated•13 years ago
|
Assignee | ||
Updated•13 years ago
|
Whiteboard: [MemShrink:P2]
Assignee | ||
Comment 19•12 years ago
|
||
DMDV (i.e. the Valgrind version of DMD) is now in the tree. There's no need to keep this bug open.
Assignee | ||
Updated•12 years ago
|
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•