mempool: test performance with larger bursts
PATCH 1/1 mempool: test performance with larger bursts
Bursts of up to 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 4096.
This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
--- app/test/test_mempool_perf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
app/test/test_mempool_perf.c +16 -9
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h>
@@ -54,22 +54,24 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128 +* - Bulk put from 1 to 128 +* - Bulk get and put from 1 to 128, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 1024 +* - 4096 */ #define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 4096 +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -204,6 +206,8 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); else ret =-1 ;
@@ -289,9 +293,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)static int do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,128 ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,128 ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,1024 ,4096 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +305,9 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
Signature · 1 line
2.17.1
Hi Morten,
Quoted 2 lines · Morten Brørup
Bursts of up to 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128.
How about add 64 ?
Quoted 5 lines
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 4096.
This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
And for 2048? (I notice below already has 1024)
PS: with this commit, the number of combinations will grow much, and every subtest cost 5sec, so the total time will increases great. So could this perf suite support paramters or derivative command ? for instance:
REGISTER_PERF_TEST(mempool_perf_autotest, test_mempool_perf); REGISTER_PERF_TEST(mempool_perf_autotest_keeps256, test_mempool_perf_keeps256);
Thanks.
Quoted 81 lines
Signed-off-by Morten Brørup <[email protected]>--- app/test/test_mempool_perf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)app/test/test_mempool_perf.c +16
-9@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h> @@ -54,22 +54,24 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128 +* - Bulk put from 1 to 128 +* - Bulk get and put from 1 to 128, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 1024 +* - 4096 */ #define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 4096 +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))@@ -204,6 +206,8 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); else ret =-1 ;@@ -289,9 +293,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)static int do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,128 ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,128 ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,1024 ,4096 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;@@ -301,6 +305,9 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
PATCH v2 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 8192, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
---
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 packets, which is probably also not uncommon.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 107 ++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 45 deletions(-)
app/test/test_mempool_perf.c +62 -45
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h>
@@ -54,22 +54,24 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128 +* - Bulk put from 1 to 128 +* - Bulk get and put from 1 to 128, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 */ #define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 8192 +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -204,6 +206,10 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); else ret =-1 ;
@@ -289,9 +295,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)static int do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +307,9 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +332,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -376,65 +385,73 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); + use_external_cache =1 ; +if (do_one_mempool_test (mp_nocache, cores) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (2 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) goto err; - -rte_mempool_list_dump (stdout); ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
Hi Morten,
Quoted 130 lines · Morten Brørup
Bursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 8192, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Signed-off-by Morten Brørup <[email protected]>---
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 packets, which is probably also not uncommon.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.--- app/test/test_mempool_perf.c | 107 ++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 45 deletions(-)app/test/test_mempool_perf.c +21
-22@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h> @@ -54,22 +54,24 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128 +* - Bulk put from 1 to 128 +* - Bulk get and put from 1 to 128, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 */ #define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 8192 +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))@@ -204,6 +206,10 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); else ret =-1 ;@@ -289,9 +295,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)static int do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;@@ -301,6 +307,9 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;@@ -323,7 +332,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;@@ -376,65 +385,73 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores) <0 )
app/test/test_mempool_perf.c test_mempool_perf(void) · line 402
Quoted 10 lines
app/test/test_mempool_perf.c +4
-2goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); + use_external_cache =1 ;
This variable should set to zero after next test, because we may repeat execute command again. I think the original code already has this bug, suggest add a bugfix first and then with this commit.
Quoted 66 lines
app/test/test_mempool_perf.c +34
-18+if (do_one_mempool_test (mp_nocache, cores) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (2 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) goto err; - -rte_mempool_list_dump (stdout); ret =0 ; err:
app/test/test_mempool_perf.c test_mempool_perf(void) · line 457
Quoted 10 lines
app/test/test_mempool_perf.c +3
-3-rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
I'm OK for derivative tests by core-number.
With above bug fixed,
Thanks
Quoted 1 line
PATCH v3 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128. For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
---
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-)
app/test/test_mempool_perf.c +26 -16
@@ -54,9 +54,9 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 128 -* - Bulk put from 1 to 128 -* - Bulk get and put from 1 to 128, compile time constant +* - Bulk get from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) *
@@ -65,12 +65,13 @@* - 512 * - 2048 * - 8192 +* - 32768 */ -#define N 65536 +#define N 262144#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 8192 +#define MAX_KEEP 32768#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */
@@ -210,6 +211,9 @@ per_lcore_mempool_test(void *arg) ret =test_loop (mp, cache, n_keep,64 ,64 ); else if (n_get_bulk == 128) ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -293,11 +297,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -310,6 +316,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr)continue ; + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -346,8 +353,10 @@ do_all_mempool_perf_tests(unsigned int cores)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -356,8 +365,10 @@ do_all_mempool_perf_tests(unsigned int cores)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -386,21 +397,20 @@ do_all_mempool_perf_tests(unsigned int cores)rte_mempool_obj_iter (default_pool, my_obj_init,NULL );printf ("start performance test (without cache)\n" ); -if (do_one_mempool_test (mp_nocache, cores) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err;printf ("start performance test for %s (without cache)\n" , default_pool_ops); -if (do_one_mempool_test (default_pool, cores) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err;printf ("start performance test (with cache)\n" ); -if (do_one_mempool_test (mp_cache, cores) <0 ) +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err;printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; -if (do_one_mempool_test (mp_nocache, cores) <0 ) +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err;rte_mempool_list_dump (stdout);
Signature · 1 line
2.17.1
PATCH v4 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128. For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
---
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 125 +++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 49 deletions(-)
app/test/test_mempool_perf.c +76 -49
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h>
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536 +#define N 262144#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -204,6 +207,13 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -287,11 +297,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +313,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +339,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -337,8 +353,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -347,8 +365,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -376,65 +396,72 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (2 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) goto err; - -rte_mempool_list_dump (stdout); ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
PATCH v5 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128. For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of rate_persec calculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.
Added cache guard to per-lcore stats structure.
---
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision of rate_persec calculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 137 ++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 51 deletions(-)
app/test/test_mempool_perf.c +86 -51
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems */ #include <string.h>
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];
@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())
@@ -204,6 +210,13 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -215,6 +228,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);
@@ -232,6 +247,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);
@@ -278,7 +294,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);
@@ -287,11 +305,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +321,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +347,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -337,8 +361,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -347,8 +373,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -376,65 +404,72 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} -if (do_one_mempool_test (mp_nocache,2 ) <0 ) - goto err; +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (2 ) <0 ) + goto err; +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) goto err; - -rte_mempool_list_dump (stdout); ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
24/01/2024 12:21, Morten Brørup:
app/test/test_mempool_perf.c line 3
Quoted 7 lines
app/test/test_mempool_perf.c +1
-1@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems
You don't need to update copyright year.
The first year is the only important one.
[...]
app/test/test_mempool_perf.c test_mempool_perf(void) · line 474
Quoted 3 lines
app/test/test_mempool_perf.c +2
-0REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores);
How do we make sure the test is skipped if we have only 1 core?
Quoted 1 line
+REGISTER_PERF_TEST(mempool_perf_autotest_allcores,
test_mempool_perf_allcores);
How the test duration is changed after this patch?
Quoted 15 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, 18 February 2024 19.0424/01/2024 12:21, Morten Brørup:
app/test/test_mempool_perf.c line 3
Quoted 7 lines
app/test/test_mempool_perf.c +1
-1@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation -* Copyright(c) 2022 SmartShare Systems +* Copyright(c) 2022-2024 SmartShare Systems You don't need to update copyright year.
The first year is the only important one.
Quoted 2 lines
reading: https://matija.suklje.name/how-and-why-to-properly-write-
copyright-statements-in-your-code#why-not-bump-the-year-on-change
Thank you, Thomas. Very informative.
Will fix in next version.
Quoted 9 lines
[...]
Quoted 2 lines
REGISTER_PERF_TEST(mempool_perf_autotest, test_mempool_perf);
+REGISTER_PERF_TEST(mempool_perf_autotest_1core,
test_mempool_perf_1core);Quoted 1 line
+REGISTER_PERF_TEST(mempool_perf_autotest_2cores,
test_mempool_perf_2cores);How do we make sure the test is skipped if we have only 1 core?
Good point. Will fix in next version.
Quoted 6 lines
Quoted 2 lines
+REGISTER_PERF_TEST(mempool_perf_autotest_allcores,
test_mempool_perf_allcores);How the test duration is changed after this patch?
On my test machine, the expanded test parameter set increased the duration of one test run from 20 minutes to 100 minutes. Before the patch, all three test runs were always executed, i.e. a total duration of 60 minutes.
In other words:
The expanded test parameter set increased the test run duration by factor five.
Introducing the ability to optionally only test with a specific number of lcores reduced the total test duration to a third.
20/02/2024 14:49, Morten Brørup:
Quoted 16 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 8 lines
24/01/2024 12:21, Morten Brørup:
Quoted 2 lines
REGISTER_PERF_TEST(mempool_perf_autotest, test_mempool_perf);
+REGISTER_PERF_TEST(mempool_perf_autotest_1core,
test_mempool_perf_1core);Quoted 1 line
+REGISTER_PERF_TEST(mempool_perf_autotest_2cores,
test_mempool_perf_2cores);How do we make sure the test is skipped if we have only 1 core?
Good point. Will fix in next version.
Quoted 4 lines
Quoted 2 lines
+REGISTER_PERF_TEST(mempool_perf_autotest_allcores,
test_mempool_perf_allcores);
Quoted 8 lines
Quoted 1 line
How the test duration is changed after this patch?
On my test machine, the expanded test parameter set increased the duration of one test run from 20 minutes to 100 minutes. Before the patch, all three test runs were always executed, i.e. a total duration of 60 minutes.
In other words:
The expanded test parameter set increased the test run duration by factor five.
Introducing the ability to optionally only test with a specific number of lcores reduced the total test duration to a third.
That's a very long test.
It would be interesting to find a way to make it shorter.
Quoted 13 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 21 February 2024 11.2320/02/2024 14:49, Morten Brørup:
Quoted 5 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 2 lines
How the test duration is changed after this patch?
On my test machine, the expanded test parameter set increased the
duration of one test run from 20 minutes to 100 minutes.
Quoted 1 line
Before the patch, all three test runs were always executed, i.e. a
total duration of 60 minutes.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
In other words:
The expanded test parameter set increased the test run duration byfactor five.
Quoted 1 line
Introducing the ability to optionally only test with a specific
number of lcores reduced the total test duration to a third.
That's a very long test.
It would be interesting to find a way to make it shorter.
I tried looking into this, but I couldn't figure out how to pass parameters to a test, so I added the three variants with shorter tests, as suggested by Chengwen Feng.
Quoted 15 lines · Morten Brørup
Quoted 15 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 21 February 2024 11.2320/02/2024 14:49, Morten Brørup:
Quoted 5 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 2 lines
How the test duration is changed after this patch?
On my test machine, the expanded test parameter set increased the
duration of one test run from 20 minutes to 100 minutes.
Quoted 1 line
Before the patch, all three test runs were always executed, i.e. a
total duration of 60 minutes.
Quoted 3 lines
In other words:
The expanded test parameter set increased the test run duration by
Quoted 9 lines
Quoted 6 lines
factor five.
Quoted 1 line
Introducing the ability to optionally only test with a specific
number of lcores reduced the total test duration to a third.
That's a very long test.
It would be interesting to find a way to make it shorter.I tried looking into this, but I couldn't figure out how to pass parameters to a test, so I added the three variants with shorter tests, as suggested by Chengwen Feng.
It's not currently possible, but:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
/Bruce
PATCH v6 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64 or 128 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 128. For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of rate_persec calculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.
Added cache guard to per-lcore stats structure.
---
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision of rate_persec calculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 142 +++++++++++++++++++++++------------ 1 file changed, 94 insertions(+), 48 deletions(-)
app/test/test_mempool_perf.c +94 -48
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 128, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];
@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())
@@ -204,6 +210,13 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -215,6 +228,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);
@@ -232,6 +247,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);
@@ -278,7 +294,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);
@@ -287,11 +305,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +321,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +347,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -337,8 +361,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -347,8 +373,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -376,65 +404,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
PATCH v7 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of rate_persec calculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.
Added cache guard to per-lcore stats structure.
---
v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision of rate_persec calculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 144 +++++++++++++++++++++++------------ 1 file changed, 96 insertions(+), 48 deletions(-)
app/test/test_mempool_perf.c +96 -48
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];
@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())
@@ -204,6 +210,15 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == 256) + ret =test_loop (mp, cache, n_keep,256 ,256 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -215,6 +230,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);
@@ -232,6 +249,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);
@@ -278,7 +296,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);
@@ -287,11 +307,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +323,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +349,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -337,8 +363,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -347,8 +375,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -376,65 +406,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
PING for review. This patch is relatively trivial.
Quoted 345 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>---
v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision ofrate_perseccalculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZEobjects.
* Print error if unable to allocate mempool.
* Initializeuse_external_cachewith each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.--- app/test/test_mempool_perf.c | 144 +++++++++++++++++++++++------------ 1 file changed, 96 insertions(+), 48 deletions(-)app/test/test_mempool_perf.c +3
-3@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant
*
* - Number of kept objects (*n_keep*)
** - 32 * - 128 * - 512 + * - 2048 + * - 8192 + * - 32768*/
app/test/test_mempool_perf.c +0
-3-#define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1)
app/test/test_mempool_perf.c +3
-0+#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)
/* Number of pointers fitting into one cache line. */ #define
CACHE_LINE_BURST(RTE_CACHE_LINE_SIZE/sizeof(uintptr_t))app/test/test_mempool_perf.c +25
-6@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())@@ -204,6 +210,15 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == 256) + ret =test_loop (mp, cache, n_keep,256 ,256 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;@@ -215,6 +230,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);@@ -232,6 +249,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);@@ -278,7 +296,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);@@ -287,11 +307,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };app/test/test_mempool_perf.c +4
-0unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;@@ -301,6 +323,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache;app/test/test_mempool_perf.c +1
-1use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;@@ -323,7 +349,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;app/test/test_mempool_perf.c +57
-35struct rte_mempool *mp_nocache =NULL ;@@ -337,8 +363,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,@@ -347,8 +375,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */ @@ -376,65 +406,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST(mempool_perf_autotest_allcores,
test_mempool_perf_allcores);
--
2.17.1
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
-Morten
Quoted 352 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27PING for review. This patch is relatively trivial.
app/test/test_mempool_perf.c launch_cores(struct rte_mempool *mp, unsigned int
Quoted 157 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>---
v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision ofrate_perseccalculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZEobjects.
* Print error if unable to allocate mempool.
* Initializeuse_external_cachewith each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.--- app/test/test_mempool_perf.c | 144 +++++++++++++++++++++++------------ 1 file changed, 96 insertions(+), 48 deletions(-)app/test/test_mempool_perf.c +3
-3@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant
*
* - Number of kept objects (*n_keep*)
** - 32 * - 128 * - 512 + * - 2048 + * - 8192 + * - 32768*/
app/test/test_mempool_perf.c +0
-3-#define N 65536#define TIME_S 5#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1)
app/test/test_mempool_perf.c +3
-0+#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)
/* Number of pointers fitting into one cache line. */ #define
CACHE_LINE_BURST(RTE_CACHE_LINE_SIZE/sizeof(uintptr_t))app/test/test_mempool_perf.c +19
-2@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())@@ -204,6 +210,15 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == 256) + ret =test_loop (mp, cache, n_keep,256 ,256 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;@@ -215,6 +230,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);@@ -232,6 +249,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);@@ -278,7 +296,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);@@ -287,11 +307,13 @@ launch_cores(struct rte_mempool *mp, unsigned intcores)
app/test/test_mempool_perf.c do_one_mempool_test(struct rte_mempool *mp, unsigned
Quoted 21 lines
app/test/test_mempool_perf.c +6
-4/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;app/test/test_mempool_perf.c +0
-0unsigned *put_bulk_ptr;unsigned *keep_ptr;@@ -301,6 +323,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsignedint
Quoted 167 lines
app/test/test_mempool_perf.c +4
-0cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache;app/test/test_mempool_perf.c +1
-1use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;@@ -323,7 +349,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;app/test/test_mempool_perf.c +57
-35struct rte_mempool *mp_nocache =NULL ;@@ -337,8 +363,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,@@ -347,8 +375,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */ @@ -376,65 +406,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST(mempool_perf_autotest_allcores,
test_mempool_perf_allcores);
--
2.17.1
Bruce Richardson
Acked-byQuoted 45 lines · Morten Brørup
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
-Morten
Quoted 36 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27PING for review. This patch is relatively trivial.
Quoted 31 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>---
v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision ofrate_perseccalculation.
* Added missing cache guard to per-lcore stats structure.
This looks ok to me. However, the test itself takes a very long time to run, with 5 seconds per iteration. One suggest I have is to reduce the 5-seconds to 1-second - given we are looking at millions of iterations each time, the difference in results should not be that great, I'd hope. A very quick test of the delta on my end indicates variance in the first couple of results of a couple of %, just.
With or without this suggestion.
Quoted 50 lines
From: Bruce Richardson [mailto:[email protected]]
Quoted 18 lines · Morten Brørup
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
-Morten
Quoted 9 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27PING for review. This patch is relatively trivial.
Quoted 4 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase
the
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
maximum tested get and put burst sizes from 32 to 256. For convenience, also test get and put burst sizes of
RTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 5 seconds.Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>---
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision ofrate_perseccalculation.
* Added missing cache guard to per-lcore stats structure.
Quoted 4 lines
This looks ok to me. However, the test itself takes a very long time to run, with 5 seconds per iteration. One suggest I have is to reduce the 5-seconds to 1-second - given we are looking at millions of iterations each time, the difference in results should not be that great, I'd hope.
The test duration annoys me too.
Reducing the duration of each iteration would make the test more sensitive to short spikes of noise, e.g. from noisy neighbors in virtual environments. Someone once decided that 5 seconds was a good duration, and I didn't want to challenge that.
I also considered reducing the array of tested burst sizes, by jumping factor four here too; but I assume that both 32, 64, 128 and 256 are popular max burst sizes in applications, so I decided to keep them all, instead of omitting 32 and 128 and only keeping 64 and 256 to represent full bursts.
Quoted 3 lines
A very
quick test of the delta on my end indicates variance in the first couple of results of a couple of %, just.
Thanks for the review and suggestions, though.
Quoted 4 lines
With or without this suggestion.
Acked-by Bruce Richardson <[email protected]>
PING for apply.
Patch has 2 acks.
And since it was signed off by a co-maintainer (myself), I don't think an ack from the other co-maintainer (Andrew) is required. Please correct me if I'm wrong?
-Morten
Quoted 89 lines
-----Original Message-----
From: Morten Brørup [mailto:[email protected]]
Sent: Tuesday, 18 June 2024 15.48
To: Bruce Richardson
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v7] mempool: test performance with larger burstsQuoted 15 lines
From: Bruce Richardson [mailto:[email protected]]
Quoted 12 lines · Morten Brørup
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
-Morten
Quoted 3 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
PING for review. This patch is relatively trivial.
Quoted 4 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase
the
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
maximum tested get and put burst sizes from 32 to 256. For convenience, also test get and put burst sizes of
RTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor
four.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This exceeds the typical mempool cache size of 512 objects, so the
test
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing theactual
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
duration of the test, instead of assuming it took exactly 5 seconds.
Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>---
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
v7:
* Increase max burst size to 256. (Inspired by Honnappa) v6:
* Do not test with more lcores than available. (Thomas) v5:
* Increased N, to reduce measurement overhead with large numbers ofkept
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
objects.
* Increased precision ofrate_perseccalculation.
* Added missing cache guard to per-lcore stats structure.This looks ok to me. However, the test itself takes a very long time to run, with 5 seconds per iteration. One suggest I have is to reduce the 5-seconds to 1-second - given we are looking at millions of iterations each time, the difference in results should not be that great, I'd hope.
The test duration annoys me too.
Reducing the duration of each iteration would make the test more sensitive to short spikes of noise, e.g. from noisy neighbors in virtual environments. Someone once decided that 5 seconds was a good duration, and I didn't want to challenge that.
I also considered reducing the array of tested burst sizes, by jumping factor four here too; but I assume that both 32, 64, 128 and 256 are popular max burst sizes in applications, so I decided to keep them all, instead of omitting 32 and 128 and only keeping 64 and 256 to represent full bursts.
Quoted 3 lines
A very
quick test of the delta on my end indicates variance in the first couple of results of a couple of %, just.Thanks for the review and suggestions, though.
Quoted 4 lines
With or without this suggestion.
Acked-by Bruce Richardson <[email protected]>
13/09/2024 16:58, Morten Brørup:
Quoted 6 lines
PING for apply.
Patch has 2 acks.
And since it was signed off by a co-maintainer (myself),
I don't think an ack from the other co-maintainer (Andrew) is required. Please correct me if I'm wrong?
It's not a matter of acks.
I feel we should reduce from 5 seconds to 1 second as part of this patch. But seeing there is no more comments, I suppose I should apply this version.
Quoted 67 lines
From: Morten Brørup [mailto:[email protected]]
Quoted 66 lines
From: Bruce Richardson [mailto:[email protected]]
Quoted 11 lines · Morten Brørup
Quoted 10 lines
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
Quoted 3 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
PING for review. This patch is relatively trivial.
Quoted 4 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so increase
the
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
maximum tested get and put burst sizes from 32 to 256. For convenience, also test get and put burst sizes of
RTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor
four.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This exceeds the typical mempool cache size of 512 objects, so the
test
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing theactual
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
duration of the test, instead of assuming it took exactly 5 seconds.
Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>This looks ok to me. However, the test itself takes a very long time to run, with 5 seconds per iteration. One suggest I have is to reduce the 5-seconds to 1-second - given we are looking at millions of iterations each time, the difference in results should not be that great, I'd hope.
The test duration annoys me too.
Reducing the duration of each iteration would make the test more sensitive to short spikes of noise, e.g. from noisy neighbors in virtual environments. Someone once decided that 5 seconds was a good duration, and I didn't want to challenge that.
I also considered reducing the array of tested burst sizes, by jumping factor four here too; but I assume that both 32, 64, 128 and 256 are popular max burst sizes in applications, so I decided to keep them all, instead of omitting 32 and 128 and only keeping 64 and 256 to represent full bursts.
Quoted 3 lines
A very
quick test of the delta on my end indicates variance in the first couple of results of a couple of %, just.Thanks for the review and suggestions, though.
Quoted 4 lines
With or without this suggestion.
Acked-by Bruce Richardson <[email protected]>
Quoted 12 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, 16 September 2024 14.4113/09/2024 16:58, Morten Brørup:
Quoted 6 lines
PING for apply.
Patch has 2 acks.
And since it was signed off by a co-maintainer (myself),
I don't think an ack from the other co-maintainer (Andrew) is required. Please correct me if I'm wrong?
Quoted 3 lines
It's not a matter of acks.
I feel we should reduce from 5 seconds to 1 second as part of this patch.
As mentioned below, I was worried about reducing the test duration.
If you think the test will be accurate enough, I can easily reduce it to 1; you're not the only person annoyed by the long test duration.
Quoted 1 line
But seeing there is no more comments, I suppose I should apply this version.
Should I send v8 with reduced test duration from 5 to 1 second?
Quoted 80 lines
Quoted 22 lines
From: Morten Brørup [mailto:[email protected]]
Quoted 18 lines
From: Bruce Richardson [mailto:[email protected]]
Quoted 17 lines · Morten Brørup
Quoted 16 lines
PING (again) for review.
Many applications use bursts of more than 32 packets, and some applications buffer more than 512 packets.
This patch updates the mempool perf test accordingly.
Quoted 9 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 4 April 2024 11.27PING for review. This patch is relatively trivial.
Quoted 4 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Saturday, 2 March 2024 21.04Bursts of up to 64, 128 and 256 packets are not uncommon, so
increase
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
the
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
maximum tested get and put burst sizes from 32 to 256. For convenience, also test get and put burst sizes of
RTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the
maximum
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
number of kept objects from 512 to 32768, still in jumps of factor
four.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This exceeds the typical mempool cache size of 512 objects, so the
test
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also exercises the mempool driver.
Increased the precision of
rate_perseccalculation by timing theactual
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
duration of the test, instead of assuming it took exactly 5
seconds.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>This looks ok to me. However, the test itself takes a very long time to run, with 5 seconds per iteration. One suggest I have is to reduce the 5-seconds to 1-second - given we are looking at millions of iterations
each
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
time, the difference in results should not be that great, I'd hope.
The test duration annoys me too.
Reducing the duration of each iteration would make the test more sensitive
to
Quoted 2 lines
Quoted 2 lines
short spikes of noise, e.g. from noisy neighbors in virtual environments. Someone once decided that 5 seconds was a good duration, and I didn't want
to
Quoted 3 lines
Quoted 3 lines
challenge that.
I also considered reducing the array of tested burst sizes, by jumping
factor
Quoted 6 lines
Quoted 6 lines
four here too; but I assume that both 32, 64, 128 and 256 are popular max burst sizes in applications, so I decided to keep them all, instead of omitting 32 and 128 and only keeping 64 and 256 to represent full bursts.
Quoted 2 lines
A very
quick test of the delta on my end indicates variance in the first coupleof
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
results of a couple of %, just.
Thanks for the review and suggestions, though.
Quoted 4 lines
With or without this suggestion.
Acked-by Bruce Richardson <[email protected]>
16/09/2024 15:08, Morten Brørup:
Quoted 12 lines
Quoted 12 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, 16 September 2024 14.4113/09/2024 16:58, Morten Brørup:
Quoted 6 lines
PING for apply.
Patch has 2 acks.
And since it was signed off by a co-maintainer (myself),
I don't think an ack from the other co-maintainer (Andrew) is required. Please correct me if I'm wrong?
Quoted 6 lines
Quoted 3 lines
It's not a matter of acks.
I feel we should reduce from 5 seconds to 1 second as part of this patch.
As mentioned below, I was worried about reducing the test duration.
If you think the test will be accurate enough, I can easily reduce it to 1; you're not the only person annoyed by the long test duration.
I cannot be sure but it's probably worth to try.
Quoted 3 lines
Quoted 1 line
But seeing there is no more comments, I suppose I should apply this version.
Should I send v8 with reduced test duration from 5 to 1 second?
If you agree to try this duration, yes please send a v8.
PATCH v8 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Reduced the duration of each iteration from 5 seconds to 1 second.
Increased the precision of rate_persec calculation by timing the actual duration of the test, instead of assuming it took exactly 1 second.
Added cache guard to per-lcore stats structure.
---
v8:
* Reduced test iteration duration to 1 second. (Bruce, Thomas) v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision of rate_persec calculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 146 +++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 49 deletions(-)
app/test/test_mempool_perf.c +97 -49
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536 -#define TIME_S 5 +#define TIME_S 1#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; } __rte_cache_aligned;static struct mempool_test_stats stats[RTE_MAX_LCORE ];
@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())
@@ -204,6 +210,15 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == 256) + ret =test_loop (mp, cache, n_keep,256 ,256 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -215,6 +230,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);
@@ -232,6 +249,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);
@@ -278,7 +296,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);
@@ -287,11 +307,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -301,6 +323,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -323,7 +349,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -337,8 +363,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -347,8 +375,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -376,65 +406,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.17.1
PATCH v9 1/1 mempool: test performance with larger bursts
In reply to Morten BrørupBursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE.
Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Reduced the duration of each iteration from 5 seconds to 1 second.
Increased the precision of rate_persec calculation by timing the actual duration of the test, instead of assuming it took exactly 1 second.
Added cache guard to per-lcore stats structure.
---
v9:
* Rebased to main.
v8:
* Reduced test iteration duration to 1 second. (Bruce, Thomas) v7:
* Increase max burst size to 256. (Inspired by Honnappa)
v6:
* Do not test with more lcores than available. (Thomas)
v5:
* Increased N, to reduce measurement overhead with large numbers of kept objects.
* Increased precision of rate_persec calculation.
* Added missing cache guard to per-lcore stats structure.
v4:
* v3 failed to apply; I had messed up something with git.
* Added ACK from Chengwen Feng.
v3:
* Increased max number of kept objects to 32768.
* Added get and put burst sizes of RTE_MEMPOOL_CACHE_MAX_SIZE objects.
* Print error if unable to allocate mempool.
* Initialize use_external_cache with each test.
A previous version of this patch had a bug, where all test runs following the first would use external cache. (Chengwen Feng)
v2: Addressed feedback by Chengwen Feng
* Added get and put burst sizes of 64 objects, which is probably also not uncommon packet burst size.
* Fixed list of number of kept objects so list remains in jumps of factor four.
* Added three derivative test cases, for faster testing.
--- app/test/test_mempool_perf.c | 146 +++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 49 deletions(-)
app/test/test_mempool_perf.c +97 -49
@@ -54,22 +54,25 @@* * - Bulk size (*n_get_bulk*, *n_put_bulk*) * -* - Bulk get from 1 to 32 -* - Bulk put from 1 to 32 -* - Bulk get and put from 1 to 32, compile time constant +* - Bulk get from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE +* - Bulk get and put from 1 to 256, and RTE_MEMPOOL_CACHE_MAX_SIZE, compile time constant * * - Number of kept objects (*n_keep*) * * - 32 * - 128 * - 512 +* - 2048 +* - 8192 +* - 32768 */ -#define N 65536 -#define TIME_S 5 +#define TIME_S 1#define MEMPOOL_ELT_SIZE 2048 -#define MAX_KEEP 512 -#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1) +#define MAX_KEEP 32768 +#define N (128 * MAX_KEEP) +#define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE*2))-1)/* Number of pointers fitting into one cache line. */ #define CACHE_LINE_BURST (RTE_CACHE_LINE_SIZE / sizeof(uintptr_t))
@@ -100,9 +103,11 @@ static unsigned n_keep;/* true if we want to test with constant n_get_bulk and n_put_bulk */ static int use_constant_values; -/* number of enqueues / dequeues */ +/* number of enqueues / dequeues, and time used */ struct __rte_cache_aligned mempool_test_stats {uint64_t enq_count; +uint64_t duration_cycles; +RTE_CACHE_GUARD ; };static struct mempool_test_stats stats[RTE_MAX_LCORE ];
@@ -185,6 +190,7 @@ per_lcore_mempool_test(void *arg)GOTO_ERR (ret, out); stats[lcore_id].enq_count =0 ; + stats[lcore_id].duration_cycles =0 ;/* wait synchro for workers */ if (lcore_id !=rte_get_main_lcore ())
@@ -205,6 +211,15 @@ per_lcore_mempool_test(void *arg) CACHE_LINE_BURST, CACHE_LINE_BURST); else if (n_get_bulk == 32) ret =test_loop (mp, cache, n_keep,32 ,32 ); + else if (n_get_bulk == 64) + ret =test_loop (mp, cache, n_keep,64 ,64 ); + else if (n_get_bulk == 128) + ret =test_loop (mp, cache, n_keep,128 ,128 ); + else if (n_get_bulk == 256) + ret =test_loop (mp, cache, n_keep,256 ,256 ); + else if (n_get_bulk == RTE_MEMPOOL_CACHE_MAX_SIZE) + ret =test_loop (mp, cache, n_keep, +RTE_MEMPOOL_CACHE_MAX_SIZE ,RTE_MEMPOOL_CACHE_MAX_SIZE ); else ret =-1 ;
@@ -216,6 +231,8 @@ per_lcore_mempool_test(void *arg) stats[lcore_id].enq_count +=N ; } + stats[lcore_id].duration_cycles = time_diff; + out:if (use_external_cache) {rte_mempool_cache_flush (cache, mp);
@@ -233,6 +250,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)uint64_t rate;int ret;unsigned cores_save = cores; +double hz =rte_get_timer_hz ();rte_atomic_store_explicit (&synchro,0 , rte_memory_order_relaxed);
@@ -279,7 +297,9 @@ launch_cores(struct rte_mempool *mp, unsigned int cores) rate =0 ;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) - rate += (stats[lcore_id].enq_count /TIME_S ); +if (stats[lcore_id].duration_cycles !=0 ) + rate += (double )stats[lcore_id].enq_count * hz / + (double )stats[lcore_id].duration_cycles;printf ("rate_persec=%" PRIu64"\n" , rate);
@@ -288,11 +308,13 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)/* for a given number of core, launch all test cases */ static int -do_one_mempool_test (struct rte_mempool *mp,unsigned int cores) +do_one_mempool_test (struct rte_mempool *mp,unsigned int cores,int external_cache) { -unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,0 }; -unsigned int keep_tab[] = {32 ,128 ,512 ,0 }; +unsigned int bulk_tab_get[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int bulk_tab_put[] = {1 ,4 ,CACHE_LINE_BURST ,32 ,64 ,128 ,256 , +RTE_MEMPOOL_CACHE_MAX_SIZE ,0 }; +unsigned int keep_tab[] = {32 ,128 ,512 ,2048 ,8192 ,32768 ,0 };unsigned *get_bulk_ptr;unsigned *put_bulk_ptr;unsigned *keep_ptr;
@@ -302,6 +324,10 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores)for (put_bulk_ptr = bulk_tab_put; *put_bulk_ptr; put_bulk_ptr++) {for (keep_ptr = keep_tab; *keep_ptr; keep_ptr++) { +if (*keep_ptr < *get_bulk_ptr || *keep_ptr < *put_bulk_ptr) +continue ; + + use_external_cache = external_cache; use_constant_values =0 ; n_get_bulk = *get_bulk_ptr; n_put_bulk = *put_bulk_ptr;
@@ -324,7 +350,7 @@ do_one_mempool_test(struct rte_mempool *mp, unsigned int cores) }static int -test_mempool_perf (void ) +do_all_mempool_perf_tests (unsigned int cores) {struct rte_mempool *mp_cache =NULL ;struct rte_mempool *mp_nocache =NULL ;
@@ -338,8 +364,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_nocache ==NULL ) +if (mp_nocache ==NULL ) { +printf ("cannot allocate mempool (without cache)\n" ); goto err; + }/* create a mempool (with cache) */ mp_cache = rte_mempool_create("perf_test_cache", MEMPOOL_SIZE,
@@ -348,8 +376,10 @@ test_mempool_perf(void)NULL ,NULL , my_obj_init,NULL , SOCKET_ID_ANY, 0); -if (mp_cache ==NULL ) +if (mp_cache ==NULL ) { +printf ("cannot allocate mempool (with cache)\n" ); goto err; + } default_pool_ops =rte_mbuf_best_mempool_ops ();/* Create a mempool based on Default handler */
@@ -377,65 +407,83 @@ test_mempool_perf(void)rte_mempool_obj_iter (default_pool, my_obj_init,NULL ); -/* performance test with 1, 2 and max cores */ printf ("start performance test (without cache)\n" ); - -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; - -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +if (do_one_mempool_test (mp_nocache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) - goto err; - -/* performance test with 1, 2 and max cores */ printf ("start performance test for %s (without cache)\n" , default_pool_ops); - -if (do_one_mempool_test (default_pool,1 ) <0 ) +if (do_one_mempool_test (default_pool, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,2 ) <0 ) +printf ("start performance test (with cache)\n" ); +if (do_one_mempool_test (mp_cache, cores,0 ) <0 ) goto err; -if (do_one_mempool_test (default_pool,rte_lcore_count ()) <0 ) +printf ("start performance test (with user-owned cache)\n" ); +if (do_one_mempool_test (mp_nocache, cores,1 ) <0 ) goto err; -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with cache)\n" ); +rte_mempool_list_dump (stdout); -if (do_one_mempool_test (mp_cache,1 ) <0 ) - goto err; + ret =0 ; -if (do_one_mempool_test (mp_cache,2 ) <0 ) - goto err; +err: +rte_mempool_free (mp_cache); +rte_mempool_free (mp_nocache); +rte_mempool_free (default_pool); +return ret; +} -if (do_one_mempool_test (mp_cache,rte_lcore_count ()) <0 ) - goto err; +static int +test_mempool_perf_1core (void ) +{ +return do_all_mempool_perf_tests (1 ); +} -/* performance test with 1, 2 and max cores */ -printf ("start performance test (with user-owned cache)\n" ); - use_external_cache =1 ; +static int +test_mempool_perf_2cores (void ) +{ +if (rte_lcore_count () <2 ) { +printf ("not enough lcores\n" ); +return -1 ; + } +return do_all_mempool_perf_tests (2 ); +} -if (do_one_mempool_test (mp_nocache,1 ) <0 ) - goto err; +static int +test_mempool_perf_allcores (void ) +{ +return do_all_mempool_perf_tests (rte_lcore_count ()); +} + +static int +test_mempool_perf (void ) +{ +int ret =-1 ; -if (do_one_mempool_test (mp_nocache,2 ) <0 ) +/* performance test with 1, 2 and max cores */ +if (do_all_mempool_perf_tests (1 ) <0 ) goto err; +if (rte_lcore_count () ==1 ) + goto done; -if (do_one_mempool_test (mp_nocache,rte_lcore_count ()) <0 ) +if (do_all_mempool_perf_tests (2 ) <0 ) goto err; +if (rte_lcore_count () ==2 ) + goto done; -rte_mempool_list_dump (stdout); +if (do_all_mempool_perf_tests (rte_lcore_count ()) <0 ) + goto err; +done: ret =0 ; err: -rte_mempool_free (mp_cache); -rte_mempool_free (mp_nocache); -rte_mempool_free (default_pool);return ret; }REGISTER_PERF_TEST (mempool_perf_autotest, test_mempool_perf); +REGISTER_PERF_TEST (mempool_perf_autotest_1core, test_mempool_perf_1core); +REGISTER_PERF_TEST (mempool_perf_autotest_2cores, test_mempool_perf_2cores); +REGISTER_PERF_TEST (mempool_perf_autotest_allcores, test_mempool_perf_allcores);
Signature · 1 line
2.43.0
Quoted 20 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Tuesday, 17 September 2024 10.10Bursts of up to 64, 128 and 256 packets are not uncommon, so increase the
maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four.
This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.Reduced the duration of each iteration from 5 seconds to 1 second.
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 1 second.
Quoted 6 lines
Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>Acked-by Bruce Richardson <[email protected]>---
Duration of mempool_perf_autotest on a 4 core x86_64 virtual machine: 1 hour 15 minutes
David Marchand
AppliedQuoted 13 lines · Morten Brørup
Bursts of up to 64, 128 and 256 packets are not uncommon, so increase the maximum tested get and put burst sizes from 32 to 256.
For convenience, also test get and put burst sizes ofRTE_MEMPOOL_CACHE_MAX_SIZE.Some applications keep more than 512 objects, so increase the maximum number of kept objects from 512 to 32768, still in jumps of factor four. This exceeds the typical mempool cache size of 512 objects, so the test also exercises the mempool driver.
Reduced the duration of each iteration from 5 seconds to 1 second.
Quoted 8 lines
Increased the precision of
rate_perseccalculation by timing the actual duration of the test, instead of assuming it took exactly 1 second.Added cache guard to per-lcore stats structure.
Signed-off-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks Morten.
Signature · 1 line
David Marchand