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

Long cache retrieval when resolving dependencies #8123

Open
Ernest0-Production opened this issue Nov 18, 2024 · 4 comments
Open

Long cache retrieval when resolving dependencies #8123

Ernest0-Production opened this issue Nov 18, 2024 · 4 comments

Comments

@Ernest0-Production
Copy link

Ernest0-Production commented Nov 18, 2024

Description

SPM dependency resolution takes a very long time to extract. Each package* takes on average ~1 second to extract.

As I understand it, the problem is that the cache is stored in a compressed form and takes time to extract. But it seems to me that this is of less practical use than a faster resolution.

I would like the user cache to store the original artifacts (the same as in the local .build directory)

@dschaefer2
Copy link
Member

I assume you mean "package" not "packet". But yes, it's actually doing a git clone and checkout from the cache which is a very expensive operation.

@Ernest0-Production
Copy link
Author

I assume you mean "package" not "packet". But yes, it's actually doing a git clone and checkout from the cache which is a very expensive operation.

Yes, I made a typo.
Is it technically possible to change this strategy, storing all repositories in the user cache?

@dschaefer2
Copy link
Member

I think we're probably at the point where we're doing the best we can. SwiftPM does a complete git clone into the user cache under .swiftpm/cache/repositories. We need that so we have all the versions available during dependency resolution and allows you to have multiple projects using different versions. We then do a shallow clone of the selected revision over to the package scratch directory. One second to do is about as fast as git can go.

The solution we're hoping for is the previous work with package registries where the registry would have the metadata we need and a source archive for each available version. Then we can cache those which would be much faster. But I'm not sure when a community wide solution for that will happen.

@Ernest0-Production
Copy link
Author

@dschaefer2 I spent some more time on the benchmark:
It seems that the real reason for the long resolution is not in the cache, but in the process of generating the workspace-state.json file.

If you delete everything in the .build folder except this file – restoring from the user cache will happen quite quickly.
But if you delete workspace-state.json (even without deleting the local cache) – the generation of this file takes a surprisingly long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants