Skip to content

proposal: cmd/compile: generate PDBs on Windows #62420

Open
@randomascii

Description

@randomascii

Chromum uses Go for various build tools, including the up-and-coming siso build tool. Windows has a rich set of tools (better than on Linux in many ways) for debugging and profiling. All Windows executables should generate PDB files (Windows debug-information files) to let them use these tools. Go does not generate PDBs
and therefore these powerful and standard tools cannot be used with Go executables. This disconnect between Windows expectations and what Go provides makes adoption of Go on Windows more difficult, and means that some performance problems will be unnecessarily difficult to investigate.

Details: Virtually every EXE and DLL on Windows ships with a link to a PDB that contains, at the very least, the names of functions in the binary. Here is an example for notepad:

dumpbin C:\Windows\System32\notepad.exe /headers | find /i "rsds"
BDD4ADCD cv 24 0002B4E4 2A0E4 Format: RSDS, {67D551E7-B9BB-3B68-E823-F5B998BD9453}, 1, notepad.pdb

The PDB isn't actually shipped, but it can be obtained (in an automated way) from symbol servers that are published by Microsoft, Chrome, Firefox, and other companies (https://randomascii.wordpress.com/2013/03/09/symbols-the-microsoft-way/).

Go binaries, on the other hand, lack this information:

dumpbin third_party\siso\siso.exe /headers | find /i "rsds"

This means that windbg, VS, ETW, and many other amazing tools can do very little with Go programs.

ETW profiling in particular (https://randomascii.wordpress.com/2015/09/24/etw-central/) is tremendously powerful. It allows viewing of CPU usage (both sampled and based on context switches), disk I/O, memory allocations, and many other performance-relevant attributes, all on a unified timeline with configurable ways of drilling into the available information.
ETW sampling can seamlessly straddle the user-mode/kernel-mode boundary, making kernel calls appear just like function calls in the tables. ETW's context-switch graphs allow diagnosing of where a thread is waiting and what it is waiting on.

While integrated profiling with -cpuprofile (supported by siso) is nice, it is not a substitute for ETW profiling.

Concretely, I am currently trying to understand some suboptimal performance in siso (Googler-only link - b/298409062) but siso's -cpuprofile option doesn't make this easy to do. Simultaneously I am looking at ETW profiles (from a user) that show that most of the time in Chrome's setup process is being spent in KiPageFault - this is information that no user-mode profiler could reveal.

The Go team should consider giving their build tools an option (on by default!) to generate basic PDBs that can be consumed by standard Windows tools. The lld-link linker already generates rich PDBs (with stack frame, type, and inlining information) and generating just function name information would be simple in comparison, and could reuse the expertise and code of the lld-link project.

TL;DR - Support of PDBs is expected on Windows and it would be great if Go could satisfy that expectation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions