Remaining perf work for wolfictl text
#250
Labels
enhancement
New feature or request
needs-triage
applied to all new customer/user issues. Removed after triage occurs.
Description
I'm going to stop digging into this, but I wanted to write down what I've found before dropping all context:
Once all the PRs I've sent are merged and those dependencies get bumped,
wolfictl text
~400ms instead of ~250s (on my machine, at least).What's left looks like this:
The biggest chunk in the middle is calling BuildFlavor, from here:
https://github.com/chainguard-dev/melange/blob/a3b7a002e874b75c318e5d2a2c3c7af7142f456c/pkg/build/pipeline.go#L97-L98
We end up
Stat
ing (I think) an empty directory a lot, so fixing that would shave off ~50ms.There's also a ton of redundant reading of files and parsing of yamls and detecting of commits. I added some logging to see what's going on:
I'm a little hesitant to start refactoring things too much, but it seems like it would be straightforward to cache this stuff.
There are also a bunch of little things:
We spend a ton of time in https://github.com/chainguard-dev/go-apk/blob/2829525a71369b8c570b98332bb73639b1e59802/pkg/apk/version.go#L371 doing regex stuff. If it's possible to do this in a non-regexy way, we could save some time.
All of the string manipulation in here could also be a lot faster: https://gitlab.alpinelinux.org/alpine/go/-/blob/master/repository/repository.go
E.g.
IndexUri()
,NewRepositoryFromComponents
, andUrl
should all be usingpath.Join
instead offmt.Sprintf
.The
Packages()
method should initializepkgs
withCount()
capacity.I suspect we could get this down to sub-100ms if we fix everything.
The text was updated successfully, but these errors were encountered: