-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/pprof: unexpectedly seeing full struct definitions in function names for generics functions #65147
Comments
I expected this to be fixed with Go 1.21.6. Are you trying to open a pprof captured with an old version of Go? |
I don't think this is related to #64528 (the bug fixed in 1.21.6). That is about the profile containing an incorrect symbol name. AFAICT, this issue is simply about the giant name in the profile. That name is the actual symbol name, for better or worse. The CL on #65030 (included in 1.22) uses a hashed name for these giant names to keep them small. That should make the pprof graph look less absurd, but at the expensive that it will no longer be possible to tell what the type parameters are. |
Go verison is 1.21.6 as I added go env result or is there chance that |
I could undstertand that, but is there a need to treat any struct like anonymous and show its body instead? The one I am passing is the struct name itself, so it should have the name like package.Struct. EDIT: I took a look at #65030, but it seems like a workaround for visual. Is that also mean Go does not even hold the name of the type (struct's full name) passed in generics functions? |
The Go toolchain uses a dictionary-based generics implementation. That doc has complete details, but the critical aspect is that the compiler does not create a unique function instantiation for every distinct type argument. A single instantiation is shared by all types that have the same shape. You can see an example of this with this program:
If you look at the disassembly, you'll see that even though |
Thanks for the the detail explanations, seems like even I write like |
Go version
go1.20.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
When I profile with pprof, func name output is too large for struct types.
Might related to this fix with 1.21.6
What did you see happen?
When you pass large struct as Type to generics functions, pprof show all if its definition like this.
![image](https://private-user-images.githubusercontent.com/1001175/297620845-cd7b5db6-52f2-4e72-b88a-aeb9b8713de6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTM2NDgsIm5iZiI6MTczOTQ5MzM0OCwicGF0aCI6Ii8xMDAxMTc1LzI5NzYyMDg0NS1jZDdiNWRiNi01MmYyLTRlNzItYjg4YS1hZWI5Yjg3MTNkZTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDAzNTQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YmFkMjQ2ODJkYTc4Nzc5Y2Y5NmY2NjNiYjdhZGU4MDFiZmNlZjAwMmFmYWJlODA0N2NhYmM4ZGEyNzI3MmRkYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.vbHImuCpp0csxvd4gyVUfMWJLANcWIN2VntIsV1Az58)
What did you expect to see?
Only struct Name or with package name for Types passed to generics function, instead of full definition on pprof output.
The text was updated successfully, but these errors were encountered: