-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
make-disk-image: improve xargs invocation #910
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
the flags -P
and -I
both exist on macOS as well 👍
@mergify queue |
🛑 The pull request has been removed from the queue
|
lib/make-disk-image.nix
Outdated
@@ -94,7 +94,7 @@ let | |||
|
|||
# We copy files with cp because `nix copy` seems to have a large memory leak | |||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store | |||
xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths | |||
xargs -P 0 -I {} sh -c 'cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store "$1" || exit 255' sh {} < ${closureInfo}/store-paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not run than one cp for every store path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently yes. We could wrap the cp invocation in a short script with $@
to avoid that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that to reduce the overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed by e6c2ca8
@mergify dequeue |
✅ The pull request has been removed from the queue
|
Btw we also have parallel copy implemented here: #788 |
I have seen that. However, this does not do anything about aborting early in out of space situations which was my main motivation for this PR. |
I also tried |
Also if the disk is full, how long does it actually take for cp to finish? Should this not rather quickly? |
No public example code but I build a 2GB sized aarch64-linux image on my x86_64-linux host. Just tested it again.
cp exits instantly. The problem is that xargs keeps invoking cp with the remaining arguments. I've observed 1-5 mins delay because of that depending at which point the disk gets full. |
Made the xargs flags configurable. Since I had to use |
When the disk image is too small,
cp
fails because it is out of space. However,xargs
does not abort immediately but still invokes all remainingcp
commands, which will of course also fail. That can lead to long waiting times until the make-disk-image script exits with a failure. This PR decreases the time to failure by lettingxargs
abort directly by causingcp
to fail with exti code 255.https://www.man7.org/linux/man-pages/man1/xargs.1.html#DESCRIPTION
Additionally allow
xargs
to invokecp
nproc
times in parallel with-P 0
as argument. Since by default the vm uses only one core, this does not change anything. However, for customimageBuilder.qemu
options like-smp 4
this can cause a major speedup. For example, I observed a time reduction from 22 to 12 minutes when building an image with aarch64 binfmt emulation.