-
Notifications
You must be signed in to change notification settings - Fork 618
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
Proposal: add Discriminator field to Line message #768
Comments
I think we should add one or the other, having both column and discriminator fields would look confusing IMO - like two identifiers of a position or fragment within the source line. Maybe we should add the discriminator field with the comment that for languages that use DWARF to resolve the debug info this is the DWARF discriminator and other languages like JS can give a special meaning to it like column number. |
I assume you mean "column and discriminator fields" here?
This seems reasonable to me. w.r.t. DWARF, I'll note that the spec quote above says: "Discriminator values ... distinguish among multiple blocks that may all be associated with the same source file, line, and column. Where only one block exists for a given source position, the discriminator value is be zero (sic)." My read of that is that the discriminator should only be set if the column is insufficient to discriminate, which would mean we'd need both. However, LLVM does not appear to follow the spec. In |
Sorry, yes. Updated the text retroactively.
Thanks for pointing out this detail. Yes, our internal symbolization pipeline also only carries the line number and the discriminator, not also the column number, so practically I think the two should be sufficient. |
There is #818 in review currently which will address #687 (adding column field in the Line message). I don't think we will be adding both fields unless a strong use case emerges, so when the discriminator is needed I would propose using the column field for it. Closing this issue as "not planned" - please feel free to re-open if the proposed solution does not work. |
The downside to this is that today Go's PGO uses standard CPU profiles emitted from |
I think it may be a sign that a more specialized format would be a better thing here then. Including every possible bit of information in profile.proto can make hard to manage over time. |
This proposal is a corollary to #687, to add more precision to sample locations.
A "discriminator" is an arbitrary value used to distinguish multiple constructs (traditionally basic blocks) that occur on the same (file, line, column) location.
Concretely, the DWARF spec defines "discriminator" on page 152 as "An unsigned integer identifying the block to which the current instruction belongs. Discriminator values are assigned arbitrarily by the DWARF producer and serve to distinguish among multiple blocks that may all be associated with the same source file, line, and column. Where only one block exists for a given source position, the discriminator value is be zero."
Discriminators are used by compilers (notably, LLVM) to distinguish basic blocks for use in profile-guided optimization (PGO). The Go toolchain supports PGO as of Go 1.20, and we use pprof profiles as the PGO input format as they are easy for users to collect (e.g., using
net/http/pprof
). However, line number as the highest precision granularity is rather limiting, and we would like to increase granularity (golang/go#59612). We could probably make do with just column number (#687), but adding discriminators would provide maximum precision.Concretely, the proposal is to add a field to
Line
:(
int64
selected for consistency with other fields, but I'm not tied to it. For reference, LLVM usesunsigned
, which I think isuint32
. 32-bits ought to be enough for anyone.)As suggested in #687 (comment), we may want to add
start_discriminator
to Function. (Perhaps Function should haveLine start_line
?)Other pprof changes from #687 apply here as well: adjusting aggregation options, perhaps adding a granularity flag. In my opinion, we could be even more lenient in the tool w.r.t. mostly ignoring discriminators. I don't think there are too many uses that will want to use discriminator values directly in the pprof tool itself (e.g., I don't think source view needs to display discriminators).
The text was updated successfully, but these errors were encountered: