Created
January 22, 2020 01:14
-
-
Save uroni/4671b3b5215e230babcd7561c6619a82 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| set -e -o pipefail | |
| SUBVOL=test | |
| SUBVOL_RO=test_ro | |
| DB_FILE=$SUBVOL/test.file | |
| NUM_ENTRIES=100000000 | |
| NUM_EXTENTS=100000 | |
| uname -a | |
| frags() { | |
| filefrag -v $DB_FILE | wc -l | |
| } | |
| mod_db() { | |
| echo "WITH RECURSIVE cnt_rnd(x, rnd) AS (VALUES(1, ABS(RANDOM())%$NUM_ENTRIES ) UNION ALL SELECT x+1, ABS(RANDOM())%$NUM_ENTRIES FROM cnt_rnd WHERE x<10000) UPDATE test SET rnd=RANDOM() WHERE x in (SELECT rnd FROM cnt_rnd);" | sqlite3 $DB_FILE | |
| } | |
| CREATE=1 | |
| if [[ $CREATE == 1 ]]; then | |
| if test -e $SUBVOL | |
| then | |
| btrfs subvol del $SUBVOL | |
| fi | |
| #! [ -e "$DB_FILE" ] || rm "$DB_FILE" | |
| btrfs subvol create $SUBVOL | |
| echo "CREATE TABLE test(x INTEGER PRIMARY KEY, rnd INTEGER); WITH RECURSIVE cnt(x, rnd) AS (VALUES(1, RANDOM()) UNION ALL SELECT x+1, RANDOM() FROM cnt WHERE x<$NUM_ENTRIES) INSERT INTO test (x, rnd) SELECT x, rnd FROM cnt;" | sqlite3 $DB_FILE | |
| fi # CREATE=1 | |
| if test -e $SUBVOL_RO | |
| then | |
| btrfs subvol del $SUBVOL_RO | |
| fi | |
| echo "Testing send without fragmentation..." | |
| sync | |
| echo 3 > /proc/sys/vm/drop_caches | |
| btrfs subvol snap -r $SUBVOL $SUBVOL_RO | |
| time btrfs send $SUBVOL_RO > /dev/null | |
| FRAGS=$(frags) | |
| while [ $FRAGS -lt $NUM_EXTENTS ] | |
| do | |
| echo "Currently $DB_FILE has $FRAGS extents..." | |
| for i in seq 0 10 | |
| do | |
| mod_db | |
| done | |
| FRAGS=$(frags) | |
| done | |
| echo "$DB_FILE has $FRAGS extents." | |
| if test -e $SUBVOL_RO | |
| then | |
| btrfs subvol del $SUBVOL_RO | |
| fi | |
| echo "Testing send with fragmentation..." | |
| btrfs subvol snap -r $SUBVOL $SUBVOL_RO | |
| mod_db | |
| sync | |
| echo 3 > /proc/sys/vm/drop_caches | |
| time btrfs send $SUBVOL_RO > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment