Skip to content
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

ResolveWorld is very inefficient #777

Open
Tracked by #781
jonjohnsonjr opened this issue Jul 1, 2023 · 1 comment
Open
Tracked by #781

ResolveWorld is very inefficient #777

jonjohnsonjr opened this issue Jul 1, 2023 · 1 comment

Comments

@jonjohnsonjr
Copy link
Contributor

This line is relatively slow because it uses a regexp. That's fine, but unfortunately we end up calling it several million times during a build because it gets called inside sortPackages and filterPackages.

See here:

image

A very lazy fix would be to memoize parseVersion because we call parseVersion with identical strings repeatedly, but we could also probably do a lot better by parsing everything before we start sorting.

I logged a bunch of the inputs to parseVersion for a build of go images, this is what I saw:

64168 20230201-r2
71968 20220614-r2
79036 20230201-r1
100868 20221118-r1
101776 20220614-r3
101776 20220614-r4
101776 20230106-r0
112092 20221118-r0
120114 2.37-r6
130224 20230201-r0
156160 20221118-r2
198156 2.37-r3
202690 2.37-r2
266633 2.36-r4
292318 2.36-r6
311620 2.36-r5
333008 2.36-r3
340075 2.37-r0
395170 2
429106 2.37-r1
506736 6
544820 1
@jonjohnsonjr
Copy link
Contributor Author

Partially addresses this: chainguard-dev/go-apk#76

@jonjohnsonjr jonjohnsonjr changed the title FixateWorld is very inefficient ResolveWorld is very inefficient Jul 8, 2023
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

No branches or pull requests

1 participant