public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v3 5/5] Lightweight copy of rootfs directories if possible
Date: Fri, 20 Jan 2023 08:31:06 +0100	[thread overview]
Message-ID: <20230120073106.5453-6-ubely@ilbers.de> (raw)
In-Reply-To: <20230120073106.5453-1-ubely@ilbers.de>

Some filesystem (such as BTFRS or XFS) support copy-on-write feature.
In this case, data blocks are not really copied until modified.

Using `--reflink=auto` enables this feature for `cp` and allows
to get a 2x..3x speed when copying files.

Some measurements on HDD and XFS (~900MiB rootfs from isar build):

```
real    0m31,828s
user    0m0,369s
sys     0m3,403s

real    0m13,611s
user    0m0,156s
sys     0m1,267s
```

The solution is taken from Roberto A. Foglietta patches and released
in a separate patch here.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 meta/classes/imagetypes_container.bbclass | 2 +-
 meta/classes/rootfs.bbclass               | 4 ++--
 meta/classes/sdk.bbclass                  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/meta/classes/imagetypes_container.bbclass b/meta/classes/imagetypes_container.bbclass
index 436a0051..50645aea 100644
--- a/meta/classes/imagetypes_container.bbclass
+++ b/meta/classes/imagetypes_container.bbclass
@@ -40,7 +40,7 @@ do_containerize() {
         "${oci_img_dir}_unpacked"
 
     # add root filesystem as the flesh of the skeleton
-    sudo cp -a "${rootfs}"/* "${oci_img_dir}_unpacked/rootfs/"
+    sudo cp --reflink=auto -a "${rootfs}"/* "${oci_img_dir}_unpacked/rootfs/"
     # clean-up temporary files
     sudo find "${oci_img_dir}_unpacked/rootfs/tmp" -mindepth 1 -delete
 
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 517185e8..19ce998f 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -78,7 +78,7 @@ BOOTSTRAP_SRC_${ROOTFS_ARCH} = "${DEPLOY_DIR_BOOTSTRAP}/${ROOTFS_DISTRO}-${ROOTF
 
 rootfs_prepare[weight] = "25"
 rootfs_prepare(){
-    sudo cp -Trpfx '${BOOTSTRAP_SRC}/' '${ROOTFSDIR}'
+    sudo cp -Trpfx --reflink=auto '${BOOTSTRAP_SRC}/' '${ROOTFSDIR}'
 }
 
 ROOTFS_CONFIGURE_COMMAND += "rootfs_configure_isar_apt"
@@ -218,7 +218,7 @@ cache_deb_src() {
     # Note: ISAR updates the apt state information(apt-get update) only once during bootstrap and
     # relies on that through out the build. Copy that state information instead of apt-get update
     # which generates a new state from upstream.
-    sudo cp -Trpn "${BOOTSTRAP_SRC}/var/lib/apt/lists/" "${ROOTFSDIR}/var/lib/apt/lists/"
+    sudo cp -Trpn --reflink=auto "${BOOTSTRAP_SRC}/var/lib/apt/lists/" "${ROOTFSDIR}/var/lib/apt/lists/"
 
     deb_dl_dir_import ${ROOTFSDIR} ${ROOTFS_BASE_DISTRO}-${BASE_DISTRO_CODENAME}
     debsrc_download ${ROOTFSDIR} ${ROOTFS_BASE_DISTRO}-${BASE_DISTRO_CODENAME}
diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
index 79e01a19..3feada21 100644
--- a/meta/classes/sdk.bbclass
+++ b/meta/classes/sdk.bbclass
@@ -82,7 +82,7 @@ do_rootfs_install[vardeps] += "${SDKROOTFSVARDEPS}"
 ROOTFS_CONFIGURE_COMMAND_append_class-sdk = " ${@'rootfs_configure_isar_apt_dir' if d.getVar('SDK_INCLUDE_ISAR_APT') == '1' else ''}"
 rootfs_configure_isar_apt_dir() {
     # Copy isar-apt instead of mounting:
-    sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO} ${ROOTFSDIR}/isar-apt
+    sudo cp -Trpfx --reflink=auto ${REPO_ISAR_DIR}/${DISTRO} ${ROOTFSDIR}/isar-apt
 }
 
 ROOTFS_POSTPROCESS_COMMAND_prepend_class-sdk = "sdkchroot_configscript "
-- 
2.20.1


  parent reply	other threads:[~2023-01-20  7:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20  7:31 [PATCH v3 0/5] Improving apt cache Uladzimir Bely
2023-01-20  7:31 ` [PATCH v3 1/5] Clean apt cache from debootstrapped rootfs dirs Uladzimir Bely
2023-01-20  7:31 ` [PATCH v3 2/5] Use hardlinks in deb-dl-dir import/export Uladzimir Bely
2023-01-20  7:31 ` [PATCH v3 3/5] Exclude apt cache from sstate caches Uladzimir Bely
2023-01-20  7:31 ` [PATCH v3 4/5] Use symlinks when importing debian packages to sbuild chroot Uladzimir Bely
2023-01-20  7:31 ` Uladzimir Bely [this message]
2023-01-20 13:04 ` [PATCH v3 0/5] Improving apt cache Moessbauer, Felix
2023-01-21  4:12   ` Roberto A. Foglietta
2023-01-24  7:38 ` Uladzimir Bely
2023-01-30  8:45 ` Moessbauer, Felix
2023-01-30  9:56   ` Roberto A. Foglietta
2023-01-30 10:04     ` Roberto A. Foglietta
2023-01-30 10:45   ` Henning Schild
2023-01-30 12:24     ` Roberto A. Foglietta
2023-01-30 14:16   ` Roberto A. Foglietta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120073106.5453-6-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox