-
Notifications
You must be signed in to change notification settings - Fork 712
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
Remove and optimize more Copy()s #1739
Conversation
This reduces CPU usage by ~15% in my tests. @2opremio This currently fails a couple of unit tests. Can't work out why. Mind taking a look? |
result := n.Copy() | ||
result.Metrics[key] = n.Metrics[key].Merge(metric) | ||
return result | ||
n.Metrics = n.Metrics.Copy() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I am not an expert on the rendering pipeline, but I will take a look. |
@@ -54,33 +54,35 @@ func (s StringSet) Intersection(b StringSet) StringSet { | |||
// Add adds the strings to the StringSet. Add is the only valid way to grow a | |||
// StringSet. Add returns the StringSet to enable chaining. | |||
func (s StringSet) Add(strs ...string) StringSet { | |||
r := s.Copy() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
A shallow copy is sufficient. Which we get for free in most cases since Node is passed around by value.
044e9d7
to
c180c56
Compare
Rebased and added some more improvements. |
c180c56
to
5d857d0
Compare
I see a very minor improvement in CPU consumption in the Scope App in dev-c4. Maybe I wasn't interacting with the details panel enough (it's hard to try to do it manually and spread usage fairly between tests). Before:
After:
|
output = propagateLatest(docker.ImageName, image, output) | ||
output = propagateLatest(docker.ImageLabelPrefix+"works.weave.role", image, output) | ||
output.Parents = output.Parents. | ||
c = propagateLatest(docker.ImageName, image, c) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I can no longer see any statistically significant improvement between this branch and master :( |
I think we should merge it anyhow to remove unneeded uses of Copy() which prompt to abuse it. @paulbellamy Any further comments? |
Nope |
This was building a set of all the image ids represented by the same unversioned image. Well, it was doing that until I broke it with a silly mistake in #1739 - instead of extracting the imageID from the original node ID, it's extracting it from the updated ID, which is the unversioned image. Even if it was working though, it's pointless since nothing is looking at that info.
This was building a set of all the image ids represented by the same unversioned image. Well, it was doing that until I broke it with a silly mistake in #1739 - instead of extracting the imageID from the original node ID, it's extracting it from the updated ID, which is the unversioned image. Even if it was working though, it's pointless since nothing is looking at that info.
Part of #1730.