add no-op network call, and a simple benchmark that exercises it

git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@980 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
sears 2010-08-09 20:21:41 +00:00
parent dc75f6d1f0
commit 2a45c2cda8
5 changed files with 87 additions and 4 deletions

View file

@ -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++)

View file

@ -0,0 +1 @@
CREATE_CLIENT_EXECUTABLE(tcpclient_noop)

View file

@ -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 <sys/time.h>
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;
}

View file

@ -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;
}

View file

@ -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;