aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-05-18 19:33:00 -0700
committerDamjan Marion <dmarion@me.com>2021-05-20 10:04:14 +0000
commit733a26e787a789fa5d7ebdafd9826071a5270855 (patch)
tree4ab6ec2e5c906ee8a06b55c4ba40415d14b68bde /src/plugins
parente3c6a54995b052045709b1d80039eede1757f43f (diff)
hsa: test server incremental stats
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ie8ec924ebaf006f1df84a1013050114831144a79
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test.h60
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_client.c2
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_server.c44
3 files changed, 71 insertions, 35 deletions
diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h
index f1e6bc4eb6c..c22eccc629b 100644
--- a/src/plugins/hs_apps/vcl/vcl_test.h
+++ b/src/plugins/hs_apps/vcl/vcl_test.h
@@ -65,7 +65,7 @@
#define VCL_TEST_CFG_TXBUF_SIZE_DEF 8192
#define VCL_TEST_CFG_RXBUF_SIZE_DEF (64*VCL_TEST_CFG_TXBUF_SIZE_DEF)
#define VCL_TEST_CFG_BUF_SIZE_MIN 128
-#define VCL_TEST_CFG_MAX_TEST_SESS 32
+#define VCL_TEST_CFG_MAX_TEST_SESS 512
#define VCL_TEST_CFG_MAX_EPOLL_EVENTS 16
#define VCL_TEST_CTRL_LISTENER (~0 - 1)
@@ -415,16 +415,30 @@ vcl_test_time_diff (struct timespec *old, struct timespec *new)
}
static inline void
-vcl_test_stats_dump_inc (vcl_test_stats_t *old, vcl_test_stats_t *new)
+vcl_test_stats_dump_inc (vcl_test_session_t *ts, int is_rx)
{
+ vcl_test_stats_t *old, *new;
double duration, rate;
uint64_t total_bytes;
+ char *dir_str;
+ old = &ts->old_stats;
+ new = &ts->stats;
duration = vcl_test_time_diff (&old->stop, &new->stop);
- total_bytes = new->tx_bytes - old->tx_bytes;
+ if (is_rx)
+ {
+ total_bytes = new->rx_bytes - old->rx_bytes;
+ dir_str = "Received";
+ }
+ else
+ {
+ total_bytes = new->tx_bytes - old->tx_bytes;
+ dir_str = "Sent";
+ }
+
rate = (double) total_bytes * 8 / duration / 1e9;
- printf ("Sent %lu Mbytes in %.2lf seconds %.2lf Gbps\n",
+ printf ("%d: %s %lu Mbytes in %.2lf seconds %.2lf Gbps\n", ts->fd, dir_str,
(uint64_t) (total_bytes / 1e6), duration, rate);
}
@@ -447,33 +461,32 @@ static inline int
vcl_test_read (vcl_test_session_t *ts, void *buf, uint32_t nbytes)
{
vcl_test_stats_t *stats = &ts->stats;
- int rx_bytes;
+ int rv, rx_bytes = 0;
do
{
stats->rx_xacts++;
- rx_bytes = vppcom_session_read (ts->fd, buf, nbytes);
-
- if (rx_bytes < 0)
+ rv = vppcom_session_read (ts->fd, buf, nbytes);
+ if (rv <= 0)
{
- errno = -rx_bytes;
- rx_bytes = -1;
+ errno = -rv;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ {
+ stats->rx_eagain++;
+ continue;
+ }
+
+ vterr ("vppcom_session_read()", -errno);
+ break;
}
- if ((rx_bytes == 0) ||
- ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))))
- stats->rx_eagain++;
- else if (rx_bytes < nbytes)
+
+ rx_bytes = rv;
+ if (rv < nbytes)
stats->rx_incomp++;
}
- while ((rx_bytes == 0) ||
- ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
+ while (!rx_bytes);
- if (rx_bytes < 0)
- {
- vterr ("vppcom_session_read()", -errno);
- }
- else
- stats->rx_bytes += rx_bytes;
+ stats->rx_bytes += rx_bytes;
return (rx_bytes);
}
@@ -533,7 +546,8 @@ vcl_test_write (vcl_test_session_t *ts, void *buf, uint32_t nbytes)
nbytes_left = nbytes_left - rv;
buf += rv;
- stats->tx_incomp++;
+ if (rv < nbytes_left)
+ stats->tx_incomp++;
}
while (tx_bytes != nbytes);
diff --git a/src/plugins/hs_apps/vcl/vcl_test_client.c b/src/plugins/hs_apps/vcl/vcl_test_client.c
index d16d62ce63c..4a9fb46e5b8 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_client.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_client.c
@@ -303,7 +303,7 @@ vtc_inc_stats_check (vcl_test_session_t *ts)
clock_gettime (CLOCK_REALTIME, &ts->stats.stop);
if (vcl_test_time_diff (&ts->old_stats.stop, &ts->stats.stop) > 1)
{
- vcl_test_stats_dump_inc (&ts->old_stats, &ts->stats);
+ vcl_test_stats_dump_inc (ts, 0 /* is_rx */);
ts->old_stats = ts->stats;
}
}
diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c
index a36801b0691..ca21a4bfe08 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_server.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_server.c
@@ -58,6 +58,7 @@ typedef struct
volatile int worker_fails;
volatile int active_workers;
u8 use_ds;
+ u8 incremental_stats;
} vcl_test_server_main_t;
vcl_test_main_t vcl_test_main;
@@ -101,10 +102,10 @@ again:
if (!wrk->conn_pool[i].is_alloc)
{
conn = &wrk->conn_pool[i];
+ memset (conn, 0, sizeof (*conn));
conn->endpt.ip = wrk->conn_pool[i].ip;
conn->is_alloc = 1;
conn->session_index = i;
- memset (&conn->stats, 0, sizeof (vcl_test_stats_t));
vcl_test_cfg_init (&conn->cfg);
return (&wrk->conn_pool[i]);
}
@@ -324,6 +325,7 @@ vts_accept_client (vcl_test_server_worker_t *wrk, int listen_fd)
if (vsm->ctrl)
conn->cfg = vsm->ctrl->cfg;
vcl_test_session_buf_alloc (conn);
+ clock_gettime (CLOCK_REALTIME, &conn->old_stats.stop);
tp = vcl_test_main.protos[vsm->server_cfg.proto];
if (tp->accept (listen_fd, conn))
@@ -348,15 +350,15 @@ vts_accept_client (vcl_test_server_worker_t *wrk, int listen_fd)
static void
print_usage_and_exit (void)
{
- fprintf (stderr,
- "vcl_test_server [OPTIONS] <port>\n"
- " OPTIONS\n"
- " -h Print this message and exit.\n"
- " -6 Use IPv6\n"
- " -w <num> Number of workers\n"
- " -p <PROTO> Use <PROTO> transport layer\n"
- " -D Use UDP transport layer\n"
- " -L Use TLS transport layer\n");
+ fprintf (stderr, "vcl_test_server [OPTIONS] <port>\n"
+ " OPTIONS\n"
+ " -h Print this message and exit.\n"
+ " -6 Use IPv6\n"
+ " -w <num> Number of workers\n"
+ " -p <PROTO> Use <PROTO> transport layer\n"
+ " -D Use UDP transport layer\n"
+ " -L Use TLS transport layer\n"
+ " -S Incremental stats\n");
exit (1);
}
@@ -406,7 +408,7 @@ vcl_test_server_process_opts (vcl_test_server_main_t * vsm, int argc,
vsm->server_cfg.proto = VPPCOM_PROTO_TCP;
opterr = 0;
- while ((c = getopt (argc, argv, "6DLsw:hp:")) != -1)
+ while ((c = getopt (argc, argv, "6DLsw:hp:S")) != -1)
switch (c)
{
case '6':
@@ -436,6 +438,9 @@ vcl_test_server_process_opts (vcl_test_server_main_t * vsm, int argc,
case 's':
vsm->use_ds = 1;
break;
+ case 'S':
+ vsm->incremental_stats = 1;
+ break;
case '?':
switch (optopt)
{
@@ -578,6 +583,21 @@ vts_conn_read (vcl_test_session_t *conn)
return conn->read (conn, conn->rxbuf, conn->rxbuf_size);
}
+static void
+vts_inc_stats_check (vcl_test_session_t *ts)
+{
+ /* Avoid checking time too often because of syscall cost */
+ if (ts->stats.rx_bytes - ts->old_stats.rx_bytes < 1 << 20)
+ return;
+
+ clock_gettime (CLOCK_REALTIME, &ts->stats.stop);
+ if (vcl_test_time_diff (&ts->old_stats.stop, &ts->stats.stop) > 1)
+ {
+ vcl_test_stats_dump_inc (ts, 1 /* is_rx */);
+ ts->old_stats = ts->stats;
+ }
+}
+
static void *
vts_worker_loop (void *arg)
{
@@ -700,6 +720,8 @@ vts_worker_loop (void *arg)
if (vppcom_session_attr (conn->fd, VPPCOM_ATTR_GET_NREAD, 0, 0) >
0)
goto read_again;
+ if (vsm->incremental_stats)
+ vts_inc_stats_check (conn);
continue;
}
else