From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id E82971E34 for ; Fri, 1 Mar 2019 09:45:14 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2019 00:45:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,426,1544515200"; d="scan'208";a="138192629" Received: from tjozwiax-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.103.104.44]) by orsmga002.jf.intel.com with ESMTP; 01 Mar 2019 00:45:11 -0800 From: Tomasz Jozwiak To: dev@dpdk.org, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com Date: Fri, 1 Mar 2019 09:45:10 +0100 Message-Id: <1551429910-16248-1-git-send-email-tomaszx.jozwiak@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] app/compress-perf: add incompressible data handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Mar 2019 08:45:15 -0000 Currently, compress-perf doesn't respect incompressible data inside one operation. This patch adds such a functionality. Now the output buffer in one operation is big enough to store such a data after compression. Also added segment size checking to pass values in right range. Signed-off-by: Tomasz Jozwiak --- app/test-compress-perf/comp_perf_options.h | 5 ++++ app/test-compress-perf/comp_perf_options_parse.c | 11 ++++++-- app/test-compress-perf/comp_perf_test_benchmark.c | 9 ++++-- app/test-compress-perf/comp_perf_test_verify.c | 9 ++++-- app/test-compress-perf/main.c | 34 +++++++++++++++++++---- 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h index ca96a3c..f87751d 100644 --- a/app/test-compress-perf/comp_perf_options.h +++ b/app/test-compress-perf/comp_perf_options.h @@ -8,6 +8,10 @@ #define MAX_DRIVER_NAME 64 #define MAX_INPUT_FILE_NAME 64 #define MAX_LIST 32 +#define MIN_COMPRESSED_BUF_SIZE 8 +#define EXPANSE_RATIO 1.05 +#define MAX_MBUF_DATA_SIZE (UINT16_MAX - RTE_PKTMBUF_HEADROOM) +#define MAX_SEG_SIZE ((int)(MAX_MBUF_DATA_SIZE / EXPANSE_RATIO)) enum comp_operation { COMPRESS_ONLY, @@ -38,6 +42,7 @@ struct comp_test_data { struct rte_mempool *op_pool; int8_t cdev_id; uint16_t seg_sz; + uint16_t out_seg_sz; uint16_t burst_sz; uint32_t pool_sz; uint32_t num_iter; diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c index 66eb81f..9f18ffa 100644 --- a/app/test-compress-perf/comp_perf_options_parse.c +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -326,8 +326,15 @@ parse_seg_sz(struct comp_test_data *test_data, const char *arg) return -1; } - if (test_data->seg_sz == 0) { - RTE_LOG(ERR, USER1, "Segment size must be higher than 0\n"); + if (test_data->seg_sz < MIN_COMPRESSED_BUF_SIZE) { + RTE_LOG(ERR, USER1, "Segment size must be higher than %d\n", + MIN_COMPRESSED_BUF_SIZE - 1); + return -1; + } + + if (test_data->seg_sz > MAX_SEG_SIZE) { + RTE_LOG(ERR, USER1, "Segment size must be lower than %d\n", + MAX_SEG_SIZE + 1); return -1; } diff --git a/app/test-compress-perf/comp_perf_test_benchmark.c b/app/test-compress-perf/comp_perf_test_benchmark.c index 9aa2665..5752906 100644 --- a/app/test-compress-perf/comp_perf_test_benchmark.c +++ b/app/test-compress-perf/comp_perf_test_benchmark.c @@ -22,6 +22,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, struct rte_mbuf **input_bufs, **output_bufs; int res = 0; int allocated = 0; + uint32_t out_seg_sz; if (test_data == NULL || !test_data->burst_sz) { RTE_LOG(ERR, USER1, @@ -55,6 +56,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, }; input_bufs = test_data->decomp_bufs; output_bufs = test_data->comp_bufs; + out_seg_sz = test_data->out_seg_sz; } else { xform = (struct rte_comp_xform) { .type = RTE_COMP_DECOMPRESS, @@ -67,6 +69,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, }; input_bufs = test_data->comp_bufs; output_bufs = test_data->decomp_bufs; + out_seg_sz = test_data->seg_sz; } /* Create private xform */ @@ -130,7 +133,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, /* Reset all data in output buffers */ struct rte_mbuf *m = output_bufs[buf_id]; - m->pkt_len = test_data->seg_sz * m->nb_segs; + m->pkt_len = out_seg_sz * m->nb_segs; while (m) { m->data_len = m->buf_len - m->data_off; m = m->next; @@ -187,7 +190,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, while (remaining_data > 0) { data_to_append = RTE_MIN(remaining_data, - test_data->seg_sz); + out_seg_sz); m->data_len = data_to_append; remaining_data -= data_to_append; @@ -236,7 +239,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, while (remaining_data > 0) { data_to_append = RTE_MIN(remaining_data, - test_data->seg_sz); + out_seg_sz); m->data_len = data_to_append; remaining_data -= data_to_append; diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c index 57a9930..28a0fe8 100644 --- a/app/test-compress-perf/comp_perf_test_verify.c +++ b/app/test-compress-perf/comp_perf_test_verify.c @@ -24,6 +24,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, struct rte_mbuf **input_bufs, **output_bufs; int res = 0; int allocated = 0; + uint32_t out_seg_sz; if (test_data == NULL || !test_data->burst_sz) { RTE_LOG(ERR, USER1, @@ -57,6 +58,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, }; input_bufs = test_data->decomp_bufs; output_bufs = test_data->comp_bufs; + out_seg_sz = test_data->out_seg_sz; } else { xform = (struct rte_comp_xform) { .type = RTE_COMP_DECOMPRESS, @@ -69,6 +71,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, }; input_bufs = test_data->comp_bufs; output_bufs = test_data->decomp_bufs; + out_seg_sz = test_data->seg_sz; } /* Create private xform */ @@ -130,7 +133,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, /* Reset all data in output buffers */ struct rte_mbuf *m = output_bufs[buf_id]; - m->pkt_len = test_data->seg_sz * m->nb_segs; + m->pkt_len = out_seg_sz * m->nb_segs; while (m) { m->data_len = m->buf_len - m->data_off; m = m->next; @@ -209,7 +212,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, while (remaining_data > 0) { data_to_append = RTE_MIN(remaining_data, - test_data->seg_sz); + out_seg_sz); m->data_len = data_to_append; remaining_data -= data_to_append; @@ -280,7 +283,7 @@ main_loop(struct comp_test_data *test_data, uint8_t level, while (remaining_data > 0) { data_to_append = RTE_MIN(remaining_data, - test_data->seg_sz); + out_seg_sz); m->data_len = data_to_append; remaining_data -= data_to_append; diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c index 4de913e..c2a45d1 100644 --- a/app/test-compress-perf/main.c +++ b/app/test-compress-perf/main.c @@ -13,8 +13,6 @@ #define NUM_MAX_XFORMS 16 #define NUM_MAX_INFLIGHT_OPS 512 -#define EXPANSE_RATIO 1.05 -#define MIN_COMPRESSED_BUF_SIZE 8 #define DIV_CEIL(a, b) ((a) / (b) + ((a) % (b) != 0)) @@ -117,9 +115,34 @@ comp_perf_check_capabilities(struct comp_test_data *test_data) return 0; } +static uint32_t +find_buf_size(uint32_t input_size) +{ + uint32_t i; + + /* From performance point of view the buffer size should be a + * power of 2 but also should be enough to store incompressible data + */ + + /* We're looking for nearest power of 2 buffer size, which is greather + * than input_size + */ + uint32_t size = + !input_size ? MIN_COMPRESSED_BUF_SIZE : (input_size << 1); + + for (i = UINT16_MAX + 1; !(i & size); i >>= 1) + ; + + return i > ((UINT16_MAX + 1) >> 1) + ? (uint32_t)((float)input_size * EXPANSE_RATIO) + : i; +} + static int comp_perf_allocate_memory(struct comp_test_data *test_data) { + + test_data->out_seg_sz = find_buf_size(test_data->seg_sz); /* Number of segments for input and output * (compression and decompression) */ @@ -127,7 +150,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data) test_data->seg_sz); test_data->comp_buf_pool = rte_pktmbuf_pool_create("comp_buf_pool", total_segs, - 0, 0, test_data->seg_sz + RTE_PKTMBUF_HEADROOM, + 0, 0, + test_data->out_seg_sz + RTE_PKTMBUF_HEADROOM, rte_socket_id()); if (test_data->comp_buf_pool == NULL) { RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\n"); @@ -396,7 +420,7 @@ prepare_bufs(struct comp_test_data *test_data) } data_addr = (uint8_t *) rte_pktmbuf_append( test_data->comp_bufs[i], - test_data->seg_sz); + test_data->out_seg_sz); if (data_addr == NULL) { RTE_LOG(ERR, USER1, "Could not append data\n"); return -1; @@ -414,7 +438,7 @@ prepare_bufs(struct comp_test_data *test_data) } data_addr = (uint8_t *)rte_pktmbuf_append(next_seg, - test_data->seg_sz); + test_data->out_seg_sz); if (data_addr == NULL) { RTE_LOG(ERR, USER1, "Could not append data\n"); -- 2.7.4