Last active
December 18, 2015 03:59
-
-
Save smoser/5722502 to your computer and use it in GitHub Desktop.
demonstrate time to clone a ephemeral disk image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== size=10G LABEL=ephemeral0 FSTYPE=ext3 === | |
truncate real: 0m0.053s user: 0m0.000s sys: 0m0.000s | |
mkfs.ext3 real: 0m8.295s user: 0m0.008s sys: 0m0.584s | |
cp working o real: 0m0.284s user: 0m0.048s sys: 0m0.216s | |
cp working q real: 0m0.162s user: 0m0.036s sys: 0m0.120s | |
rm working real: 0m0.083s user: 0m0.000s sys: 0m0.080s | |
sync real: 0m1.608s user: 0m0.000s sys: 0m0.000s | |
flush cache real: 0m0.748s user: 0m0.004s sys: 0m0.032s | |
[1] cp new real: 0m1.226s user: 0m0.000s sys: 0m0.048s | |
[1] qcow create real: 0m1.990s user: 0m0.012s sys: 0m0.028s | |
[2] cp new real: 0m0.037s user: 0m0.000s sys: 0m0.032s | |
[2] qcow create real: 0m0.111s user: 0m0.008s sys: 0m0.016s | |
e2label real: 0m0.999s user: 0m0.000s sys: 0m0.036s | |
tune2fs real: 0m0.206s user: 0m0.004s sys: 0m0.004s | |
6.2M ephemeral0_ext3_10G.img | |
6.2M ephemeral0_ext3_10G.qcow2 | |
6.2M new.img | |
136K new.qcow2 | |
=== size=20G LABEL=ephemeral0 FSTYPE=ext3 === | |
truncate real: 0m0.023s user: 0m0.000s sys: 0m0.004s | |
mkfs.ext3 real: 0m15.542s user: 0m0.020s sys: 0m0.896s | |
cp working o real: 0m0.641s user: 0m0.144s sys: 0m0.492s | |
cp working q real: 0m0.248s user: 0m0.060s sys: 0m0.184s | |
rm working real: 0m0.131s user: 0m0.000s sys: 0m0.128s | |
sync real: 0m2.908s user: 0m0.004s sys: 0m0.000s | |
flush cache real: 0m0.706s user: 0m0.000s sys: 0m0.044s | |
[1] cp new real: 0m1.901s user: 0m0.004s sys: 0m0.072s | |
[1] qcow create real: 0m2.190s user: 0m0.012s sys: 0m0.028s | |
[2] cp new real: 0m0.056s user: 0m0.008s sys: 0m0.048s | |
[2] qcow create real: 0m0.164s user: 0m0.008s sys: 0m0.016s | |
e2label real: 0m1.582s user: 0m0.004s sys: 0m0.056s | |
tune2fs real: 0m0.249s user: 0m0.004s sys: 0m0.004s | |
11M ephemeral0_ext3_20G.img | |
11M ephemeral0_ext3_20G.qcow2 | |
11M new.img | |
136K new.qcow2 | |
=== size=100G LABEL=ephemeral0 FSTYPE=ext3 === | |
truncate real: 0m0.022s user: 0m0.000s sys: 0m0.004s | |
mkfs.ext3 real: 1m5.541s user: 0m0.156s sys: 0m4.388s | |
cp working o real: 0m1.024s user: 0m0.336s sys: 0m0.684s | |
cp working q real: 0m0.940s user: 0m0.216s sys: 0m0.720s | |
rm working real: 0m0.563s user: 0m0.000s sys: 0m0.556s | |
sync real: 0m13.101s user: 0m0.000s sys: 0m0.004s | |
flush cache real: 0m0.643s user: 0m0.004s sys: 0m0.068s | |
[1] cp new real: 0m6.992s user: 0m0.000s sys: 0m0.228s | |
[1] qcow create real: 0m1.951s user: 0m0.008s sys: 0m0.032s | |
[2] cp new real: 0m0.107s user: 0m0.008s sys: 0m0.096s | |
[2] qcow create real: 0m0.118s user: 0m0.008s sys: 0m0.000s | |
e2label real: 0m6.140s user: 0m0.004s sys: 0m0.264s | |
tune2fs real: 0m0.298s user: 0m0.000s sys: 0m0.008s | |
31M ephemeral0_ext3_100G.img | |
31M ephemeral0_ext3_100G.qcow2 | |
31M new.img | |
136K new.qcow2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SIZE=${1:-20G} | |
LABEL="ephemeral0" | |
FSTYPE="ext3" | |
export TIMEFORMAT='real: %3lR user: %3lU sys: %3lS' | |
IMG_ORIG="${LABEL}_${FSTYPE}_${SIZE}.img" | |
IMG_NEW="new.img" | |
QIMG_ORIG="${IMG_ORIG%.img}.qcow2" | |
QIMG_NEW="${IMG_NEW%.img}.qcow2" | |
IMG_WORKING="$IMG.WORKING" | |
rm -f "$IMG_ORIG" "$IMG_NEW" "$QIMG_ORIG" "$QIMG_NEW" "$IMG_WORKING" | |
timeit() { | |
local out="" | |
printf "%-18s" "$1" | |
local sudo="" | |
[ "${SUDO:-0}" = "0" ] || sudo="sudo" | |
time $sudo bash -fc "$2 >/dev/null 2>/dev/null" </dev/null | |
} | |
echo "=== size=$SIZE LABEL=$LABEL FSTYPE=$FSTYPE ===" | |
timeit "truncate" "truncate --size $SIZE $IMG_WORKING" | |
timeit "mkfs.$FSTYPE" "mkfs.$FSTYPE -F -L $LABEL $IMG_WORKING" | |
timeit "cp working o" "cp --sparse=always $IMG_WORKING $IMG_ORIG" | |
timeit "cp working q" "cp --sparse=always $IMG_WORKING $QIMG_ORIG" | |
timeit "rm working" "rm -f $IMG_WORKING" | |
timeit "sync" "sync" | |
SUDO=1 timeit "flush cache" "echo 3 | tee /proc/sys/vm/drop_caches" | |
for pass in 1 2; do | |
rm -f $QIMG_NEW $IMG_NEW | |
timeit "[$pass] cp new" "cp --sparse=always $IMG_ORIG $IMG_NEW" | |
timeit "[$pass] qcow create" "qemu-img create -f qcow2 -b $QIMG_ORIG $QIMG_NEW" | |
done | |
timeit "e2label" "e2label $IMG_NEW new_label" | |
timeit "tune2fs" "tune2fs -U \$(uuidgen) $IMG_NEW" | |
ls -1hs $IMG_ORIG $IMG_NEW $QIMG_ORIG $QIMG_NEW |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment