This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via b0ce12f94111484567ae6314a51b8500cc7363af (commit) via a8030759ec3467206a52bdefadda3b7c5f7bdf27 (commit) from 7fd565206ddfe4acb5c8c44d7aa2f6a6e4218148 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit b0ce12f94111484567ae6314a51b8500cc7363af Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Aug 20 14:20:01 2019 +0300
test: pool_perf: add packet pool test option
Added -t option to select between buffer or packet pool types. This can be used to compare alloc/free performance of packet and buffer pools. Packets have more metadata than buffers, so packet pool performance may be less than buffer pool performance.
Also, added -s option to select data size. Data size may affect packet alloc/free performance as a large data size may result segmented packets.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-by: Matias Elo matias.elo@nokia.com
diff --git a/test/performance/odp_pool_perf.c b/test/performance/odp_pool_perf.c index d00e4bc92..26fe44be5 100644 --- a/test/performance/odp_pool_perf.c +++ b/test/performance/odp_pool_perf.c @@ -1,4 +1,6 @@ /* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2019, Nokia + * * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -20,6 +22,8 @@ typedef struct test_options_t { uint32_t num_round; uint32_t max_burst; uint32_t num_burst; + uint32_t data_size; + int pool_type;
} test_options_t;
@@ -57,6 +61,9 @@ static void print_usage(void) " -r, --num_round Number of rounds\n" " -b, --burst Maximum number of events per operation\n" " -n, --num_burst Number of bursts allocated/freed back-to-back\n" + " -s, --data_size Data size in bytes\n" + " -t, --pool_type 0: Buffer pool (default)\n" + " 1: Packet pool\n" " -h, --help This help\n" "\n"); } @@ -73,17 +80,21 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options) {"num_round", required_argument, NULL, 'r'}, {"burst", required_argument, NULL, 'b'}, {"num_burst", required_argument, NULL, 'n'}, + {"data_size", required_argument, NULL, 's'}, + {"pool_type", required_argument, NULL, 't'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0} };
- static const char *shortopts = "+c:e:r:b:n:h"; + static const char *shortopts = "+c:e:r:b:n:s:t:h";
test_options->num_cpu = 1; test_options->num_event = 1000; test_options->num_round = 100000; test_options->max_burst = 100; test_options->num_burst = 1; + test_options->data_size = 64; + test_options->pool_type = 0;
while (1) { opt = getopt_long(argc, argv, shortopts, longopts, &long_index); @@ -107,6 +118,12 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options) case 'n': test_options->num_burst = atoi(optarg); break; + case 's': + test_options->data_size = atoi(optarg); + break; + case 't': + test_options->pool_type = atoi(optarg); + break; case 'h': /* fall through */ default: @@ -164,36 +181,62 @@ static int create_pool(test_global_t *global) odp_pool_capability_t pool_capa; odp_pool_param_t pool_param; odp_pool_t pool; - uint32_t max_num; + uint32_t max_num, max_size; test_options_t *test_options = &global->test_options; uint32_t num_event = test_options->num_event; uint32_t num_round = test_options->num_round; uint32_t max_burst = test_options->max_burst; uint32_t num_burst = test_options->num_burst; uint32_t num_cpu = test_options->num_cpu; + uint32_t data_size = test_options->data_size; + int packet_pool = test_options->pool_type;
printf("\nPool performance test\n"); printf(" num cpu %u\n", num_cpu); printf(" num rounds %u\n", num_round); printf(" num events %u\n", num_event); printf(" max burst %u\n", max_burst); - printf(" num bursts %u\n\n", num_burst); + printf(" num bursts %u\n", num_burst); + printf(" data size %u\n", data_size); + printf(" pool type %s\n\n", packet_pool ? "packet" : "buffer");
if (odp_pool_capability(&pool_capa)) { printf("Error: Pool capa failed.\n"); return -1; }
- max_num = pool_capa.buf.max_num; + if (packet_pool) { + max_num = pool_capa.pkt.max_num; + max_size = pool_capa.pkt.max_len; + } else { + max_num = pool_capa.buf.max_num; + max_size = pool_capa.buf.max_size; + }
if (max_num && num_event > max_num) { printf("Error: max events supported %u\n", max_num); return -1; }
+ if (max_size && data_size > max_size) { + printf("Error: max data size supported %u\n", max_size); + return -1; + } + odp_pool_param_init(&pool_param); - pool_param.type = ODP_POOL_BUFFER; - pool_param.buf.num = num_event; + + if (packet_pool) { + pool_param.type = ODP_POOL_PACKET; + pool_param.pkt.num = num_event; + pool_param.pkt.len = data_size; + pool_param.pkt.max_num = num_event; + pool_param.pkt.max_len = data_size; + + } else { + pool_param.type = ODP_POOL_BUFFER; + pool_param.buf.num = num_event; + pool_param.buf.size = data_size; + }
pool = odp_pool_create("pool perf", &pool_param);
@@ -207,7 +250,7 @@ static int create_pool(test_global_t *global) return 0; }
-static int test_pool(void *arg) +static int test_buffer_pool(void *arg) { int ret, thr; uint32_t num, num_free, num_freed, i, rounds; @@ -289,18 +332,107 @@ static int test_pool(void *arg) return 0; }
+static int test_packet_pool(void *arg) +{ + int ret, thr; + uint32_t num, num_free, num_freed, i, rounds; + uint64_t c1, c2, cycles, nsec; + uint64_t events, frees; + odp_time_t t1, t2; + test_global_t *global = arg; + test_options_t *test_options = &global->test_options; + uint32_t num_round = test_options->num_round; + uint32_t max_burst = test_options->max_burst; + uint32_t num_burst = test_options->num_burst; + uint32_t max_num = num_burst * max_burst; + uint32_t data_size = test_options->data_size; + odp_pool_t pool = global->pool; + odp_packet_t pkt[max_num]; + + thr = odp_thread_id(); + + for (i = 0; i < max_num; i++) + pkt[i] = ODP_PACKET_INVALID; + + events = 0; + frees = 0; + ret = 0; + + /* Start all workers at the same time */ + odp_barrier_wait(&global->barrier); + + t1 = odp_time_local(); + c1 = odp_cpu_cycles(); + + for (rounds = 0; rounds < num_round; rounds++) { + num = 0; + + for (i = 0; i < num_burst; i++) { + ret = odp_packet_alloc_multi(pool, data_size, &pkt[num], + max_burst); + if (odp_unlikely(ret < 0)) { + printf("Error: Alloc failed. Round %u\n", + rounds); + + if (num) + odp_packet_free_multi(pkt, num); + + return -1; + } + + num += ret; + } + + if (odp_unlikely(num == 0)) + continue; + + events += num; + num_freed = 0; + + while (num_freed < num) { + num_free = num - num_freed; + if (num_free > max_burst) + num_free = max_burst; + + odp_packet_free_multi(&pkt[num_freed], num_free); + frees++; + num_freed += num_free; + } + } + + c2 = odp_cpu_cycles(); + t2 = odp_time_local(); + + nsec = odp_time_diff_ns(t2, t1); + cycles = odp_cpu_cycles_diff(c2, c1); + + /* Update stats*/ + global->stat[thr].rounds = rounds; + global->stat[thr].frees = frees; + global->stat[thr].events = events; + global->stat[thr].nsec = nsec; + global->stat[thr].cycles = cycles; + + return 0; +} + static int start_workers(test_global_t *global, odp_instance_t instance) { odph_odpthread_params_t thr_params; test_options_t *test_options = &global->test_options; int num_cpu = test_options->num_cpu; + int packet_pool = test_options->pool_type;
memset(&thr_params, 0, sizeof(thr_params)); thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = instance; - thr_params.start = test_pool; thr_params.arg = global;
+ if (packet_pool) + thr_params.start = test_packet_pool; + else + thr_params.start = test_buffer_pool; + if (odph_odpthreads_create(global->thread_tbl, &global->cpumask, &thr_params) != num_cpu) return -1;
commit a8030759ec3467206a52bdefadda3b7c5f7bdf27 Author: Petri Savolainen petri.savolainen@nokia.com Date: Tue Aug 20 11:27:00 2019 +0300
test: pool_perf: add number of bursts option
Added -n option to control how many (bursts) alloc calls are done before freeing allocated events. When more events are allocated before freeing any, it's more likely that alloc needs to synchronize with the global pool (thread local stash gets empty) and performance decreases.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-by: Matias Elo matias.elo@nokia.com
diff --git a/test/performance/odp_pool_perf.c b/test/performance/odp_pool_perf.c index 89cb109b2..d00e4bc92 100644 --- a/test/performance/odp_pool_perf.c +++ b/test/performance/odp_pool_perf.c @@ -19,6 +19,7 @@ typedef struct test_options_t { uint32_t num_event; uint32_t num_round; uint32_t max_burst; + uint32_t num_burst;
} test_options_t;
@@ -55,6 +56,7 @@ static void print_usage(void) " -e, --num_event Number of events\n" " -r, --num_round Number of rounds\n" " -b, --burst Maximum number of events per operation\n" + " -n, --num_burst Number of bursts allocated/freed back-to-back\n" " -h, --help This help\n" "\n"); } @@ -70,16 +72,18 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options) {"num_event", required_argument, NULL, 'e'}, {"num_round", required_argument, NULL, 'r'}, {"burst", required_argument, NULL, 'b'}, + {"num_burst", required_argument, NULL, 'n'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0} };
- static const char *shortopts = "+c:e:r:b:h"; + static const char *shortopts = "+c:e:r:b:n:h";
test_options->num_cpu = 1; test_options->num_event = 1000; test_options->num_round = 100000; test_options->max_burst = 100; + test_options->num_burst = 1;
while (1) { opt = getopt_long(argc, argv, shortopts, longopts, &long_index); @@ -100,6 +104,9 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options) case 'b': test_options->max_burst = atoi(optarg); break; + case 'n': + test_options->num_burst = atoi(optarg); + break; case 'h': /* fall through */ default: @@ -109,6 +116,15 @@ static int parse_options(int argc, char *argv[], test_options_t *test_options) } }
+ if (test_options->num_burst * test_options->max_burst > + test_options->num_event) { + printf("Not enough events (%u) for the burst configuration.\n" + "Use smaller burst size (%u) or less bursts (%u)\n", + test_options->num_event, test_options->max_burst, + test_options->num_burst); + ret = -1; + } + return ret; }
@@ -153,13 +169,15 @@ static int create_pool(test_global_t *global) uint32_t num_event = test_options->num_event; uint32_t num_round = test_options->num_round; uint32_t max_burst = test_options->max_burst; + uint32_t num_burst = test_options->num_burst; uint32_t num_cpu = test_options->num_cpu;
printf("\nPool performance test\n"); printf(" num cpu %u\n", num_cpu); printf(" num rounds %u\n", num_round); printf(" num events %u\n", num_event); - printf(" max burst %u\n\n", max_burst); + printf(" max burst %u\n", max_burst); + printf(" num bursts %u\n\n", num_burst);
if (odp_pool_capability(&pool_capa)) { printf("Error: Pool capa failed.\n"); @@ -191,8 +209,8 @@ static int create_pool(test_global_t *global)
static int test_pool(void *arg) { - int num, ret, thr; - uint32_t i, rounds; + int ret, thr; + uint32_t num, num_free, num_freed, i, rounds; uint64_t c1, c2, cycles, nsec; uint64_t events, frees; odp_time_t t1, t2; @@ -200,12 +218,14 @@ static int test_pool(void *arg) test_options_t *test_options = &global->test_options; uint32_t num_round = test_options->num_round; uint32_t max_burst = test_options->max_burst; + uint32_t num_burst = test_options->num_burst; + uint32_t max_num = num_burst * max_burst; odp_pool_t pool = global->pool; - odp_buffer_t buf[max_burst]; + odp_buffer_t buf[max_num];
thr = odp_thread_id();
- for (i = 0; i < max_burst; i++) + for (i = 0; i < max_num; i++) buf[i] = ODP_BUFFER_INVALID;
events = 0; @@ -219,19 +239,37 @@ static int test_pool(void *arg) c1 = odp_cpu_cycles();
for (rounds = 0; rounds < num_round; rounds++) { - num = odp_buffer_alloc_multi(pool, buf, max_burst); + num = 0;
- if (odp_likely(num > 0)) { - events += num; - odp_buffer_free_multi(buf, num); - frees++; - continue; + for (i = 0; i < num_burst; i++) { + ret = odp_buffer_alloc_multi(pool, &buf[num], + max_burst); + if (odp_unlikely(ret < 0)) { + printf("Error: Alloc failed. Round %u\n", + rounds); + if (num) + odp_buffer_free_multi(buf, num); + + return -1; + } + + num += ret; }
- if (num < 0) { - printf("Error: Alloc failed. Round %u\n", rounds); - ret = -1; - break; + if (odp_unlikely(num == 0)) + continue; + + events += num; + num_freed = 0; + + while (num_freed < num) { + num_free = num - num_freed; + if (num_free > max_burst) + num_free = max_burst; + + odp_buffer_free_multi(&buf[num_freed], num_free); + frees++; + num_freed += num_free; } }
@@ -248,7 +286,7 @@ static int test_pool(void *arg) global->stat[thr].nsec = nsec; global->stat[thr].cycles = cycles;
- return ret; + return 0; }
static int start_workers(test_global_t *global, odp_instance_t instance) @@ -273,9 +311,11 @@ static int start_workers(test_global_t *global, odp_instance_t instance) static void print_stat(test_global_t *global) { int i, num; - double rounds_ave, frees_ave, events_ave, nsec_ave, cycles_ave; + double rounds_ave, allocs_ave, frees_ave; + double events_ave, nsec_ave, cycles_ave; test_options_t *test_options = &global->test_options; int num_cpu = test_options->num_cpu; + uint32_t num_burst = test_options->num_burst; uint64_t rounds_sum = 0; uint64_t frees_sum = 0; uint64_t events_sum = 0; @@ -297,6 +337,7 @@ static void print_stat(test_global_t *global) }
rounds_ave = rounds_sum / num_cpu; + allocs_ave = (num_burst * rounds_sum) / num_cpu; frees_ave = frees_sum / num_cpu; events_ave = events_sum / num_cpu; nsec_ave = nsec_sum / num_cpu; @@ -321,7 +362,7 @@ static void print_stat(test_global_t *global)
printf("RESULTS - average over %i threads:\n", num_cpu); printf("----------------------------------\n"); - printf(" alloc calls: %.3f\n", rounds_ave); + printf(" alloc calls: %.3f\n", allocs_ave); printf(" free calls: %.3f\n", frees_ave); printf(" duration: %.3f msec\n", nsec_ave / 1000000); printf(" num cycles: %.3f M\n", cycles_ave / 1000000); @@ -330,9 +371,11 @@ static void print_stat(test_global_t *global) printf(" cycles per event: %.3f\n", cycles_ave / events_ave); printf(" ave events allocated: %.3f\n", - events_ave / rounds_ave); - printf(" operations per sec: %.3f M\n", - (1000.0 * rounds_ave) / nsec_ave); + events_ave / allocs_ave); + printf(" allocs per sec: %.3f M\n", + (1000.0 * allocs_ave) / nsec_ave); + printf(" frees per sec: %.3f M\n", + (1000.0 * frees_ave) / nsec_ave); printf(" events per sec: %.3f M\n\n", (1000.0 * events_ave) / nsec_ave); }
-----------------------------------------------------------------------
Summary of changes: test/performance/odp_pool_perf.c | 229 ++++++++++++++++++++++++++++++++++----- 1 file changed, 202 insertions(+), 27 deletions(-)
hooks/post-receive