-
Notifications
You must be signed in to change notification settings - Fork 207
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
Some small optimisations #3261
base: master
Are you sure you want to change the base?
Some small optimisations #3261
Conversation
What benchmark are you running in your before/after? |
@@ -108,10 +108,19 @@ func resolvePluginValue(values []string, subrepo string) []string { | |||
continue // I guess it wasn't a build label. Leave it alone. | |||
} | |||
// Force the full build label including empty subrepo so this is portable | |||
v = fmt.Sprintf("///%v//%v:%v", l.Subrepo, l.PackageName, l.Name) | |||
var buf strings.Builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty unwieldy. Are we really calling this so frequently that it's worth making the code that much more complicated?
I'd expect under most circumstances the vast majority of wall-clock time to be spent on the build steps themselves, rather than anything to do with parsing BUILD files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even just using string concatenation:
v = `///`+l.Subrepo+`//`+l.PackageName+`:`+l.Name
But this won't call into the Stringer
interface if any of these variables aren't a string
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called a lot more often than you'd expect. The way subrepos + plugins work with go_repo each being their own subrepo, it's called often.
I'd expect under most circumstances the vast majority of wall-clock time to be spent on the build steps themselves, rather than anything to do with parsing BUILD files?
Well it depends what you're doing. Things like plz query changes
are usually blocked by parsing files.
The performance one we run after merge ( |
@@ -108,10 +108,19 @@ func resolvePluginValue(values []string, subrepo string) []string { | |||
continue // I guess it wasn't a build label. Leave it alone. | |||
} | |||
// Force the full build label including empty subrepo so this is portable | |||
v = fmt.Sprintf("///%v//%v:%v", l.Subrepo, l.PackageName, l.Name) | |||
var buf strings.Builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here (or at the top of the file) to explain why you're not using fmt.Sprintf
Reduces one allocation in
provideFor
and a few other things in paths of varying temperatures (notably getting rid offmt.Sprintf
which isn't the most efficient way to put strings together, although it is fairly concise).Before:
After: