Skip to content

Commit

Permalink
rpm2img: stripe root filesystem
Browse files Browse the repository at this point in the history
Aligning the root filesystem along 4MiB boundaries provides a subtle but
measureable performance improvement in Bottlerocket's boot process.
  • Loading branch information
cbgbt committed Mar 8, 2023
1 parent 62a7e47 commit a2fea12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/rpm2img
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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]}"
Expand Down

0 comments on commit a2fea12

Please sign in to comment.