A ref change was pushed to the repository containing the project "Grayskull Repository". The branch, master has been updated via 633a91e55dab62f2552b52e311b721ed6c097985 (commit) via 0c4daab522ba0d4c3b3dc5f4a2d0595f8e6d7b1f (commit) via d493a790c1b1b1b3767260e3a9b01d9da67a2376 (commit) from 95873c5c5d7e07c2692a544706d2dd252a9619cd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 633a91e55dab62f2552b52e311b721ed6c097985 Author: Phil Carns <[email protected]> Date: Wed Dec 16 14:48:45 2009 -0500 bug fix to workload generator commit 0c4daab522ba0d4c3b3dc5f4a2d0595f8e6d7b1f Author: Phil Carns <[email protected]> Date: Wed Dec 16 14:34:34 2009 -0500 added program to generate benchmark workloads commit d493a790c1b1b1b3767260e3a9b01d9da67a2376 Author: Phil Carns <[email protected]> Date: Wed Dec 16 13:36:47 2009 -0500 minor cleanup of cosd benchmark ----------------------------------------------------------------------- Summary of changes: .../cosd-prototype/test/cosd-bench-concurrent.gs | 20 +-- .../gsl/resources/cosd-prototype/test/module.mk.in | 2 + .../resources/cosd-prototype/test/workload-gen.gs | 122 ++++++++++++++++++++ 3 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 code/src/gsl/resources/cosd-prototype/test/workload-gen.gs Diff of changes: diff --git a/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs b/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs index aa43467..7a9de2a 100644 --- a/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs +++ b/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs @@ -44,26 +44,23 @@ static __blocking int do_cosd_test(void) uint64_t out_oid1; uint64_t version; - printf("Creating oid 1 (if it doesn't already exist)...\n"); ret = gs_cosd_create(1, &out_oid1); - if(ret != 0 && ret != -EEXIST) + if(ret == -EEXIST) + { + printf("# operating on existing object.\n"); + } + else if(ret != 0) { printf("Error creating oid=1: %d\n", ret); return 1; } - printf("DONE\n"); - printf("Getting version number of oid 1...\n"); ret = gs_cosd_get_version(1, &version); if(ret != 0) { printf("Error getting version number for oid=1: %d\n", ret); return(1); } - printf("DONE: %llu\n", llu(version)); - - ret = gs_cosd_dump(); - assert(ret == 0); pwait { @@ -206,12 +203,11 @@ int main(int argc, char *argv[]) fclose(desc); if(mode == 1) - printf("Initializing cosd in poll-driven mode...\n"); + printf("# Initializing cosd in poll-driven mode.\n"); else - printf("Initializing cosd in thread-per-op mode...\n"); + printf("# Initializing cosd in thread-per-op mode.\n"); gs_cosd_init(mode, argv[3]); - printf("Done.\n"); gs_context_create(&ctx, 1, "cosd"); @@ -221,8 +217,6 @@ int main(int argc, char *argv[]) { pc++; gs_poll(ctx, 10000); - fflush(NULL); - printf("polled %d times...\n", pc); } gs_cosd_finalize(); diff --git a/code/src/gsl/resources/cosd-prototype/test/module.mk.in b/code/src/gsl/resources/cosd-prototype/test/module.mk.in index 78bca02..b0f2de9 100644 --- a/code/src/gsl/resources/cosd-prototype/test/module.mk.in +++ b/code/src/gsl/resources/cosd-prototype/test/module.mk.in @@ -2,5 +2,7 @@ DIR := resources/cosd-prototype/test GSTESTSRC += $(DIR)/cosd1.gs GSTESTSRC += $(DIR)/cosd-bench-concurrent.gs +GSTESTSRC += $(DIR)/workload-gen.gs + MODLIBS_$(DIR) = -lpthread @DB_LIB@ diff --git a/code/src/gsl/resources/cosd-prototype/test/workload-gen.gs b/code/src/gsl/resources/cosd-prototype/test/workload-gen.gs new file mode 100644 index 0000000..37db00a --- /dev/null +++ b/code/src/gsl/resources/cosd-prototype/test/workload-gen.gs @@ -0,0 +1,122 @@ +#include <stdio.h> +#include <errno.h> +#include <assert.h> +#include <stdlib.h> + +#include "../../../include/gs.h" +#include "../cosd-prototype.gsh" +#include "gs-config.h" + + +/* + * arguments: + * ./workload-gen <total size> <op size> <l|r> + */ + +/* TODO: this needs to be in a header somewhere */ +#ifndef llu +#if SIZEOF_LONG_INT == 4 +# define llu(x) (x) +# define lld(x) (x) +# define SCANF_lld lld +#elif SIZEOF_LONG_INT == 8 +# define llu(x) (unsigned long long)(x) +# define lld(x) (long long)(x) +# define SCANF_lld ld +#else +# error Unexpected sizeof(long int) +#endif +#endif + +int main(int argc, char **argv) +{ + int64_t total_size = -1; + int64_t op_size = -1; + int random_flag = 0; + int op_count = 0; + int64_t* offset_array; + int i; + int64_t current_offset = 0; + + if(argc != 4) + { + fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n", + argv[0]); + fprintf(stderr, " r=random, l=linear\n"); + return(-1); + } + +#if SIZEOF_LONG_INT == 4 + sscanf(argv[1], "%lld", &total_size); + sscanf(argv[2], "%lld", &op_size); +#else + sscanf(argv[1], "%ld", &total_size); + sscanf(argv[2], "%ld", &op_size); +#endif + + if(total_size < 1 || op_size < 1) + { + fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n", + argv[0]); + fprintf(stderr, " r=random, l=linear\n"); + return(-1); + } + + if(strcmp(argv[3], "l") == 0) + random_flag = 0; + else if(strcmp(argv[3], "r") == 0) + random_flag = 1; + else + { + fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n", + argv[0]); + fprintf(stderr, " r=random, l=linear\n"); + return(-1); + } + + if(total_size % op_size != 0) + { + fprintf(stderr, "Error: sizes must be evenly divisible.\n"); + return(-1); + } + + op_count = total_size/op_size; + + /* allocate one big array with all of the offset */ + offset_array = malloc(op_count*sizeof(int64_t)); + assert(offset_array); + + for(i=0; i<op_count; i++) + { + offset_array[i] = current_offset; + current_offset+= op_size; + } + + if(random_flag && op_count > 1) + { + for(i=0; i<(op_count-1); i++) + { + int j = i + rand() / (RAND_MAX / (op_count-i) + 1); + int64_t t = offset_array[j]; + offset_array[j] = offset_array[i]; + offset_array[i] = t; + } + } + + printf("# <op> <offset> <size>\n"); + for(i=0; i<op_count; i++) + { + printf("write\t%lld\t%lld\n", lld(offset_array[i]), lld(op_size)); + } + + return(0); +} + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ft=c ts=8 sts=4 sw=4 expandtab + */ hooks/post-receive -- Grayskull Repository