-
Notifications
You must be signed in to change notification settings - Fork 62
🐛 improve poor performance of helm chart conversion #1050
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
🐛 improve poor performance of helm chart conversion #1050
Conversation
👷 Deploy Preview for olmv1 processing.
|
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
eb5f63f
to
5bd1edd
Compare
And it already needs a rebase... |
…lm chart conversion Signed-off-by: Joe Lanford <[email protected]>
5bd1edd
to
67352d1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1050 +/- ##
==========================================
- Coverage 73.46% 72.98% -0.48%
==========================================
Files 32 28 -4
Lines 1986 1877 -109
==========================================
- Hits 1459 1370 -89
- Misses 368 375 +7
+ Partials 159 132 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
A few questions.
@@ -161,7 +158,12 @@ func main() { | |||
} | |||
|
|||
cl := mgr.GetClient() | |||
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, httpClient)) | |||
catalogsCachePath := filepath.Join(cachePath, "catalogs") | |||
if err := os.MkdirAll(catalogsCachePath, 0700); err != nil { |
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.
Nothing that the previous mode (for bundles
) was 0755
, does this make a difference?
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 shouldn't. We don't expect any other users or groups to read these files.
@@ -212,6 +212,9 @@ func checkForUnexpectedFieldChange(a, b ocv1alpha1.ClusterExtension) bool { | |||
*/ | |||
//nolint:unparam | |||
func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.ClusterExtension) (ctrl.Result, error) { | |||
l := log.FromContext(ctx) |
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.
Did you want to put the name of the ClusterExtension
here?
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.
Possibly, also attach the V(1) to this. e.g.
l := log.FromContext(ctx) | |
l := log.FromContext(ctx).V(1).AddValues("ClusterExtension", ext.GetName()) |
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.
The name is already part of the context provided in the context that arrives from the caller of Reconcile
.
I thought about using V(1)
, but that would mean that no logging (with that logger at least) could ever happen at the INFO level.
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.
I was going to suggest that I could do something like this:
l := log.FromContext(ctx)
debugLog := l.V(1)
But that would be misleading because levels build (i.e. .V(1).V(1)
is equivalent to .V(2)
), so if the caller set a .V(1)
logger in the context, the this would suddenly not be a debug logger.
}, | ||
hash := sha256.Sum256(jsonData) | ||
chrt.Templates = append(chrt.Templates, &chart.File{ | ||
Name: fmt.Sprintf("object-%x.json", hash[0:8]), |
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.
Is this enough of the hash? Should it be longer?
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.
We can make it longer, but I didn't change that aspect of this code. The name is the same as before except for .json
instead of .yaml
.
return nil, fmt.Errorf("read %q: %v", e.Name(), err) | ||
defer func() { | ||
if err := manifestFile.Close(); err != nil { | ||
l.Error(err, "error closing file", "path", path) |
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 appears to be the only place l
is used. Should l := log.FromContext(ctx)
be moved down here for locality?
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 into the WalkDir function?
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.
If we did that, we'd have to repeatedly ask the context for the same logger over and over. It feels better (to me at least) to get the "logger to be used in the scope of this function" once, right at the very beginning of the function.
return nil, err | ||
} | ||
for _, e := range entries { | ||
if err := fs.WalkDir(rv1, manifestsDir, func(path string, e fs.DirEntry, err error) error { |
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.
There's another potential optimization here, where we spin up runtime.NumCPU
goroutines and parse the files concurrently. But that can happen as a follow-up.
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.
/lgtm
bfc65ee
…lm chart conversion (operator-framework#1050) Signed-off-by: Joe Lanford <[email protected]>
…lm chart conversion (operator-framework#1050) Signed-off-by: Joe Lanford <[email protected]>
Description
A few ways that performance is improved:
storage
abstraction. We can convert directly from the unpacked bundle FS.cli-runtime
to parse manifests from the registry+v1 bundle (e.g. don't read file into buffer and then parse the buffer)plain
FS and then turn around and immediately re-parse the plain FS. Skip the plain FS and generate the chart directly.Other ancillary changes:
<cacheDir>/catalogs
directory (rather than directly in<cacheDir>
).Motivation
Performance improvements of the reconcile function, and thus a more reactive system.
Locally, I noticed e2e drops from 323s to 231s.
Reviewer Checklist