From 8ef7ddbf895d0126f578fcc46d2cb292addddf2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Jan 2008 17:27:36 +1100 Subject: added latency reporting (This used to be commit f0ffbb8e19c1085bf54d226f62c667868e14f62e) --- source4/torture/raw/offline.c | 57 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'source4/torture/raw') diff --git a/source4/torture/raw/offline.c b/source4/torture/raw/offline.c index 4b7d108b0f..754185ec62 100644 --- a/source4/torture/raw/offline.c +++ b/source4/torture/raw/offline.c @@ -44,15 +44,20 @@ static int test_failed; extern int torture_numops; static bool test_finished; +enum offline_op {OP_LOADFILE, OP_SAVEFILE, OP_SETOFFLINE, OP_GETOFFLINE, OP_ENDOFLIST}; + +static double latencies[OP_ENDOFLIST]; +static double worst_latencies[OP_ENDOFLIST]; + #define FILE_SIZE 8192 -enum offline_op {OP_LOADFILE, OP_SAVEFILE, OP_SETOFFLINE, OP_GETOFFLINE, OP_ENDOFLIST}; struct offline_state { struct torture_context *tctx; struct event_context *ev; struct smbcli_tree *tree; TALLOC_CTX *mem_ctx; + int client; int fnum; uint32_t count; uint32_t lastcount; @@ -64,6 +69,7 @@ struct offline_state { struct smb_composite_savefile *savefile; struct smbcli_request *req; enum offline_op op; + struct timeval tv_start; }; static void test_offline(struct offline_state *state); @@ -208,6 +214,12 @@ static void getoffline_callback(struct smbcli_request *req) static void test_offline(struct offline_state *state) { struct composite_context *ctx; + double lat; + + lat = timeval_elapsed(&state->tv_start); + if (latencies[state->op] < lat) { + latencies[state->op] = lat; + } state->op = (enum offline_op) (random() % OP_ENDOFLIST); @@ -215,6 +227,8 @@ static void test_offline(struct offline_state *state) talloc_free(state->fname); state->fname = filename(state->mem_ctx, state->fnumber); + state->tv_start = timeval_current(); + switch (state->op) { case OP_LOADFILE: state->loadfile = talloc_zero(state->mem_ctx, struct smb_composite_loadfile); @@ -258,6 +272,9 @@ static void test_offline(struct offline_state *state) io.setattr.level = RAW_SFILEINFO_SETATTR; io.setattr.in.attrib = FILE_ATTRIBUTE_OFFLINE; io.setattr.in.file.path = state->fname; + /* make the file 1 hour old, to get past mininum age restrictions + for HSM systems */ + io.setattr.in.write_time = time(NULL) - 60*60; state->req = smb_raw_setpathinfo_send(state->tree, &io); if (state->req == NULL) { @@ -316,16 +333,32 @@ static void report_rate(struct event_context *ev, struct timed_event *te, struct offline_state *state = talloc_get_type(private_data, struct offline_state); int i; - uint32_t total=0; + uint32_t total=0, total_offline=0, total_online=0; for (i=0;i latencies[state[i].op]) { + latencies[state[i].op] = timeval_elapsed(&state[i].tv_start); + } state[i].lastcount = state[i].count; + total_online += state[i].online_count; + total_offline += state[i].offline_count; } - printf("ops=%6u offline_count=%6u online_count=%6u\r", - total, state->offline_count, state->online_count); + printf("ops/s=%4u offline=%5u online=%4u set_lat=%.1f get_lat=%.1f save_lat=%.1f load_lat=%.1f\r", + total, total_offline, total_online, + latencies[OP_SETOFFLINE], + latencies[OP_GETOFFLINE], + latencies[OP_SAVEFILE], + latencies[OP_LOADFILE]); fflush(stdout); event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state); + for (i=0;i worst_latencies[i]) { + worst_latencies[i] = latencies[i]; + } + latencies[i] = 0; + } + /* send an echo on each interface to ensure it stays alive - this helps with IP takeover */ for (i=0;itree; + state[i].client = i; + /* allow more time for offline files */ + state[i].tree->session->transport->options.request_timeout = 200; } /* the others are repeats on the earlier connections */ @@ -383,6 +419,7 @@ bool torture_test_offline(struct torture_context *torture) state[i].mem_ctx = talloc_new(state); state[i].ev = ev; state[i].tree = state[i % nconnections].tree; + state[i].client = i; } num_connected = i; @@ -392,6 +429,7 @@ bool torture_test_offline(struct torture_context *torture) } /* pre-create files */ + printf("Pre-creating %u files ....\n", torture_numops); for (i=0;i