Skip to content

Remove type parameters from go names #2343

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

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

kolesnikovae
Copy link
Collaborator

@kolesnikovae kolesnikovae commented Aug 31, 2023

Fixes #2241.

Replaces Go type parameters with ellipses as it was before go 1.21.0.

image

@@ -92,7 +92,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {
f.IntVar(&l.MaxProfileStacktraceSamples, "validation.max-profile-stacktrace-samples", 16000, "Maximum number of samples in a profile. 0 to disable.")
f.IntVar(&l.MaxProfileStacktraceSampleLabels, "validation.max-profile-stacktrace-sample-labels", 100, "Maximum number of labels in a profile sample. 0 to disable.")
f.IntVar(&l.MaxProfileStacktraceDepth, "validation.max-profile-stacktrace-depth", 1000, "Maximum depth of a profile stacktrace. Profiles are not rejected instead stacktraces are truncated. 0 to disable.")
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 1024, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.")
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 65535, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.")
Copy link
Collaborator Author

@kolesnikovae kolesnikovae Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit is increased as length of 1024 is too short for Go:

image

In practice we already have profile size limit therefore this one might not be required. Because of the string truncation it's easy to make profiles unreadable (e.g such profiles are useless for PGO)

Comment on lines +10 to +24
func DropGoTypeParameters(input string) string {
matchesIndices := goStructTypeParameterRegex.FindAllStringIndex(input, -1)
if len(matchesIndices) == 0 {
return input
}
var modified strings.Builder
prevEnd := 0
for _, indices := range matchesIndices {
start, end := indices[0], indices[1]
modified.WriteString(input[prevEnd:start] + "[...]")
prevEnd = end
}
modified.WriteString(input[prevEnd:])
return modified.String()
}
Copy link
Collaborator Author

@kolesnikovae kolesnikovae Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we don't know if it is a Go profile / node, therefore the function is applied to all nodes. ReplaceAllString would look better here but it allocates a new string.

I'm also not sure if there might be more than one group of type parameters.

@kolesnikovae kolesnikovae marked this pull request as ready for review August 31, 2023 10:44
@kolesnikovae kolesnikovae requested review from a team as code owners August 31, 2023 10:44
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go1.21.0 pprof function names
2 participants