Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bjodah/d89be472c652e2d1dfe06e400bda48f3 to your computer and use it in GitHub Desktop.
Save bjodah/d89be472c652e2d1dfe06e400bda48f3 to your computer and use it in GitHub Desktop.
This was a failed attempt to create a mdadm RAID1 xfs filesytem backed by two files on separate NVMe drives (with two separate BTRFS filesystems). Read performance was heavily degraded compared to just reading all files from a single btrfs filesystem.
#!/bin/bash
# Raid1 with XFS should perform well:
# https://www.phoronix.com/review/linux54-hdd-raid/3
#
# to benchmakr this, first outside llama.cpp we can do:
# $ sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
# $ time b3sum /mnt/gguf-unsloth-maverick/.../.../...1-of-4.gguf
set -euo pipefail
usage() {
echo " \$ $0 /opt/gguf-unsloth-maverick-backing-1-of-2/disk1.img /cache/gguf-unsloth-maverick-backing-2-of-2/disk2.img"
}
if [ $# -ne 2 ]; then
echo "Unexpected number of arguments, usage:"
usage
exit 1
fi
declare -a files
files=($1 $2)
set -x
for fn in ${files[@]}; do
if [ -e $fn ]; then
>&2 echo "File already exists, did not recreate it: $fn"
continue
fi
fallocate -l 160G $fn # my UD-Q2_K_XL checkout needs ~140GiB
chattr +C $fn # <-- this should already disable compression, no need for next line
#btrfs property set $fn compression no
done
for fn in ${files[@]}; do
if [ ! -e $fn ]; then
>&2 echo "Could not create file?: $fn"
exit 1
fi
done
lo1=$(sudo losetup --find --show $1)
lo2=$(sudo losetup --find --show $2)
if [ ! -d /mnt/gguf-unsloth-maverick ]; then
sudo mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 $lo1 $lo2
sudo mkfs.xfs -s size=4096 /dev/md0
sudo mkdir /mnt/gguf-unsloth-maverick
fi
sudo mount /dev/md0 /mnt/gguf-unsloth-maverick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment