From a552cfe5de077ccd0236a387f1aed5924ed62663 Mon Sep 17 00:00:00 2001 From: Nathan Rutman Date: Mon, 9 Aug 2010 12:20:29 -0700 Subject: [PATCH] b=21720 fix test 18 to interleave tests increase pass margin i=rread backport 2.0's fractional-second createmany --- lustre/tests/createmany.c | 163 +++++++++++++++++++++++++++++++--------------- lustre/tests/ost-pools.sh | 96 ++++++++++++++------------- 2 files changed, 161 insertions(+), 98 deletions(-) diff --git a/lustre/tests/createmany.c b/lustre/tests/createmany.c index 3ae06cb..3151f2f 100644 --- a/lustre/tests/createmany.c +++ b/lustre/tests/createmany.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -37,75 +37,117 @@ #include #include #include +#include #include #include #include #include #include #include +#include -void usage(char *prog) +static void usage(char *prog) { - printf("usage: %s {-o|-m|-d|-l} filenamefmt count\n", prog); - printf(" %s {-o|-m|-d|-l} filenamefmt -seconds\n", prog); - printf(" %s {-o|-m|-d|-l} filenamefmt start count\n", prog); + printf("usage: %s {-o|-m|-d|-l} [-r altpath ] filenamefmt count\n", prog); + printf(" %s {-o|-m|-d|-l} [-r altpath ] filenamefmt ] -seconds\n", prog); + printf(" %s {-o|-m|-d|-l} [-r altpath ] filenamefmt start count\n", prog); + exit(EXIT_FAILURE); } -int main(int argc, char ** argv) +static char *get_file_name(const char *fmt, long n, int has_fmt_spec) { - int i, rc = 0, do_open = 0, do_link = 0, do_mkdir = 0; - char format[4096], *fmt, *tgt = NULL; - char filename[4096]; - long start, last, end; - long begin = 0, count; + static char filename[4096]; + int bytes; - if (argc < 4 || argc > 5) { - usage(argv[0]); - return 1; + bytes = has_fmt_spec ? snprintf(filename, 4095, fmt, n) : + snprintf(filename, 4095, "%s%ld", fmt, n); + if (bytes >= 4095) { + printf("file name too long\n"); + exit(EXIT_FAILURE); } + return filename; +} - if (strcmp(argv[1], "-d") == 0) { - do_mkdir = 1; - } else if (strcmp(argv[1], "-o") == 0) { - do_open = 1; - } else if (strncmp(argv[1], "-l", 2) == 0 && argv[1][2]) { - tgt = argv[1] + 2; - do_link = 1; - } else if (strcmp(argv[1], "-m") != 0) { - usage(argv[0]); - return 1; - } +double now(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; +} - if (strlen(argv[2]) > 4080) { - printf("name too long\n"); - return 1; - } +int main(int argc, char ** argv) +{ + long i; + int rc = 0, do_open = 0, do_link = 0, do_mkdir = 0; + int do_unlink = 0, do_mknod = 0; + char *filename; + char *fmt = NULL, *fmt_unlink = NULL, *tgt = NULL; + double start, last; + long begin = 0, end = ~0UL >> 1, count = ~0UL >> 1; + int c, has_fmt_spec = 0, unlink_has_fmt_spec = 0; - start = last = time(0); + /* Handle the last argument in form of "-seconds" */ + if (argc > 1 && argv[argc - 1][0] == '-') { + char *endp; - if (argc == 4) { - end = strtol(argv[3], NULL, 0); - } else { - begin = strtol(argv[3], NULL, 0); - end = strtol(argv[4], NULL, 0); + argc--; + end = strtol(argv[argc] + 1, &endp, 0); + if (end <= 0 || *endp != '\0') + usage(argv[0]); + end = end + time(NULL); } - if (end > 0) { - count = end; - end = -1UL >> 1; - } else { - end = start - end; - count = -1UL >> 1; + while ((c = getopt(argc, argv, "omdl:r:")) != -1) { + switch(c) { + case 'o': + do_open++; + break; + case 'm': + do_mknod++; + break; + case 'd': + do_mkdir++; + break; + case 'l': + do_link++; + tgt = optarg; + break; + case 'r': + do_unlink++; + fmt_unlink = optarg; + break; + case '?': + printf("Unknown option '%c'\n", optopt); + usage(argv[0]); + } } - if (strchr(argv[2], '%')) - fmt = argv[2]; - else { - sprintf(format, "%s%%d", argv[2]); - fmt = format; + if (do_open + do_mkdir + do_link + do_mknod != 1 || + do_unlink > 1) + usage(argv[0]); + + switch (argc - optind) { + case 3: + begin = strtol(argv[argc - 2], NULL, 0); + case 2: + count = strtol(argv[argc - 1], NULL, 0); + if (end != ~0UL >> 1) + usage(argv[0]); + case 1: + fmt = argv[optind]; + break; + default: + usage(argv[0]); } - for (i = 0; i < count && time(0) < end; i++, begin++) { - sprintf(filename, fmt, begin); + + start = last = now(); + + has_fmt_spec = strchr(fmt, '%') != NULL; + if (do_unlink) + unlink_has_fmt_spec = strchr(fmt_unlink, '%') != NULL; + + for (i = 0; i < count && time(NULL) < end; i++, begin++) { + filename = get_file_name(fmt, begin, has_fmt_spec); if (do_open) { int fd = open(filename, O_CREAT|O_RDWR, 0644); if (fd < 0) { @@ -140,14 +182,27 @@ int main(int argc, char ** argv) break; } } - if ((i % 10000) == 0) { - printf(" - created %d (time %ld total %ld last %ld)\n", - i, time(0), time(0) - start, time(0) - last); - last = time(0); + if (do_unlink) { + filename = get_file_name(fmt_unlink, begin, + unlink_has_fmt_spec); + rc = do_mkdir ? rmdir(filename) : unlink(filename); + if (rc) { + printf("unlink(%s) error: %s\n", + filename, strerror(errno)); + rc = errno; + break; + } + } + + if (i && (i % 10000) == 0) { + printf(" - created %ld (time %.2f total %.2f last %.2f)" + "\n", i, now(), now() - start, now() - last); + last = now(); } } - printf("total: %d creates in %ld seconds: %f creates/second\n", i, - time(0) - start, ((float)i / (time(0) - start))); + printf("total: %ld creates%s in %.2f seconds: %.2f creates/second\n", i, + do_unlink ? "/deletions" : "", + now() - start, ((double)i / (now() - start))); return rc; } diff --git a/lustre/tests/ost-pools.sh b/lustre/tests/ost-pools.sh index bb5b29b..ea73cad 100644 --- a/lustre/tests/ost-pools.sh +++ b/lustre/tests/ost-pools.sh @@ -926,71 +926,79 @@ test_17() { } run_test 17 "Referencing an empty pool" -create_perf_one() { - local dir=$1/d +create_perf() { + local cdir=$1/d local numfiles=$2 local time - mkdir -p $dir + mkdir -p $cdir sync; sleep 5 # give pending IO a chance to go to disk - stat=$(createmany -o $dir/${tfile} $numfiles) - rm -rf $dir + stat=$(createmany -o $cdir/${tfile} $numfiles | tail -1) + rm -rf $cdir sync time=$(echo $stat | cut -f 5 -d ' ') - echo $stat > /dev/stderr + echo $stat >> /dev/stderr echo $time } -create_perf() { - local t1=$(create_perf_one $1 $2) - local t2=$(create_perf_one $1 $2) - local t3=$(create_perf_one $1 $2) - local time=$(echo "scale=2; ( $t1 + $t2 + $t3 ) / 3" | bc) - - echo "$time" -} - test_18() { local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir} - local numfiles=10000 - local i=0 - local time1 - local time2 - local time3 - local dir=$POOL_ROOT/dir - local stat - local diff - - time1=$(create_perf $dir $numfiles) - - create_pool_nofail $POOL - - add_pool $POOL $TGT_ALL "$TGT_UUID" + local numfiles=9877 + local plaindir=$POOL_ROOT/plaindir + local pooldir=$POOL_ROOT/pooldir + local t1=0 + local t2=0 + local t3=0 + local diff + + for i in $(seq 1 3); + do + echo "Create performance, iteration $i, $numfiles files x 3" - create_dir $dir $POOL - time2=$(create_perf $dir $numfiles) + time1=$(create_perf $plaindir $numfiles) + echo "iter $i: $numfiles creates without pool: $time1" + t1=$(echo "scale=2; $t1 + $time1" | bc) - destroy_pool $POOL + create_pool_nofail $POOL > /dev/null + add_pool $POOL $TGT_ALL "$TGT_UUID" > /dev/null + create_dir $pooldir $POOL + time2=$(create_perf $pooldir $numfiles) + echo "iter $i: $numfiles creates with pool: $time2" + t2=$(echo "scale=2; $t2 + $time2" | bc) - time3=$(create_perf $dir $numfiles) + destroy_pool $POOL > /dev/null + time3=$(create_perf $pooldir $numfiles) + echo "iter $i: $numfiles creates with missing pool: $time3" + t3=$(echo "scale=2; $t3 + $time3" | bc) - echo Time taken for $numfiles creates without pools: $time1 - echo Time taken for $numfiles creates with pools: $time2 - echo Time taken for $numfiles creates without pools: $time3 + echo + done - deg=$(echo "scale=2; (($time2 - $time3) * 100 / $time3) > 5" | bc) - diff=$(echo "scale=2; ($time2 - $time3) * 100 / $time3" | bc) + time1=$(echo "scale=2; $t1 / $i" | bc) + echo Avg time taken for $numfiles creates without pool: $time1 + time2=$(echo "scale=2; $t2 / $i" | bc) + echo Avg time taken for $numfiles creates with pool: $time2 + time3=$(echo "scale=2; $t3 / $i" | bc) + echo Avg time taken for $numfiles creates with missing pool: $time3 + + # Set this high until we establish a baseline for what the degradation + # is / should be + max=30 + diff=$(echo "scale=2; ($time2 - $time1) * 100 / $time1" | bc) + echo "No pool to wide pool: $diff %." + deg=$(echo "scale=2; $diff > $max" | bc) + [ "$deg" == "1" ] && error "Degradation with wide pool is $diff % (> $max %)" + + max=15 + diff=$(echo "scale=2; ($time3 - $time1) * 100 / $time1" | bc) + echo "No pool to missing pool: $diff %." + deg=$(echo "scale=2; $diff > $max" | bc) + [ "$deg" == "1" ] && error "Degradation with missing pool is $diff % (> $max %)" - if [[ "$deg" == "1" ]]; then - error "Performance degradation with pools is $diff %." - else - echo "Performance degradation with pools is $diff %." - fi return 0 } run_test 18 "File create in a directory which references a deleted pool" - test_19() { local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir} local numfiles=12 -- 1.8.3.1