From a2fea1246ecb4912e795aa05743e728ccb70796c Mon Sep 17 00:00:00 2001 From: "Sean P. Kelly" Date: Wed, 8 Feb 2023 14:55:14 +0000 Subject: [PATCH] rpm2img: stripe root filesystem Aligning the root filesystem along 4MiB boundaries provides a subtle but measureable performance improvement in Bottlerocket's boot process. --- tools/rpm2img | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/rpm2img b/tools/rpm2img index b05914a0374..7cec1e1e387 100755 --- a/tools/rpm2img +++ b/tools/rpm2img @@ -126,6 +126,11 @@ VERITY_HASH_ALGORITHM=sha256 VERITY_DATA_BLOCK_SIZE=4096 VERITY_HASH_BLOCK_SIZE=4096 +# Bottlerocket has been experimentally shown to boot faster on EBS volumes when striping the root filesystem into 4MiB stripes. +# We use 4kb ext4 blocks. The stride and stripe should both be $STRIPE_SIZE / $EXT4_BLOCK_SIZE +ROOT_STRIDE=1024 +ROOT_STRIPE_WIDTH=1024 + case "${PARTITION_PLAN}" in split) truncate -s "${OS_IMAGE_SIZE_GIB}G" "${OS_IMAGE}" @@ -279,7 +284,8 @@ mkdir -p "${ROOT_MOUNT}/lost+found" ROOT_LABELS=$(setfiles -n -d -F -m -r "${ROOT_MOUNT}" \ "${SELINUX_FILE_CONTEXTS}" "${ROOT_MOUNT}" \ | awk -v root="${ROOT_MOUNT}" '{gsub(root"/","/"); gsub(root,"/"); print "ea_set", $1, "security.selinux", $4}') -mkfs.ext4 -O ^has_journal -b "${VERITY_DATA_BLOCK_SIZE}" -d "${ROOT_MOUNT}" "${ROOT_IMAGE}" "${partsize[ROOT-A]}M" +mkfs.ext4 -E "lazy_itable_init=0,stride=${ROOT_STRIDE},stripe_width=${ROOT_STRIPE_WIDTH}" \ + -O ^has_journal -b "${VERITY_DATA_BLOCK_SIZE}" -d "${ROOT_MOUNT}" "${ROOT_IMAGE}" "${partsize[ROOT-A]}M" echo "${ROOT_LABELS}" | debugfs -w -f - "${ROOT_IMAGE}" resize2fs -M "${ROOT_IMAGE}" dd if="${ROOT_IMAGE}" of="${OS_IMAGE}" conv=notrunc bs=1M seek="${partoff[ROOT-A]}"