1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-10-12 19:04:54 +03:00

benchtests: Improve large memcpy/memset benchmarks

Adjust sizes between 64KB and 16MB and iterations based on length.
Remove incorrect uses of alloc_bufs since we're not interested in measuring
Linux clear_page time.  Use getpagesize() - 1 instead of 4095 when
aligning within a page.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Wilco Dijkstra
2024-03-18 15:05:38 +00:00
parent 226476e322
commit dac7ea4a6f
4 changed files with 14 additions and 43 deletions

View File

@@ -22,9 +22,8 @@
#else #else
# define TEST_NAME "bzero" # define TEST_NAME "bzero"
#endif #endif
#define START_SIZE (128 * 1024) #define START_SIZE (64 * 1024)
#define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024) #define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024)
#define TIMEOUT (20 * 60)
#include "bench-string.h" #include "bench-string.h"
#include "json-lib.h" #include "json-lib.h"
@@ -52,7 +51,7 @@ IMPL (memset_zero, 0)
static void static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n) do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n)
{ {
size_t i, iters = 16; size_t i, iters = (MIN_PAGE_SIZE * 64) / n;
timing_t start, stop, cur; timing_t start, stop, cur;
TIMING_NOW (start); TIMING_NOW (start);
@@ -74,20 +73,13 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n)
static void static void
do_test (json_ctx_t *json_ctx, size_t align, size_t len) do_test (json_ctx_t *json_ctx, size_t align, size_t len)
{ {
align &= 63;
if ((align + len) * sizeof (CHAR) > page_size)
return;
json_element_object_begin (json_ctx); json_element_object_begin (json_ctx);
json_attr_uint (json_ctx, "length", len); json_attr_uint (json_ctx, "length", len);
json_attr_uint (json_ctx, "alignment", align); json_attr_uint (json_ctx, "alignment", align);
json_array_begin (json_ctx, "timings"); json_array_begin (json_ctx, "timings");
FOR_EACH_IMPL (impl, 0) FOR_EACH_IMPL (impl, 0)
{
do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, len); do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, len);
alloc_bufs ();
}
json_array_end (json_ctx); json_array_end (json_ctx);
json_element_object_end (json_ctx); json_element_object_end (json_ctx);

View File

@@ -19,10 +19,9 @@
#ifndef MEMCPY_RESULT #ifndef MEMCPY_RESULT
# define MEMCPY_RESULT(dst, len) dst # define MEMCPY_RESULT(dst, len) dst
# define START_SIZE (64 * 1024) # define START_SIZE (64 * 1024)
# define MIN_PAGE_SIZE (getpagesize () + 32 * 1024 * 1024) # define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024)
# define TEST_MAIN # define TEST_MAIN
# define TEST_NAME "memcpy" # define TEST_NAME "memcpy"
# define TIMEOUT (20 * 60)
# include "bench-string.h" # include "bench-string.h"
IMPL (memcpy, 1) IMPL (memcpy, 1)
@@ -36,7 +35,7 @@ static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src, do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
size_t len) size_t len)
{ {
size_t i, iters = 16; size_t i, iters = (MIN_PAGE_SIZE * 8) / len;
timing_t start, stop, cur; timing_t start, stop, cur;
TIMING_NOW (start); TIMING_NOW (start);
@@ -59,12 +58,7 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
char *s1, *s2; char *s1, *s2;
size_t repeats; size_t repeats;
align1 &= 4095; align1 &= 4095;
if (align1 + len >= page_size)
return;
align2 &= 4095; align2 &= 4095;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf1 + align1); s1 = (char *) (buf1 + align1);
s2 = (char *) (buf2 + align2); s2 = (char *) (buf2 + align2);

View File

@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
#define BASE_PAGE_SIZE (1024 * 1024) #define START_SIZE (64 * 1024)
#define START_SIZE (4 * 1024)
#define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024) #define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024)
#define TEST_MAIN #define TEST_MAIN
#define TEST_NAME "memmove" #define TEST_NAME "memmove"
#define TIMEOUT (20 * 60)
#include "bench-string.h" #include "bench-string.h"
#include "json-lib.h" #include "json-lib.h"
@@ -33,7 +31,7 @@ static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
size_t len) size_t len)
{ {
size_t i, iters = 16; size_t i, iters = (MIN_PAGE_SIZE * 8) / len;
timing_t start, stop, cur; timing_t start, stop, cur;
TIMING_NOW (start); TIMING_NOW (start);
@@ -54,13 +52,8 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
size_t i, j; size_t i, j;
char *s1, *s2; char *s1, *s2;
align1 &= 127; align1 &= 4095;
if (align1 + len >= page_size) align2 &= 4095;
return;
align2 &= 127;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf2 + align1); s1 = (char *) (buf2 + align1);
s2 = (char *) (buf2 + align2); s2 = (char *) (buf2 + align2);

View File

@@ -18,9 +18,8 @@
#define TEST_MAIN #define TEST_MAIN
#define TEST_NAME "memset" #define TEST_NAME "memset"
#define START_SIZE (128 * 1024) #define START_SIZE (64 * 1024)
#define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024) #define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024)
#define TIMEOUT (20 * 60)
#include "bench-string.h" #include "bench-string.h"
#include "json-lib.h" #include "json-lib.h"
@@ -35,7 +34,7 @@ static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
int c __attribute ((unused)), size_t n) int c __attribute ((unused)), size_t n)
{ {
size_t i, iters = 16; size_t i, iters = (MIN_PAGE_SIZE * 64) / n;
timing_t start, stop, cur; timing_t start, stop, cur;
TIMING_NOW (start); TIMING_NOW (start);
@@ -53,10 +52,6 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
static void static void
do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len) do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
{ {
align &= 63;
if ((align + len) * sizeof (CHAR) > page_size)
return;
json_element_object_begin (json_ctx); json_element_object_begin (json_ctx);
json_attr_uint (json_ctx, "length", len); json_attr_uint (json_ctx, "length", len);
json_attr_uint (json_ctx, "alignment", align); json_attr_uint (json_ctx, "alignment", align);
@@ -64,10 +59,7 @@ do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
json_array_begin (json_ctx, "timings"); json_array_begin (json_ctx, "timings");
FOR_EACH_IMPL (impl, 0) FOR_EACH_IMPL (impl, 0)
{
do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len); do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
alloc_bufs ();
}
json_array_end (json_ctx); json_array_end (json_ctx);
json_element_object_end (json_ctx); json_element_object_end (json_ctx);