From patchwork Mon Oct 1 13:27:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Jozwiak X-Patchwork-Id: 45780 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBBCC1B293; Mon, 1 Oct 2018 15:27:39 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 01C9F1B204 for ; Mon, 1 Oct 2018 15:27:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Oct 2018 06:27:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,327,1534834800"; d="scan'208";a="91103214" Received: from tjozwiax-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.103.104.44]) by fmsmga002.fm.intel.com with ESMTP; 01 Oct 2018 06:27:12 -0700 From: Tomasz Jozwiak To: dev@dpdk.org, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com, akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com Cc: De@dpdk.org, Lara@dpdk.org, Guarch@dpdk.org Date: Mon, 1 Oct 2018 15:27:05 +0200 Message-Id: <1538400427-20164-2-git-send-email-tomaszx.jozwiak@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> References: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> Subject: [dpdk-dev] [PATCH 1/3] app/compress-perf: add parser 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added parser part into compression perf. test. Signed-off-by: De Lara Guarch, Pablo Signed-off-by: Tomasz Jozwiak --- app/Makefile | 4 + app/meson.build | 1 + app/test-compress-perf/Makefile | 16 + app/test-compress-perf/comp_perf_options.h | 59 +++ app/test-compress-perf/comp_perf_options_parse.c | 596 +++++++++++++++++++++++ app/test-compress-perf/main.c | 52 ++ app/test-compress-perf/meson.build | 7 + config/common_base | 5 + 8 files changed, 740 insertions(+) create mode 100644 app/test-compress-perf/Makefile create mode 100644 app/test-compress-perf/comp_perf_options.h create mode 100644 app/test-compress-perf/comp_perf_options_parse.c create mode 100644 app/test-compress-perf/main.c create mode 100644 app/test-compress-perf/meson.build diff --git a/app/Makefile b/app/Makefile index 069fa98..d6641ef 100644 --- a/app/Makefile +++ b/app/Makefile @@ -11,6 +11,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_BBDEV),y) DIRS-$(CONFIG_RTE_TEST_BBDEV) += test-bbdev endif +ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y) +DIRS-$(CONFIG_RTE_APP_COMPRESS_PERF) += test-compress-perf +endif + ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y) DIRS-$(CONFIG_RTE_APP_CRYPTO_PERF) += test-crypto-perf endif diff --git a/app/meson.build b/app/meson.build index 99e0b93..c2ebb11 100644 --- a/app/meson.build +++ b/app/meson.build @@ -4,6 +4,7 @@ apps = ['pdump', 'proc-info', 'test-bbdev', + 'test-compress-perf', 'test-crypto-perf', 'test-eventdev', 'test-pmd'] diff --git a/app/test-compress-perf/Makefile b/app/test-compress-perf/Makefile new file mode 100644 index 0000000..8aa7a22 --- /dev/null +++ b/app/test-compress-perf/Makefile @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +APP = dpdk-test-compress-perf + +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 + +# all source are stored in SRCS-y +SRCS-y := main.c +SRCS-y += comp_perf_options_parse.c + +include $(RTE_SDK)/mk/rte.app.mk diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h new file mode 100644 index 0000000..7516ea0 --- /dev/null +++ b/app/test-compress-perf/comp_perf_options.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ + +#define MAX_DRIVER_NAME 64 +#define MAX_INPUT_FILE_NAME 64 +#define MAX_LIST 32 + +enum comp_operation { + COMPRESS_ONLY, + DECOMPRESS_ONLY, + COMPRESS_DECOMPRESS +}; + +struct range_list { + uint8_t min; + uint8_t max; + uint8_t inc; + uint8_t count; + uint8_t list[MAX_LIST]; +}; + +struct comp_test_data { + char driver_name[64]; + char input_file[64]; + struct rte_mbuf **comp_bufs; + struct rte_mbuf **decomp_bufs; + uint32_t total_bufs; + uint8_t *input_data; + size_t input_data_sz; + uint8_t *compressed_data; + uint8_t *decompressed_data; + struct rte_mempool *comp_buf_pool; + struct rte_mempool *decomp_buf_pool; + struct rte_mempool *op_pool; + int8_t cdev_id; + uint16_t seg_sz; + uint16_t burst_sz; + uint32_t pool_sz; + uint32_t num_iter; + uint16_t max_sgl_segs; + enum rte_comp_huffman huffman_enc; + enum comp_operation test_op; + int window_sz; + struct range_list level; + /* Store TSC duration for all levels (including level 0) */ + uint64_t comp_tsc_duration[RTE_COMP_LEVEL_MAX + 1]; + uint64_t decomp_tsc_duration[RTE_COMP_LEVEL_MAX + 1]; +}; + +int +comp_perf_options_parse(struct comp_test_data *test_data, int argc, + char **argv); + +void +comp_perf_options_default(struct comp_test_data *test_data); + +int +comp_perf_options_check(struct comp_test_data *test_data); diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c new file mode 100644 index 0000000..bef4d2f --- /dev/null +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -0,0 +1,596 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "comp_perf_options.h" + +#define CPERF_DRIVER_NAME ("driver-name") +#define CPERF_TEST_FILE ("input-file") +#define CPERF_SEG_SIZE ("seg-sz") +#define CPERF_BURST_SIZE ("burst-sz") +#define CPERF_EXTENDED_SIZE ("extended-input-sz") +#define CPERF_POOL_SIZE ("pool-sz") +#define CPERF_MAX_SGL_SEGS ("max-num-sgl-segs") +#define CPERF_NUM_ITER ("num-iter") +#define CPERF_OPTYPE ("operation") +#define CPERF_HUFFMAN_ENC ("huffman-enc") +#define CPERF_LEVEL ("compress-level") +#define CPERF_WINDOW_SIZE ("window-sz") + +struct name_id_map { + const char *name; + uint32_t id; +}; + +static void +usage(char *progname) +{ + printf("%s [EAL options] --\n" + " --driver-name NAME: compress driver to use\n" + " --input-file NAME: file to compress and decompress\n" + " --extended-input-sz N: extend file data up to this size (default: no extension)\n" + " --seg-sz N: size of segment to store the data (default: 2048)\n" + " --burst-sz N: compress operation burst size\n" + " --pool-sz N: mempool size for compress operations/mbufs\n" + " (default: 8192)\n" + " --max-num-sgl-segs N: maximum number of segments for each mbuf\n" + " (default: 65535)\n" + " --num-iter N: number of times the file will be\n" + " compressed/decompressed (default: 10000)\n" + " --operation [comp/decomp/comp_and_decomp]: perform test on\n" + " compression, decompression or both operations\n" + " --huffman-enc [fixed/dynamic/default]: Huffman encoding\n" + " (default: dynamic)\n" + " --compress-level N: compression level, which could be a single value, list or range\n" + " (default: range between 1 and 9)\n" + " --window-sz N: base two log value of compression window size\n" + " (e.g.: 15 => 32k, default: max supported by PMD)\n" + " -h: prints this help\n", + progname); +} + +static int +get_str_key_id_mapping(struct name_id_map *map, unsigned int map_len, + const char *str_key) +{ + unsigned int i; + + for (i = 0; i < map_len; i++) { + + if (strcmp(str_key, map[i].name) == 0) + return map[i].id; + } + + return -1; +} + +static int +parse_uint32_t(uint32_t *value, const char *arg) +{ + char *end = NULL; + unsigned long n = strtoul(arg, &end, 10); + + if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + + if (n > UINT32_MAX) + return -ERANGE; + + *value = (uint32_t) n; + + return 0; +} + +static int +parse_uint16_t(uint16_t *value, const char *arg) +{ + uint32_t val = 0; + int ret = parse_uint32_t(&val, arg); + + if (ret < 0) + return ret; + + if (val > UINT16_MAX) + return -ERANGE; + + *value = (uint16_t) val; + + return 0; +} + +static int +parse_range(const char *arg, uint8_t *min, uint8_t *max, uint8_t *inc) +{ + char *token; + uint8_t number; + + char *copy_arg = strdup(arg); + + if (copy_arg == NULL) + return -1; + + errno = 0; + token = strtok(copy_arg, ":"); + + /* Parse minimum value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE) + goto err_range; + + *min = number; + } else + goto err_range; + + token = strtok(NULL, ":"); + + /* Parse increment value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0) + goto err_range; + + *inc = number; + } else + goto err_range; + + token = strtok(NULL, ":"); + + /* Parse maximum value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number < *min) + goto err_range; + + *max = number; + } else + goto err_range; + + if (strtok(NULL, ":") != NULL) + goto err_range; + + free(copy_arg); + return 0; + +err_range: + free(copy_arg); + return -1; +} + +static int +parse_list(const char *arg, uint8_t *list, uint8_t *min, uint8_t *max) +{ + char *token; + uint32_t number; + uint8_t count = 0; + uint32_t temp_min; + uint32_t temp_max; + + char *copy_arg = strdup(arg); + + if (copy_arg == NULL) + return -1; + + errno = 0; + token = strtok(copy_arg, ","); + + /* Parse first value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE) + goto err_list; + + list[count++] = number; + temp_min = number; + temp_max = number; + } else + goto err_list; + + token = strtok(NULL, ","); + + while (token != NULL) { + if (count == MAX_LIST) { + RTE_LOG(WARNING, USER1, + "Using only the first %u sizes\n", + MAX_LIST); + break; + } + + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE) + goto err_list; + + list[count++] = number; + + if (number < temp_min) + temp_min = number; + if (number > temp_max) + temp_max = number; + + token = strtok(NULL, ","); + } + + if (min) + *min = temp_min; + if (max) + *max = temp_max; + + free(copy_arg); + return count; + +err_list: + free(copy_arg); + return -1; +} + +static int +parse_num_iter(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint32_t(&test_data->num_iter, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse total iteration count\n"); + return -1; + } + + if (test_data->num_iter == 0) { + RTE_LOG(ERR, USER1, + "Total number of iterations must be higher than 0\n"); + return -1; + } + + return ret; +} + +static int +parse_pool_sz(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint32_t(&test_data->pool_sz, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse pool size"); + return -1; + } + + if (test_data->pool_sz == 0) { + RTE_LOG(ERR, USER1, "Pool size must be higher than 0\n"); + return -1; + } + + return ret; +} + +static int +parse_burst_sz(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint16_t(&test_data->burst_sz, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse burst size/s\n"); + return -1; + } + + if (test_data->burst_sz == 0) { + RTE_LOG(ERR, USER1, "Burst size must be higher than 0\n"); + return -1; + } + + return 0; +} + +static int +parse_extended_input_sz(struct comp_test_data *test_data, const char *arg) +{ + uint32_t tmp; + int ret = parse_uint32_t(&tmp, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse extended input size\n"); + return -1; + } + test_data->input_data_sz = tmp; + + if (tmp == 0) { + RTE_LOG(ERR, USER1, + "Extended file size must be higher than 0\n"); + return -1; + } + return 0; +} + +static int +parse_seg_sz(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint16_t(&test_data->seg_sz, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse segment size\n"); + return -1; + } + + if (test_data->seg_sz == 0) { + RTE_LOG(ERR, USER1, "Segment size must be higher than 0\n"); + return -1; + } + + return 0; +} + +static int +parse_max_num_sgl_segs(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint16_t(&test_data->max_sgl_segs, arg); + + if (ret) { + RTE_LOG(ERR, USER1, + "Failed to parse max number of segments per mbuf chain\n"); + return -1; + } + + if (test_data->max_sgl_segs == 0) { + RTE_LOG(ERR, USER1, "Max number of segments per mbuf chain " + "must be higher than 0\n"); + return -1; + } + + return 0; +} + +static int +parse_window_sz(struct comp_test_data *test_data, const char *arg) +{ + int ret = parse_uint16_t((uint16_t *)&test_data->window_sz, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "Failed to parse window size\n"); + return -1; + } + + return 0; +} + +static int +parse_driver_name(struct comp_test_data *test_data, const char *arg) +{ + if (strlen(arg) > (sizeof(test_data->driver_name) - 1)) + return -1; + + rte_strlcpy(test_data->driver_name, arg, + sizeof(test_data->driver_name)); + + return 0; +} + +static int +parse_test_file(struct comp_test_data *test_data, const char *arg) +{ + if (strlen(arg) > (sizeof(test_data->input_file) - 1)) + return -1; + + rte_strlcpy(test_data->input_file, arg, sizeof(test_data->input_file)); + + return 0; +} + +static int +parse_op_type(struct comp_test_data *test_data, const char *arg) +{ + struct name_id_map optype_namemap[] = { + { + "comp", + COMPRESS_ONLY + }, + { + "decomp", + DECOMPRESS_ONLY + }, + { + "comp_and_decomp", + COMPRESS_DECOMPRESS + } + }; + + int id = get_str_key_id_mapping(optype_namemap, + RTE_DIM(optype_namemap), arg); + if (id < 0) { + RTE_LOG(ERR, USER1, "Invalid operation type specified\n"); + return -1; + } + + test_data->test_op = (enum comp_operation)id; + + return 0; +} + +static int +parse_huffman_enc(struct comp_test_data *test_data, const char *arg) +{ + struct name_id_map huffman_namemap[] = { + { + "default", + RTE_COMP_HUFFMAN_DEFAULT + }, + { + "fixed", + RTE_COMP_HUFFMAN_FIXED + }, + { + "dynamic", + RTE_COMP_HUFFMAN_DYNAMIC + } + }; + + int id = get_str_key_id_mapping(huffman_namemap, + RTE_DIM(huffman_namemap), arg); + if (id < 0) { + RTE_LOG(ERR, USER1, "Invalid Huffmane encoding specified\n"); + return -1; + } + + test_data->huffman_enc = (enum rte_comp_huffman)id; + + return 0; +} + +static int +parse_level(struct comp_test_data *test_data, const char *arg) +{ + int ret; + + /* + * Try parsing the argument as a range, if it fails, + * arse it as a list + */ + if (parse_range(arg, &test_data->level.min, &test_data->level.max, + &test_data->level.inc) < 0) { + ret = parse_list(arg, test_data->level.list, + &test_data->level.min, + &test_data->level.max); + if (ret < 0) { + RTE_LOG(ERR, USER1, + "Failed to parse compression level/s\n"); + return -1; + } + test_data->level.count = ret; + + if (test_data->level.max > RTE_COMP_LEVEL_MAX) { + RTE_LOG(ERR, USER1, "Level cannot be higher than %u\n", + RTE_COMP_LEVEL_MAX); + return -1; + } + } + + return 0; +} + +typedef int (*option_parser_t)(struct comp_test_data *test_data, + const char *arg); + +struct long_opt_parser { + const char *lgopt_name; + option_parser_t parser_fn; + +}; + +static struct option lgopts[] = { + + { CPERF_DRIVER_NAME, required_argument, 0, 0 }, + { CPERF_TEST_FILE, required_argument, 0, 0 }, + { CPERF_SEG_SIZE, required_argument, 0, 0 }, + { CPERF_BURST_SIZE, required_argument, 0, 0 }, + { CPERF_EXTENDED_SIZE, required_argument, 0, 0 }, + { CPERF_POOL_SIZE, required_argument, 0, 0 }, + { CPERF_MAX_SGL_SEGS, required_argument, 0, 0}, + { CPERF_NUM_ITER, required_argument, 0, 0 }, + { CPERF_OPTYPE, required_argument, 0, 0 }, + { CPERF_HUFFMAN_ENC, required_argument, 0, 0 }, + { CPERF_LEVEL, required_argument, 0, 0 }, + { CPERF_WINDOW_SIZE, required_argument, 0, 0 }, + { NULL, 0, 0, 0 } +}; +static int +comp_perf_opts_parse_long(int opt_idx, struct comp_test_data *test_data) +{ + struct long_opt_parser parsermap[] = { + { CPERF_DRIVER_NAME, parse_driver_name }, + { CPERF_TEST_FILE, parse_test_file }, + { CPERF_SEG_SIZE, parse_seg_sz }, + { CPERF_BURST_SIZE, parse_burst_sz }, + { CPERF_EXTENDED_SIZE, parse_extended_input_sz }, + { CPERF_POOL_SIZE, parse_pool_sz }, + { CPERF_MAX_SGL_SEGS, parse_max_num_sgl_segs }, + { CPERF_NUM_ITER, parse_num_iter }, + { CPERF_OPTYPE, parse_op_type }, + { CPERF_HUFFMAN_ENC, parse_huffman_enc }, + { CPERF_LEVEL, parse_level }, + { CPERF_WINDOW_SIZE, parse_window_sz }, + }; + unsigned int i; + + for (i = 0; i < RTE_DIM(parsermap); i++) { + if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name, + strlen(lgopts[opt_idx].name)) == 0) + return parsermap[i].parser_fn(test_data, optarg); + } + + return -EINVAL; +} + +int +comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv) +{ + int opt, retval, opt_idx; + + while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) { + switch (opt) { + case 'h': + usage(argv[0]); + rte_exit(EXIT_SUCCESS, "Displayed help\n"); + break; + /* long options */ + case 0: + retval = comp_perf_opts_parse_long(opt_idx, test_data); + if (retval != 0) + return retval; + + break; + + default: + usage(argv[0]); + return -EINVAL; + } + } + + return 0; +} + +void +comp_perf_options_default(struct comp_test_data *test_data) +{ + test_data->cdev_id = -1; + test_data->seg_sz = 2048; + test_data->burst_sz = 32; + test_data->pool_sz = 8192; + test_data->max_sgl_segs = UINT16_MAX; + test_data->num_iter = 10000; + test_data->huffman_enc = RTE_COMP_HUFFMAN_DYNAMIC; + test_data->test_op = COMPRESS_DECOMPRESS; + test_data->window_sz = -1; + test_data->level.min = 1; + test_data->level.max = 9; + test_data->level.inc = 1; +} + +int +comp_perf_options_check(struct comp_test_data *test_data) +{ + if (strcmp(test_data->driver_name, "") == 0) { + RTE_LOG(ERR, USER1, "Driver name has to be set\n"); + return -1; + } + + if (strcmp(test_data->input_file, "") == 0) { + RTE_LOG(ERR, USER1, "Input file name has to be set\n"); + return -1; + } + + return 0; +} diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c new file mode 100644 index 0000000..f52b98d --- /dev/null +++ b/app/test-compress-perf/main.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ + +#include +#include +#include +#include + +#include "comp_perf_options.h" + +int +main(int argc, char **argv) +{ + int ret; + struct comp_test_data *test_data; + + /* Initialise DPDK EAL */ + ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n"); + argc -= ret; + argv += ret; + + test_data = rte_zmalloc_socket(NULL, sizeof(struct comp_test_data), + 0, rte_socket_id()); + + if (test_data == NULL) + rte_exit(EXIT_FAILURE, "Cannot reserve memory in socket %d\n", + rte_socket_id()); + + comp_perf_options_default(test_data); + + if (comp_perf_options_parse(test_data, argc, argv) < 0) { + RTE_LOG(ERR, USER1, + "Parsing one or more user options failed\n"); + ret = EXIT_FAILURE; + goto err; + } + + if (comp_perf_options_check(test_data) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + ret = EXIT_SUCCESS; + +err: + rte_free(test_data); + + return ret; +} diff --git a/app/test-compress-perf/meson.build b/app/test-compress-perf/meson.build new file mode 100644 index 0000000..ba6d64d --- /dev/null +++ b/app/test-compress-perf/meson.build @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +allow_experimental_apis = true +sources = files('comp_perf_options_parse.c', + 'main.c') +deps = ['compressdev'] diff --git a/config/common_base b/config/common_base index 155c7d4..23bf58a0 100644 --- a/config/common_base +++ b/config/common_base @@ -902,6 +902,11 @@ CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n CONFIG_RTE_TEST_BBDEV=y # +# Compile the compression performance application +# +CONFIG_RTE_APP_COMPRESS_PERF=y + +# # Compile the crypto performance application # CONFIG_RTE_APP_CRYPTO_PERF=y From patchwork Mon Oct 1 13:27:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Jozwiak X-Patchwork-Id: 45782 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 392761B397; Mon, 1 Oct 2018 15:28:18 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E19661B0FB for ; Mon, 1 Oct 2018 15:28:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Oct 2018 06:28:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,327,1534834800"; d="scan'208";a="91103217" Received: from tjozwiax-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.103.104.44]) by fmsmga002.fm.intel.com with ESMTP; 01 Oct 2018 06:27:14 -0700 From: Tomasz Jozwiak To: dev@dpdk.org, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com, akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com Cc: De@dpdk.org, Lara@dpdk.org, Guarch@dpdk.org Date: Mon, 1 Oct 2018 15:27:06 +0200 Message-Id: <1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> References: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> Subject: [dpdk-dev] [PATCH 2/3] app/compress-perf: add performance measurement 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added performance measurement part into compression perf. test. Signed-off-by: De Lara Guarch, Pablo Signed-off-by: Tomasz Jozwiak --- app/test-compress-perf/main.c | 844 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 844 insertions(+) diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c index f52b98d..093dfaf 100644 --- a/app/test-compress-perf/main.c +++ b/app/test-compress-perf/main.c @@ -5,13 +5,721 @@ #include #include #include +#include #include #include "comp_perf_options.h" +#define NUM_MAX_XFORMS 16 +#define NUM_MAX_INFLIGHT_OPS 512 +#define EXPANSE_RATIO 1.05 +#define MIN_ISAL_SIZE 8 + +#define DIV_CEIL(a, b) ((a) / (b) + ((a) % (b) != 0)) + +static int +param_range_check(uint16_t size, const struct rte_param_log2_range *range) +{ + unsigned int next_size; + + /* Check lower/upper bounds */ + if (size < range->min) + return -1; + + if (size > range->max) + return -1; + + /* If range is actually only one value, size is correct */ + if (range->increment == 0) + return 0; + + /* Check if value is one of the supported sizes */ + for (next_size = range->min; next_size <= range->max; + next_size += range->increment) + if (size == next_size) + return 0; + + return -1; +} + +static int +comp_perf_check_capabilities(struct comp_test_data *test_data) +{ + const struct rte_compressdev_capabilities *cap; + + cap = rte_compressdev_capability_get(test_data->cdev_id, + RTE_COMP_ALGO_DEFLATE); + + if (cap == NULL) { + RTE_LOG(ERR, USER1, + "Compress device does not support DEFLATE\n"); + return -1; + } + + uint64_t comp_flags = cap->comp_feature_flags; + + /* Huffman enconding */ + if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED && + (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) { + RTE_LOG(ERR, USER1, + "Compress device does not supported Fixed Huffman\n"); + return -1; + } + + if (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC && + (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) { + RTE_LOG(ERR, USER1, + "Compress device does not supported Dynamic Huffman\n"); + return -1; + } + + /* Window size */ + if (test_data->window_sz != -1) { + if (param_range_check(test_data->window_sz, &cap->window_size) + < 0) { + RTE_LOG(ERR, USER1, + "Compress device does not support " + "this window size\n"); + return -1; + } + } else + /* Set window size to PMD maximum if none was specified */ + test_data->window_sz = cap->window_size.max; + + /* Check if chained mbufs is supported */ + if (test_data->max_sgl_segs > 1 && + (comp_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0) { + RTE_LOG(INFO, USER1, "Compress device does not support " + "chained mbufs. Max SGL segments set to 1\n"); + test_data->max_sgl_segs = 1; + } + + /* Level 0 support */ + if (test_data->level.min == 0 && + (comp_flags & RTE_COMP_FF_NONCOMPRESSED_BLOCKS) == 0) { + RTE_LOG(ERR, USER1, "Compress device does not support " + "level 0 (no compression)\n"); + return -1; + } + + return 0; +} + +static int +comp_perf_allocate_memory(struct comp_test_data *test_data) +{ + /* Number of segments for input and output + * (compression and decompression) + */ + uint32_t total_segs = DIV_CEIL(test_data->input_data_sz, + 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, + rte_socket_id()); + if (test_data->comp_buf_pool == NULL) { + RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\n"); + return -1; + } + + test_data->decomp_buf_pool = rte_pktmbuf_pool_create("decomp_buf_pool", + total_segs, + 0, 0, test_data->seg_sz + RTE_PKTMBUF_HEADROOM, + rte_socket_id()); + if (test_data->decomp_buf_pool == NULL) { + RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\n"); + return -1; + } + + test_data->total_bufs = DIV_CEIL(total_segs, test_data->max_sgl_segs); + + test_data->op_pool = rte_comp_op_pool_create("op_pool", + test_data->total_bufs, + 0, 0, rte_socket_id()); + if (test_data->op_pool == NULL) { + RTE_LOG(ERR, USER1, "Comp op mempool could not be created\n"); + return -1; + } + + /* + * Compressed data might be a bit larger than input data, + * if data cannot be compressed + */ + test_data->compressed_data = rte_zmalloc_socket(NULL, + test_data->input_data_sz * EXPANSE_RATIO + + MIN_ISAL_SIZE, 0, + rte_socket_id()); + if (test_data->compressed_data == NULL) { + RTE_LOG(ERR, USER1, "Memory to hold the data from the input " + "file could not be allocated\n"); + return -1; + } + + test_data->decompressed_data = rte_zmalloc_socket(NULL, + test_data->input_data_sz, 0, + rte_socket_id()); + if (test_data->decompressed_data == NULL) { + RTE_LOG(ERR, USER1, "Memory to hold the data from the input " + "file could not be allocated\n"); + return -1; + } + + test_data->comp_bufs = rte_zmalloc_socket(NULL, + test_data->total_bufs * sizeof(struct rte_mbuf *), + 0, rte_socket_id()); + if (test_data->comp_bufs == NULL) { + RTE_LOG(ERR, USER1, "Memory to hold the compression mbufs" + " could not be allocated\n"); + return -1; + } + + test_data->decomp_bufs = rte_zmalloc_socket(NULL, + test_data->total_bufs * sizeof(struct rte_mbuf *), + 0, rte_socket_id()); + if (test_data->decomp_bufs == NULL) { + RTE_LOG(ERR, USER1, "Memory to hold the decompression mbufs" + " could not be allocated\n"); + return -1; + } + return 0; +} + +static int +comp_perf_dump_input_data(struct comp_test_data *test_data) +{ + FILE *f = fopen(test_data->input_file, "r"); + + if (f == NULL) { + RTE_LOG(ERR, USER1, "Input file could not be opened\n"); + return -1; + } + + if (fseek(f, 0, SEEK_END) != 0) { + RTE_LOG(ERR, USER1, "Size of input could not be calculated\n"); + goto err; + } + size_t actual_file_sz = ftell(f); + /* If extended input data size has not been set, + * input data size = file size + */ + + if (test_data->input_data_sz == 0) + test_data->input_data_sz = actual_file_sz; + + if (fseek(f, 0, SEEK_SET) != 0) { + RTE_LOG(ERR, USER1, "Size of input could not be calculated\n"); + goto err; + } + + test_data->input_data = rte_zmalloc_socket(NULL, + test_data->input_data_sz, 0, rte_socket_id()); + + if (test_data->input_data == NULL) { + RTE_LOG(ERR, USER1, "Memory to hold the data from the input " + "file could not be allocated\n"); + goto err; + } + + size_t remaining_data = test_data->input_data_sz; + uint8_t *data = test_data->input_data; + + while (remaining_data > 0) { + size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz); + + if (fread(data, data_to_read, 1, f) != 1) { + RTE_LOG(ERR, USER1, "Input file could not be read\n"); + goto err; + } + if (fseek(f, 0, SEEK_SET) != 0) { + RTE_LOG(ERR, USER1, + "Size of input could not be calculated\n"); + goto err; + } + remaining_data -= data_to_read; + data += data_to_read; + } + + if (test_data->input_data_sz > actual_file_sz) + RTE_LOG(INFO, USER1, + "%zu bytes read from file %s, extending the file %.2f times\n", + test_data->input_data_sz, test_data->input_file, + (double)test_data->input_data_sz/actual_file_sz); + else + RTE_LOG(INFO, USER1, + "%zu bytes read from file %s\n", + test_data->input_data_sz, test_data->input_file); + + fclose(f); + + return 0; + +err: + fclose(f); + rte_free(test_data->input_data); + test_data->input_data = NULL; + + return -1; +} + +static int +comp_perf_initialize_compressdev(struct comp_test_data *test_data) +{ + uint8_t enabled_cdev_count; + uint8_t enabled_cdevs[RTE_COMPRESS_MAX_DEVS]; + + enabled_cdev_count = rte_compressdev_devices_get(test_data->driver_name, + enabled_cdevs, RTE_COMPRESS_MAX_DEVS); + if (enabled_cdev_count == 0) { + RTE_LOG(ERR, USER1, "No compress devices type %s available\n", + test_data->driver_name); + return -EINVAL; + } + + if (enabled_cdev_count > 1) + RTE_LOG(INFO, USER1, + "Only the first compress device will be used\n"); + + test_data->cdev_id = enabled_cdevs[0]; + + if (comp_perf_check_capabilities(test_data) < 0) + return -1; + + /* Configure compressdev (one device, one queue pair) */ + struct rte_compressdev_config config = { + .socket_id = rte_socket_id(), + .nb_queue_pairs = 1, + .max_nb_priv_xforms = NUM_MAX_XFORMS, + .max_nb_streams = 0 + }; + + if (rte_compressdev_configure(test_data->cdev_id, &config) < 0) { + RTE_LOG(ERR, USER1, "Device configuration failed\n"); + return -1; + } + + if (rte_compressdev_queue_pair_setup(test_data->cdev_id, 0, + NUM_MAX_INFLIGHT_OPS, rte_socket_id()) < 0) { + RTE_LOG(ERR, USER1, "Queue pair setup failed\n"); + return -1; + } + + if (rte_compressdev_start(test_data->cdev_id) < 0) { + RTE_LOG(ERR, USER1, "Device could not be started\n"); + return -1; + } + + return 0; +} + +static int +prepare_bufs(struct comp_test_data *test_data) +{ + uint32_t remaining_data = test_data->input_data_sz; + uint8_t *input_data_ptr = test_data->input_data; + size_t data_sz; + uint8_t *data_addr; + uint32_t i, j; + + for (i = 0; i < test_data->total_bufs; i++) { + /* Allocate data in input mbuf and copy data from input file */ + test_data->decomp_bufs[i] = + rte_pktmbuf_alloc(test_data->decomp_buf_pool); + if (test_data->decomp_bufs[i] == NULL) { + RTE_LOG(ERR, USER1, "Could not allocate mbuf\n"); + return -1; + } + + data_sz = RTE_MIN(remaining_data, test_data->seg_sz); + data_addr = (uint8_t *) rte_pktmbuf_append( + test_data->decomp_bufs[i], data_sz); + if (data_addr == NULL) { + RTE_LOG(ERR, USER1, "Could not append data\n"); + return -1; + } + rte_memcpy(data_addr, input_data_ptr, data_sz); + + input_data_ptr += data_sz; + remaining_data -= data_sz; + + /* Already one segment in the mbuf */ + uint16_t segs_per_mbuf = 1; + + /* Chain mbufs if needed for input mbufs */ + while (segs_per_mbuf < test_data->max_sgl_segs + && remaining_data > 0) { + struct rte_mbuf *next_seg = + rte_pktmbuf_alloc(test_data->decomp_buf_pool); + + if (next_seg == NULL) { + RTE_LOG(ERR, USER1, + "Could not allocate mbuf\n"); + return -1; + } + + data_sz = RTE_MIN(remaining_data, test_data->seg_sz); + data_addr = (uint8_t *)rte_pktmbuf_append(next_seg, + data_sz); + + if (data_addr == NULL) { + RTE_LOG(ERR, USER1, "Could not append data\n"); + return -1; + } + + rte_memcpy(data_addr, input_data_ptr, data_sz); + input_data_ptr += data_sz; + remaining_data -= data_sz; + + if (rte_pktmbuf_chain(test_data->decomp_bufs[i], + next_seg) < 0) { + RTE_LOG(ERR, USER1, "Could not chain mbufs\n"); + return -1; + } + segs_per_mbuf++; + } + + /* Allocate data in output mbuf */ + test_data->comp_bufs[i] = + rte_pktmbuf_alloc(test_data->comp_buf_pool); + if (test_data->comp_bufs[i] == NULL) { + RTE_LOG(ERR, USER1, "Could not allocate mbuf\n"); + return -1; + } + data_addr = (uint8_t *) rte_pktmbuf_append( + test_data->comp_bufs[i], + test_data->seg_sz); + if (data_addr == NULL) { + RTE_LOG(ERR, USER1, "Could not append data\n"); + return -1; + } + + /* Chain mbufs if needed for output mbufs */ + for (j = 1; j < segs_per_mbuf; j++) { + struct rte_mbuf *next_seg = + rte_pktmbuf_alloc(test_data->comp_buf_pool); + + if (next_seg == NULL) { + RTE_LOG(ERR, USER1, + "Could not allocate mbuf\n"); + return -1; + } + + data_addr = (uint8_t *)rte_pktmbuf_append(next_seg, + test_data->seg_sz); + + if (data_addr == NULL) { + RTE_LOG(ERR, USER1, "Could not append data\n"); + return -1; + } + + if (rte_pktmbuf_chain(test_data->comp_bufs[i], + next_seg) < 0) { + RTE_LOG(ERR, USER1, "Could not chain mbufs\n"); + return -1; + } + } + } + + return 0; +} + +static void +free_bufs(struct comp_test_data *test_data) +{ + uint32_t i; + + for (i = 0; i < test_data->total_bufs; i++) { + rte_pktmbuf_free(test_data->comp_bufs[i]); + rte_pktmbuf_free(test_data->decomp_bufs[i]); + } + rte_free(test_data->comp_bufs); + rte_free(test_data->decomp_bufs); +} + +static int +main_loop(struct comp_test_data *test_data, uint8_t level, + enum rte_comp_xform_type type, + uint8_t *output_data_ptr, + size_t *output_data_sz, + unsigned int benchmarking) +{ + uint8_t dev_id = test_data->cdev_id; + uint32_t i, iter, num_iter; + struct rte_comp_op **ops, **deq_ops; + void *priv_xform = NULL; + struct rte_comp_xform xform; + size_t output_size = 0; + struct rte_mbuf **input_bufs, **output_bufs; + int res = 0; + int allocated = 0; + + if (test_data == NULL || !test_data->burst_sz) { + RTE_LOG(ERR, USER1, + "Unknow burst size\n"); + return -1; + } + + ops = rte_zmalloc_socket(NULL, + 2 * test_data->total_bufs * sizeof(struct rte_comp_op *), + 0, rte_socket_id()); + + if (ops == NULL) { + RTE_LOG(ERR, USER1, + "Can't allocate memory for ops strucures\n"); + return -1; + } + + deq_ops = &ops[test_data->total_bufs]; + + if (type == RTE_COMP_COMPRESS) { + xform = (struct rte_comp_xform) { + .type = RTE_COMP_COMPRESS, + .compress = { + .algo = RTE_COMP_ALGO_DEFLATE, + .deflate.huffman = test_data->huffman_enc, + .level = level, + .window_size = test_data->window_sz, + .chksum = RTE_COMP_CHECKSUM_NONE, + .hash_algo = RTE_COMP_HASH_ALGO_NONE + } + }; + input_bufs = test_data->decomp_bufs; + output_bufs = test_data->comp_bufs; + } else { + xform = (struct rte_comp_xform) { + .type = RTE_COMP_DECOMPRESS, + .decompress = { + .algo = RTE_COMP_ALGO_DEFLATE, + .chksum = RTE_COMP_CHECKSUM_NONE, + .window_size = test_data->window_sz, + .hash_algo = RTE_COMP_HASH_ALGO_NONE + } + }; + input_bufs = test_data->comp_bufs; + output_bufs = test_data->decomp_bufs; + } + + /* Create private xform */ + if (rte_compressdev_private_xform_create(dev_id, &xform, + &priv_xform) < 0) { + RTE_LOG(ERR, USER1, "Private xform could not be created\n"); + res = -1; + goto end; + } + + uint64_t tsc_start, tsc_end, tsc_duration; + + tsc_start = tsc_end = tsc_duration = 0; + if (benchmarking) { + tsc_start = rte_rdtsc(); + num_iter = test_data->num_iter; + } else + num_iter = 1; + + for (iter = 0; iter < num_iter; iter++) { + uint32_t total_ops = test_data->total_bufs; + uint32_t remaining_ops = test_data->total_bufs; + uint32_t total_deq_ops = 0; + uint32_t total_enq_ops = 0; + uint16_t ops_unused = 0; + uint16_t num_enq = 0; + uint16_t num_deq = 0; + + output_size = 0; + + while (remaining_ops > 0) { + uint16_t num_ops = RTE_MIN(remaining_ops, + test_data->burst_sz); + uint16_t ops_needed = num_ops - ops_unused; + + /* + * Move the unused operations from the previous + * enqueue_burst call to the front, to maintain order + */ + if ((ops_unused > 0) && (num_enq > 0)) { + size_t nb_b_to_mov = + ops_unused * sizeof(struct rte_comp_op *); + + memmove(ops, &ops[num_enq], nb_b_to_mov); + } + + /* Allocate compression operations */ + if (ops_needed && !rte_comp_op_bulk_alloc( + test_data->op_pool, + &ops[ops_unused], + ops_needed)) { + RTE_LOG(ERR, USER1, + "Could not allocate enough operations\n"); + res = -1; + goto end; + } + allocated += ops_needed; + + for (i = 0; i < ops_needed; i++) { + /* + * Calculate next buffer to attach to operation + */ + uint32_t buf_id = total_enq_ops + i + + ops_unused; + uint16_t op_id = ops_unused + i; + /* Reset all data in output buffers */ + struct rte_mbuf *m = output_bufs[buf_id]; + + m->pkt_len = test_data->seg_sz * m->nb_segs; + while (m) { + m->data_len = m->buf_len - m->data_off; + m = m->next; + } + ops[op_id]->m_src = input_bufs[buf_id]; + ops[op_id]->m_dst = output_bufs[buf_id]; + ops[op_id]->src.offset = 0; + ops[op_id]->src.length = + rte_pktmbuf_pkt_len(input_bufs[buf_id]); + ops[op_id]->dst.offset = 0; + ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL; + ops[op_id]->input_chksum = buf_id; + ops[op_id]->private_xform = priv_xform; + } + + num_enq = rte_compressdev_enqueue_burst(dev_id, 0, ops, + num_ops); + ops_unused = num_ops - num_enq; + remaining_ops -= num_enq; + total_enq_ops += num_enq; + + num_deq = rte_compressdev_dequeue_burst(dev_id, 0, + deq_ops, + test_data->burst_sz); + total_deq_ops += num_deq; + if (benchmarking == 0) { + for (i = 0; i < num_deq; i++) { + struct rte_comp_op *op = deq_ops[i]; + const void *read_data_addr = + rte_pktmbuf_read(op->m_dst, 0, + op->produced, output_data_ptr); + if (read_data_addr == NULL) { + RTE_LOG(ERR, USER1, + "Could not copy buffer in destination\n"); + res = -1; + goto end; + } + + if (read_data_addr != output_data_ptr) + rte_memcpy(output_data_ptr, + rte_pktmbuf_mtod( + op->m_dst, uint8_t *), + op->produced); + output_data_ptr += op->produced; + output_size += op->produced; + + } + } + + if (iter == num_iter - 1) { + for (i = 0; i < num_deq; i++) { + struct rte_comp_op *op = deq_ops[i]; + struct rte_mbuf *m = op->m_dst; + + m->pkt_len = op->produced; + uint32_t remaining_data = op->produced; + uint16_t data_to_append; + + while (remaining_data > 0) { + data_to_append = + RTE_MIN(remaining_data, + test_data->seg_sz); + m->data_len = data_to_append; + remaining_data -= + data_to_append; + m = m->next; + } + } + } + rte_mempool_put_bulk(test_data->op_pool, + (void **)deq_ops, num_deq); + allocated -= num_deq; + } + + /* Dequeue the last operations */ + while (total_deq_ops < total_ops) { + num_deq = rte_compressdev_dequeue_burst(dev_id, 0, + deq_ops, test_data->burst_sz); + total_deq_ops += num_deq; + if (benchmarking == 0) { + for (i = 0; i < num_deq; i++) { + struct rte_comp_op *op = deq_ops[i]; + const void *read_data_addr = + rte_pktmbuf_read(op->m_dst, 0, + op->produced, output_data_ptr); + if (read_data_addr == NULL) { + RTE_LOG(ERR, USER1, + "Could not copy buffer in destination\n"); + res = -1; + goto end; + } + + if (read_data_addr != output_data_ptr) + rte_memcpy(output_data_ptr, + rte_pktmbuf_mtod( + op->m_dst, uint8_t *), + op->produced); + output_data_ptr += op->produced; + output_size += op->produced; + + } + } + + if (iter == num_iter - 1) { + for (i = 0; i < num_deq; i++) { + struct rte_comp_op *op = deq_ops[i]; + struct rte_mbuf *m = op->m_dst; + + m->pkt_len = op->produced; + uint32_t remaining_data = op->produced; + uint16_t data_to_append; + + while (remaining_data > 0) { + data_to_append = + RTE_MIN(remaining_data, + test_data->seg_sz); + m->data_len = data_to_append; + remaining_data -= + data_to_append; + m = m->next; + } + } + } + rte_mempool_put_bulk(test_data->op_pool, + (void **)deq_ops, num_deq); + allocated -= num_deq; + } + } + + if (benchmarking) { + tsc_end = rte_rdtsc(); + tsc_duration = tsc_end - tsc_start; + + if (type == RTE_COMP_COMPRESS) + test_data->comp_tsc_duration[level] = + tsc_duration / num_iter; + else + test_data->decomp_tsc_duration[level] = + tsc_duration / num_iter; + } + + if (benchmarking == 0 && output_data_sz) + *output_data_sz = output_size; +end: + rte_mempool_put_bulk(test_data->op_pool, (void **)ops, allocated); + rte_compressdev_private_xform_free(dev_id, priv_xform); + rte_free(ops); + return res; +} + int main(int argc, char **argv) { + uint8_t level, level_idx = 0; + uint8_t i; int ret; struct comp_test_data *test_data; @@ -43,9 +751,145 @@ main(int argc, char **argv) goto err; } + if (comp_perf_initialize_compressdev(test_data) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (comp_perf_dump_input_data(test_data) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (comp_perf_allocate_memory(test_data) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (prepare_bufs(test_data) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (test_data->level.inc != 0) + level = test_data->level.min; + else + level = test_data->level.list[0]; + + size_t comp_data_sz; + size_t decomp_data_sz; + + printf("Burst size = %u\n", test_data->burst_sz); + printf("File size = %zu\n", test_data->input_data_sz); + + printf("%6s%12s%17s%19s%21s%15s%21s%23s%16s\n", + "Level", "Comp size", "Comp ratio [%]", + "Comp [Cycles/it]", "Comp [Cycles/Byte]", "Comp [Gbps]", + "Decomp [Cycles/it]", "Decomp [Cycles/Byte]", "Decomp [Gbps]"); + + while (level <= test_data->level.max) { + /* + * Run a first iteration, to verify compression and + * get the compression ratio for the level + */ + if (main_loop(test_data, level, RTE_COMP_COMPRESS, + test_data->compressed_data, + &comp_data_sz, 0) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (main_loop(test_data, level, RTE_COMP_DECOMPRESS, + test_data->decompressed_data, + &decomp_data_sz, 0) < 0) { + ret = EXIT_FAILURE; + goto err; + } + + if (decomp_data_sz != test_data->input_data_sz) { + RTE_LOG(ERR, USER1, + "Decompressed data length not equal to input data length\n"); + RTE_LOG(ERR, USER1, + "Decompressed size = %zu, expected = %zu\n", + decomp_data_sz, test_data->input_data_sz); + ret = EXIT_FAILURE; + goto err; + } else { + if (memcmp(test_data->decompressed_data, + test_data->input_data, + test_data->input_data_sz) != 0) { + RTE_LOG(ERR, USER1, + "Decompressed data is not the same as file data\n"); + ret = EXIT_FAILURE; + goto err; + } + } + + double ratio = (double) comp_data_sz / + test_data->input_data_sz * 100; + + /* + * Run the tests twice, discarding the first performance + * results, before the cache is warmed up + */ + for (i = 0; i < 2; i++) { + if (main_loop(test_data, level, RTE_COMP_COMPRESS, + NULL, NULL, 1) < 0) { + ret = EXIT_FAILURE; + goto err; + } + } + + for (i = 0; i < 2; i++) { + if (main_loop(test_data, level, RTE_COMP_DECOMPRESS, + NULL, NULL, 1) < 0) { + ret = EXIT_FAILURE; + goto err; + } + } + + uint64_t comp_tsc_duration = + test_data->comp_tsc_duration[level]; + double comp_tsc_byte = (double)comp_tsc_duration / + test_data->input_data_sz; + double comp_gbps = rte_get_tsc_hz() / comp_tsc_byte * 8 / + 1000000000; + uint64_t decomp_tsc_duration = + test_data->decomp_tsc_duration[level]; + double decomp_tsc_byte = (double)decomp_tsc_duration / + test_data->input_data_sz; + double decomp_gbps = rte_get_tsc_hz() / decomp_tsc_byte * 8 / + 1000000000; + + printf("%6u%12zu%17.2f%19"PRIu64"%21.2f" + "%15.2f%21"PRIu64"%23.2f%16.2f\n", + level, comp_data_sz, ratio, comp_tsc_duration, + comp_tsc_byte, comp_gbps, decomp_tsc_duration, + decomp_tsc_byte, decomp_gbps); + + if (test_data->level.inc != 0) + level += test_data->level.inc; + else { + if (++level_idx == test_data->level.count) + break; + level = test_data->level.list[level_idx]; + } + } + ret = EXIT_SUCCESS; err: + if (test_data->cdev_id != -1) + rte_compressdev_stop(test_data->cdev_id); + + free_bufs(test_data); + rte_free(test_data->compressed_data); + rte_free(test_data->decompressed_data); + rte_free(test_data->input_data); + rte_mempool_free(test_data->comp_buf_pool); + rte_mempool_free(test_data->decomp_buf_pool); + rte_mempool_free(test_data->op_pool); + rte_free(test_data); return ret; From patchwork Mon Oct 1 13:27:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Jozwiak X-Patchwork-Id: 45781 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A85B71B20D; Mon, 1 Oct 2018 15:28:16 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1B8001B0FB for ; Mon, 1 Oct 2018 15:28:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Oct 2018 06:28:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,327,1534834800"; d="scan'208";a="91103219" Received: from tjozwiax-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.103.104.44]) by fmsmga002.fm.intel.com with ESMTP; 01 Oct 2018 06:27:18 -0700 From: Tomasz Jozwiak To: dev@dpdk.org, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com, akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com Cc: De@dpdk.org, Lara@dpdk.org, Guarch@dpdk.org Date: Mon, 1 Oct 2018 15:27:07 +0200 Message-Id: <1538400427-20164-4-git-send-email-tomaszx.jozwiak@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> References: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> Subject: [dpdk-dev] [PATCH 3/3] doc/guides/tools: add doc file 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added initial version of compression performance test description file. Signed-off-by: De Lara Guarch, Pablo Signed-off-by: Tomasz Jozwiak --- MAINTAINERS | 5 +++ doc/guides/tools/comp_perf.rst | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 doc/guides/tools/comp_perf.rst diff --git a/MAINTAINERS b/MAINTAINERS index 5967c1d..f8c3820 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1184,6 +1184,11 @@ M: Bernard Iremonger F: app/test-pmd/ F: doc/guides/testpmd_app_ug/ +Compression performance test application +M: De Lara Guarch, Pablo +F: app/test-compress-perf/ +F: doc/guides/tools/comp_perf.rst + Crypto performance test application M: Declan Doherty F: app/test-crypto-perf/ diff --git a/doc/guides/tools/comp_perf.rst b/doc/guides/tools/comp_perf.rst new file mode 100644 index 0000000..14abe8b --- /dev/null +++ b/doc/guides/tools/comp_perf.rst @@ -0,0 +1,73 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +dpdk-test-crypto-perf Application +================================= + +The ``dpdk-test-compress-perf`` tool is a Data Plane Development Kit (DPDK) +utility that allows measuring performance parameters of PMDs available in the +compress tree. The application reads the data from a file (--input-file), +dumps all the file into a buffer and fill out the data of input mbufs, +which are passed to compress device with compression operations. +Then, the output buffers are fed into the decompression stage, and the resulted +data is compared against the original data (verification phase). After that, +a number of iterations are performed, compressing first and decompressing later, +to check the throughput rate +(showing cycles/iteration, cycles/Byte and Gbps, for compression and decompression). + +.. Note:: + + This is the initial version of this document + +Command line options +-------------------- + + ``--driver-name NAME``: compress driver to use + + ``--input-file NAME``: file to compress and decompress + + ``--extended-input-sz N``: extend file data up to this size (default: no extension) + + ``--seg-sz N``: size of segment to store the data (default: 2048) + + ``--burst-sz N``: compress operation burst size + + ``--pool-sz N``: mempool size for compress operations/mbufs (default: 8192) + + ``--max-num-sgl-segs N``: maximum number of segments for each mbuf (default: 65535) + + ``--num-iter N``: number of times the file will be compressed/decompressed (default: 10000) + + ``--operation [comp/decomp/comp_and_decomp]``: perform test on compression, decompression or both operations + + ``--huffman-enc [fixed/dynamic/default]``: Huffman encoding (default: dynamic) + + ``--compress-level N``: compression level, which could be a single value, list or range (default: range between 1 and 9) + + ``--window-sz N``: base two log value of compression window size (default: max supported by PMD) + + ``-h``: prints this help + + +Compiling the Application +------------------------- + +**Step 1: PMD setting** + +The ``dpdk-test-compress-perf`` tool depends on compression device drivers PMD which +can be disabled by default in the build configuration file ``common_base``. +The compression device drivers PMD which should be tested can be enabled by setting:: + + CONFIG_RTE_LIBRTE_PMD_ISAL=y + + +Running the Application +----------------------- + +The tool application has a number of command line options. Here is the sample command line: + +.. code-block:: console + + ./build/app/dpdk-test-compress-perf -l 4 -- --driver-name compress_qat --input-file test.txt --seg-sz 8192 + --compress-level 1:1:9 --num-iter 10 --extended-input-sz 1048576 --max-num-sgl-segs 16 --huffman-enc fixed +