Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: current heapdump format is undocumented #15169

Open
mdempsky opened this issue Apr 7, 2016 · 6 comments
Open

runtime: current heapdump format is undocumented #15169

mdempsky opened this issue Apr 7, 2016 · 6 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Apr 7, 2016

runtime/debug.WriteHeapDump's godocs link to https://golang.org/s/go15heapdump, but that describes a file format that starts with "go1.5 heap dump\n".

Currently, runtime.dumphdr is "go1.7 heap dump\n". Before 30f93f0, it was "go1.6 heap dump\n". So that's at least two revisions to the heap dump file format that are undocumented.

Relevant because https://go-review.googlesource.com/#/c/21647/1 might change the heap dump format again.

/cc @crawshaw

@bradfitz
Copy link
Contributor

bradfitz commented Apr 7, 2016

We need to stop documenting the heap dump in a wiki and document it in the main go repo in the same commit where the format changes.

Ideally with, say, tests. And ideally end-to-end tests writing then reading the heap dump that would break if the heapdump format changes. (which empirically it does, regularly)

/cc @randall77

@bradfitz bradfitz modified the milestones: Unplanned, Go1.7 Apr 7, 2016
@randall77
Copy link
Contributor

@matloob

@gopherbot
Copy link

CL https://golang.org/cl/21647 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 11, 2016
After mdempsky's recent changes, these are the only references to
"TheChar" left in the Go tree. Without the context, and without
knowing the history, this is confusing.

Also rename sys.TheGoos and sys.TheGoarch to sys.GOOS
and sys.GOARCH.

Also change the heap dump format to include sys.GOARCH
rather than TheChar, which is no longer a concept.

Updates #15169 (changes heapdump format)

Change-Id: I3e99eeeae00ed55d7d01e6ed503d958c6e931dca
Reviewed-on: https://go-review.googlesource.com/21647
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 11, 2016
@rsc
Copy link
Contributor

rsc commented Nov 11, 2016

Undocumented but also nearly unusable. Leave both for Go 1.9.

@rsc rsc modified the milestones: Go1.9, Go1.8 Nov 11, 2016
@aclements
Copy link
Member

Bumping to 1.10. Most likely we're going to rip out the heap dump format and replace it with @randall77's core dump reader, at which point this will become obsolete, but that's not going to happen until 1.10.

@aclements aclements modified the milestones: Go1.10, Go1.9 Jun 7, 2017
@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
@oliverbestmann
Copy link

oliverbestmann commented Jul 26, 2023

I am currently reading through the heap dump that go 1.20 writes the same way a debugger would by traversing the stack variables using dwarf info, follow pointers to the heap and continue walking using dwarf info. That works pretty well. I can even identify interface types by reading the binaries rodata + noptrdata to access rtype instances pointed to in those interfaces. I can then map rtype back to a pkg/type name and look it up in the dwarf types. This allows me to resolve the interface and recurse into the allocated values on the heap.

Some issues that i currently see:

  • funcval do have dwarf data, but i dont see the funcvals dwarf type of a closure/functype referenced anywhere.
  • usage of unsafe.Pointer (e.g. in sync.Pool) translates basically into a *void pointer. no dwarf data there. With prior knowledge I could handle special cases (like sync.Pool - it stores interfaces).

In a real world http service this helps me identifying around 30-40% of my heap objects or 50% of the heap data. not great, not too bad either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

8 participants