Skip to content

Commit

Permalink
add --latency-marker-skip <N> to ignore the first occurrences of a ma…
Browse files Browse the repository at this point in the history
…rker
  • Loading branch information
Lev Walkin committed May 15, 2015
1 parent f83b218 commit fda7d72
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

0.?: ?
* --latency-marker-skip <N> to ignore the first occurrences of a marker.

0.6: 2015-May-13
* Parse \{connection.uid} type expressions in
--first-message, --message, --latency-marker parameters,
Expand Down
14 changes: 14 additions & 0 deletions src/tcpkali.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static struct option cli_long_options[] = {
{ "first-message-file", 1, 0, 'F' },
{ "help", 0, 0, 'h' },
{ "latency-marker", 1, 0, 'L' },
{ "latency-marker-skip", 1, 0, 'S' },
{ "listen-port", 1, 0, 'l' },
{ "message", 1, 0, 'm' },
{ "message-file", 1, 0, 'f' },
Expand Down Expand Up @@ -415,6 +416,18 @@ int main(int argc, char **argv) {
}
}
break;
case 'S': { /* --latency-marker-skip */
engine_params.latency_marker_skip =
parse_with_multipliers(option, optarg,
km_multiplier,
sizeof(km_multiplier)/sizeof(km_multiplier[0]));
if(engine_params.latency_marker_skip < 0) {
fprintf(stderr, "--latency-marker-skip: "
"Failed to parse or out of range expression\n");
exit(EX_USAGE);
}
}
break;
default:
fprintf(stderr, "%s: unknown option\n", option);
usage(argv[0], &default_config);
Expand Down Expand Up @@ -949,6 +962,7 @@ usage(char *argv0, struct tcpkali_config *conf) {
" -r, --message-rate <R> Messages per second to send in a connection\n"
"\n"
" --latency-marker <string> Measure latency using a per-message marker\n"
" --latency-marker-skip <N> Ignore the first N occurrences of a marker\n"
"\n"
" --statsd Enable StatsD output (default %s)\n"
" --statsd-host <host> StatsD host to send data (default is localhost)\n"
Expand Down
21 changes: 20 additions & 1 deletion src/tcpkali_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct connection {
struct ring_buffer *sent_timestamps;
struct hdr_histogram *histogram;
unsigned message_bytes_credit; /* See (EXPL:1) below. */
unsigned lm_occurrences_skip; /* See --latency-marker-skip */
/* Boyer-Moore-Horspool substring search algorithm data */
struct StreamBMH *sbmh_ctx;
/* The following fields might be shared across connections. */
Expand Down Expand Up @@ -1007,6 +1008,11 @@ static void start_new_connection(TK_P) {
if(largs->params.latency_marker && conn->data.single_message_size) {
conn->latency.message_bytes_credit /* See (EXPL:1) below. */
= conn->data.single_message_size - 1;
/*
* Figure out how many latency markers to skip
* before starting to measure latency with them.
*/
conn->latency.lm_occurrences_skip = largs->params.latency_marker_skip;

/*
* Initialize the Boyer-Moore-Horspool context for substring search.
Expand Down Expand Up @@ -1415,7 +1421,7 @@ static void latency_record_incoming_ts(TK_P_ struct connection *conn, char *buf,

const uint8_t *lm = conn->latency.sbmh_data;
size_t lm_size = conn->latency.sbmh_size;
int num_markers_found = 0;
unsigned num_markers_found = 0;

for(; size > 0; ) {
size_t analyzed = sbmh_feed(conn->latency.sbmh_ctx,
Expand All @@ -1431,6 +1437,19 @@ static void latency_record_incoming_ts(TK_P_ struct connection *conn, char *buf,
}
}

/*
* Skip the necessary numbers of markers.
*/
if(conn->latency.lm_occurrences_skip) {
if(num_markers_found <= conn->latency.lm_occurrences_skip) {
conn->latency.lm_occurrences_skip -= num_markers_found;
return;
} else {
num_markers_found -= conn->latency.lm_occurrences_skip;
conn->latency.lm_occurrences_skip = 0;
}
}

/*
* Now, for all found markers extract and use the corresponding
* end-to-end message latency.
Expand Down
1 change: 1 addition & 0 deletions src/tcpkali_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct engine_params {
struct message_collection message_collection; /* A descr. what to send */
struct transport_data_spec *data_template;
tk_expr_t *latency_marker; /* --latency-marker */
int latency_marker_skip; /* --latency-marker-skip <N> */
struct StreamBMH_Occ sbmh_shared_occ; /* Streaming Boyer-Moore-Horspool */
};

Expand Down

0 comments on commit fda7d72

Please sign in to comment.