-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support for block devices as builds/cache dirs #60
Comments
We can probably add support for passing block devices via |
Hello Justin 👋 Have you considered using a distributed cache instead? It works just as snappy as a mounted directory/block device, but without the mounted directory bugs and extra complexity of managing the block devices (namely, Tart process running with elevated privileges, filesystem corruption due to concurrent access from multiple jobs, etc). Here's a quick example snippet that once put in [[runners]]
[runners.cache]
Type = "s3"
[runners.cache.s3]
ServerAddress = "minio.local:9000"
AccessKey = "minioadmin"
SecretKey = "minioadmin"
BucketName = "gitlab-cache"
Insecure = true MinIO itself can be easily installed with |
Hi @edigaryev, Many thanks for your reply, and for the suggestion. Our use case involves building repositories that are hundreds of GBs in size, so using a pre-existing pre-cloned repo for each build is a hard requirement. Since the S3 caching feature up/downloads zips of the cached files on each run, unfortunately it would be prohibitively slow for us. Reusing a repo is currently trivial on a bare metal macOS GitLab runner via So, we were hoping that we might have better luck using a block device to store repos and have it mounted in the build job. Ultimately we are looking to achieve build isolation for macOS builds (multiple Xcode versions, multiple OS versions, etc) as an improvement on our current bare metal solution. We are also looking into some experimental early use of Docker for this purpose, from where I was originally pointed in this direction by @fkorotkov . |
Hi @jlsalmon, Thanks for clarifying this. Assuming your goals (build isolation but no resource utilization), do I understand right that it would it be acceptable for you to only being able to run a single Tart VM when using the block device option? Otherwise I don't see how more than one Tart VM would be able to access the same block device without causing filesystem corruption and other undesirable side-effects. |
@edigaryev it would be acceptable to run only a single tart VM in the first instance, yes. I suppose it might be possible later on to support two VMs, either using two block devices (e.g. two partitions or two external drives) or or using unique build root directories per VM on a single block device. But one VM would be already a big achievement 😊 |
Another thing I have in mind is that you don't need an actual block device access to be able to mount a filesystem into a Tart VM. You could simply do This disk image could reside anywhere you want (e.g. on a fast storage attached to a Mac) and does not require privilege escalation via The only downside is that this disk image needs to be properly formatted as APFS/HFS+/etc, which is something that However, this disk image can be easily formatted from within a Tart VM and then re-used many times for subsequent CI runs. Would that be acceptable for you? If so, we can simply add a |
Thanks for clarifying this too! Please also check #60 (comment) and let me know what you think. If that works for you, we can even go further and clone that golden disk image for each Tart VM invocation (since APFS supports fast file copies using CoW). This will allow to safely run more than one Tart VM using a given golden disk image, the only downside is that changes to that cloned disk image won't be propagated back to the golden image. |
@edigaryev thanks for the tip about using disk images, I'd be happy to give that a shot! I would need changes to the disk image(s) to be persisted across runs, so not sure about the cloning images part, but I'm sure there are options there 👍 |
@jlsalmon please check out the new |
Another option to actually mount the block device is to change its access permissions: sudo chown $USER /dev/disk42 This way no However, this approach is more error-prone (or in other words, requires some scripting around) than the disk image one, because macOS has no |
I've also just realized that we need a way to tell the GitLab Tart Executor whether the |
Thanks for this @edigaryev, I just tried it out and it's working great. I'm currently assessing the performance of a few different disk image types (sparse bundles, sparse images and regular disk images). I'll also try out your |
@jlsalmon will be great if you could share your experience once it's working for you. Seems like a great piece of engineering you are working on! |
So I found that the only method which has reasonable performance for my use case is directly attaching an APFS volume (either by physically partitioning the host disk, or using an external APFS-formatted storage device). I managed to achieve 60% of the host-native performance with this method on a 2020 M1 Mac mini running macOS 14.2. File-based methods (sparsebundle, DMG, raw APFS-formatted file) were just too slow. The best was the sparsebundle, which achieved 25% of the host-native performance. It seems that in my experience it's not possible to get near-native performance when disk IO is a dominant factor of the workload. I also tried XcodeBenchmark and could only reach a maximum of 65% of the host-native performance (again using an APFS volume attachment). FYI @fkorotkov |
Thank you for the data points! Can I ask you how did you run XcodeBenchmark in a VM. I can't reproduce the 65% slowness. I use an M1 Mac Minis with 16Gb of memory and without isolation |
@fkorotkov on my 2020 M1 Mac mini with 8 CPUs/16GB memory without isolation,
Doing the same thing inside a fresh VM with matched host resources (not using any disk attachments) takes between 250-260 seconds:
I did many runs on both host and guest. I get roughly 66% of host performance on the guest. I'm not sure why my host results are faster than yours. It's worth noting that this Mac mini is booted from a Samsung T5 external SSD, and is not using the internal drive. But I would expect that to make the benchmark run slower, so that makes it even more confusing 🤔. |
Would it be possible to add support to the gitlab executor for using block devices? Specifically I would like to try using a block device as the builds/cache dirs (since virtiofs mounts via
--builds-dir
and--cache-dir
don't currently work due to cirruslabs/tart#567).I'm not sure how this would work with the requirement to run tart as root when attaching block devices though.
The text was updated successfully, but these errors were encountered: