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

Consider using hardlink instead of cow for preparing ~/.lima/<INSTANCE>/basedisk from the downloader cache #2818

Open
AkihiroSuda opened this issue Oct 28, 2024 · 9 comments

Comments

@AkihiroSuda
Copy link
Member

As the basedisk remains immutable, it could be just hardlinked from the downloader cache (when the cache exists on the same filesystem).

This may make the situation complicated though, if we want to support squashing the diffdisk to basedisk in future.

@afbjorklund
Copy link
Member

You could use reflinks, where available.

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Oct 29, 2024

You could use reflinks, where available.

We have been already using reflinks when available, but hardlinks would be preferable when reflinks are not supported by the filesystem.

return fs.CopyFile(dstPath, srcPath)

@jandubois
Copy link
Member

COW feels slightly safer because it guarantees that the source is immutable. Hardlinks rely on there being no bugs or future changes that could modify the source.

@afbjorklund
Copy link
Member

afbjorklund commented Nov 2, 2024

I think we would need to introduce CAS*, since currently the images are just indexed by their URL?

- location: "https://cloud-images.ubuntu.com/releases/24.10/release/ubuntu-24.10-server-cloudimg-amd64.img"

Currently I think that it will work with "prune", since the cache file will be deleted (before recreated).

But that means that the instance will end up "owning" the old file which might not be ideal either?

What I meant was that it should be possible for instances to continue to exist, after a cache cleanup.

But ultimately it would need some kind of "garbage collect" to clean up also those entires, if unused.


* With a CAS solution, then there would be a secondary layer for the data - like "by-content-sha256".

download/by-url-sha256/3b6b67faf5fd451e96832cbcaf6f5e04704d2ff7c47e749663508fc2a636130f/data ->
download/by-content-sha256/fad101d50b06b26590cf30542349f9e9d3041ad7929e3bc3531c81ec27f2c788.data

Probably overengineered here, but could help with mirrors and other distribution systems like IPFS?

i.e. main reason we introduced this in another project, was to be able to keep metadata in memory

By keeping the big files in separate storage ("rados"), all of the small files could be indexed ("redis")...

Like so: https://juicefs.com/docs/community/architecture

Where RADOS would be Ceph, and REDIS would be Valkey

@afbjorklund
Copy link
Member

if we want to support squashing the diffdisk to basedisk in future

Why do we want to avoid that? I thought the clone took care of backing?

@afbjorklund
Copy link
Member

I am assuming that the basic idea here is to keep each instance directory smaller, which sounds like a good idea.

And to avoid the time it takes to copy from the cache to the instance (assuming that it is in the right format...)?

@norio-nomura
Copy link
Contributor

I think using clonefile(2) would be a good approach for macOS specifically.
Reference article: https://eclecticlight.co/2024/03/20/apfs-files-and-clones/

@AkihiroSuda
Copy link
Member Author

Yes, we have been already using clonefile(2) via continuity
https://github.com/containerd/continuity/blob/v0.4.5/fs/copy_darwin.go#L27

@norio-nomura
Copy link
Contributor

I am currently investigating whether clonefile(2) can be used for suspend/resume in #2900.

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

4 participants