diff --git a/CMakeLists.txt b/CMakeLists.txt index 0adc23e..adc73d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ Project(Stasis) SET(PACKAGE_VERSION 1) -SUBDIRS(test util) +SUBDIRS(test util benchmarks) # Main decisions SET(BUILD_SHARED_LIBS ON) @@ -55,7 +55,7 @@ if(NOT HAVE_STASIS) message(STATUS "stasis not found; only building client library") endif(NOT HAVE_STASIS) -SET(CLIENT_LIBRARIES logstore_client) +SET(CLIENT_LIBRARIES logstore_client pthread) IF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" ) SET(COMMON_LIBRARIES logstore stasis m pthread stdc++) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt new file mode 100644 index 0000000..83a25e8 --- /dev/null +++ b/benchmarks/CMakeLists.txt @@ -0,0 +1 @@ +CREATE_CLIENT_EXECUTABLE(tcpclient_noop) diff --git a/benchmarks/tcpclient_noop.cpp b/benchmarks/tcpclient_noop.cpp new file mode 100644 index 0000000..bc0838c --- /dev/null +++ b/benchmarks/tcpclient_noop.cpp @@ -0,0 +1,75 @@ +/* + * tcpclient_noop.cpp + * + * Created on: Feb 23, 2010 + * Author: sears + */ + +#include "../tcpclient.h" +#include "../network.h" +#include "../datatuple.h" + +void usage(char * argv[]) { + fprintf(stderr, "usage %s numthreads threadopcount [host [port]]\n", argv[0]); +} + +#include "../util/util_main.h" +#include +int threadopcount; + +int thrargc; +char ** thrargv; + +void * worker (void * arg) { + logstore_handle_t * l = util_open_conn(thrargc-2, thrargv+2); + for(int i = 0; i < threadopcount; i++) { + datatuple * ret = logstore_client_op(l, OP_DBG_NOOP); + if(ret == NULL) { + perror("No-op failed"); return (void*)-1; + } else { + datatuple::freetuple(ret); + } + } + logstore_client_close(l); + return 0; +} + +int main(int argc, char * argv[]) { + if(argc < 3) { + usage(argv); + return 1; + } + thrargc = argc; + thrargv = argv; + + int numthreads = atoi(argv[1]); + threadopcount = (atoi(argv[2])/numthreads); + + pthread_t * threads = (pthread_t*)malloc(sizeof(*threads) * numthreads); + + struct timeval start, stop; + gettimeofday(&start, 0); + for(int i = 0; i < numthreads; i++) { + pthread_create(&threads[i], 0, worker, 0); + } + int had_err = 0; + for(int i = 0; i < numthreads; i++) { + void * err; + pthread_join(threads[i], &err); + if(err) { + had_err = 1; + } + } + gettimeofday(&stop,0); + if(!had_err) { + double startf = ((double)start.tv_sec) + (double)start.tv_usec / 1000000.0; + double stopf = ((double)stop.tv_sec) + (double)stop.tv_usec / 1000000.0; + double elapsed = stopf -startf; + printf("%5d threads, %6d ops/thread, %6.2f seconds, %7.1f ops/thread-second, %6.1f ops/sec\n", + numthreads, threadopcount, elapsed, ((double)threadopcount)/elapsed, (((double)numthreads)*(double)threadopcount)/elapsed); + } + free(threads); + return 0; + +} + diff --git a/logserver.cpp b/logserver.cpp index 8b2cf20..03de589 100644 --- a/logserver.cpp +++ b/logserver.cpp @@ -796,6 +796,9 @@ int op_dbg_drop_database(pthread_data * data) { fprintf(stderr, "...DROP DATABASE COMPLETE\n"); return writeoptosocket(*(data->workitem), LOGSTORE_RESPONSE_SUCCESS); } +int op_dbg_noop(pthread_data * data) { + return writeoptosocket(*(data->workitem), LOGSTORE_RESPONSE_SUCCESS); +} int dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, pthread_data* data) { int err = 0; @@ -841,6 +844,9 @@ int dispatch_request(network_op_t opcode, datatuple * tuple, datatuple * tuple2, { err = op_dbg_drop_database(data); } + else if(opcode == OP_DBG_NOOP) { + err = op_dbg_noop(data); + } return err; } diff --git a/network.h b/network.h index 4da28b3..1d566c5 100644 --- a/network.h +++ b/network.h @@ -43,9 +43,10 @@ static const network_op_t OP_STAT_PERF_REPORT = 15; static const network_op_t OP_STAT_HISTOGRAM = 16; // Return N approximately equal size partitions (including split points + cardinalities) N=1 estimates table cardinality. -static const network_op_t OP_DBG_DROP_DATABASE = 17; +static const network_op_t OP_DBG_DROP_DATABASE = 17; static const network_op_t OP_DBG_BLOCKMAP = 18; -static const network_op_t LOGSTORE_LAST_REQUEST_CODE = 18; +static const network_op_t OP_DBG_NOOP = 19; +static const network_op_t LOGSTORE_LAST_REQUEST_CODE = 19; //error codes static const network_op_t LOGSTORE_FIRST_ERROR = 27;