2020-01-01 00:14:33 +00:00
|
|
|
|
# Copyright (C) 2013-2020 Free Software Foundation, Inc.
|
2013-03-15 07:00:03 +00:00
|
|
|
|
# This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
# License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
|
# <https://www.gnu.org/licenses/>.
|
2013-03-15 07:00:03 +00:00
|
|
|
|
|
|
|
|
|
# Makefile for benchmark tests. The only useful target here is `bench`.
|
2013-05-22 05:35:04 +00:00
|
|
|
|
# Add benchmark functions in alphabetical order.
|
2013-03-15 07:00:03 +00:00
|
|
|
|
|
|
|
|
|
subdir := benchtests
|
2014-02-26 23:12:03 +00:00
|
|
|
|
|
|
|
|
|
include ../Makeconfig
|
2015-12-08 18:45:14 +00:00
|
|
|
|
bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 log log2 \
|
2016-12-19 13:00:45 +00:00
|
|
|
|
modf pow rint sin sincos sinh sqrt tan tanh fmin fmax fminf \
|
2017-10-13 08:49:45 +00:00
|
|
|
|
fmaxf powf trunc truncf expf exp2f logf log2f sincosf sinf \
|
2019-03-14 11:55:04 +00:00
|
|
|
|
cosf isnan isinf isfinite hypot logb logbf
|
2014-04-15 09:03:06 +00:00
|
|
|
|
|
nptl: Invert the mmap/mprotect logic on allocated stacks (BZ#18988)
Current allocate_stack logic for create stacks is to first mmap all
the required memory with the desirable memory and then mprotect the
guard area with PROT_NONE if required. Although it works as expected,
it pessimizes the allocation because it requires the kernel to actually
increase commit charge (it counts against the available physical/swap
memory available for the system).
The only issue is to actually check this change since side-effects are
really Linux specific and to actually account them it would require a
kernel specific tests to parse the system wide information. On the kernel
I checked /proc/self/statm does not show any meaningful difference for
vmm and/or rss before and after thread creation. I could only see
really meaningful information checking on system wide /proc/meminfo
between thread creation: MemFree, MemAvailable, and Committed_AS shows
large difference without the patch. I think trying to use these
kind of information on a testcase is fragile.
The BZ#18988 reports shows that the commit pages are easily seen with
mlockall (MCL_FUTURE) (with lock all pages that become mapped in the
process) however a more straighfoward testcase shows that pthread_create
could be faster using this patch:
--
static const int inner_count = 256;
static const int outer_count = 128;
static
void *thread1(void *arg)
{
return NULL;
}
static
void *sleeper(void *arg)
{
pthread_t ts[inner_count];
for (int i = 0; i < inner_count; i++)
pthread_create (&ts[i], &a, thread1, NULL);
for (int i = 0; i < inner_count; i++)
pthread_join (ts[i], NULL);
return NULL;
}
int main(void)
{
pthread_attr_init(&a);
pthread_attr_setguardsize(&a, 1<<20);
pthread_attr_setstacksize(&a, 1134592);
pthread_t ts[outer_count];
for (int i = 0; i < outer_count; i++)
pthread_create(&ts[i], &a, sleeper, NULL);
for (int i = 0; i < outer_count; i++)
pthread_join(ts[i], NULL);
assert(r == 0);
}
return 0;
}
--
On x86_64 (4.4.0-45-generic, gcc 5.4.0) running the small benchtests
I see:
$ time ./test
real 0m3.647s
user 0m0.080s
sys 0m11.836s
While with the patch I see:
$ time ./test
real 0m0.696s
user 0m0.040s
sys 0m1.152s
So I added a pthread_create benchtest (thread_create) which check
the thread creation latency. As for the simple benchtests, I saw
improvements in thread creation on all architectures I tested the
change.
Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu,
and sparcv9-linux-gnu.
[BZ #18988]
* benchtests/thread_create-inputs: New file.
* benchtests/thread_create-source.c: Likewise.
* support/xpthread_attr_setguardsize.c: Likewise.
* support/Makefile (libsupport-routines): Add
xpthread_attr_setguardsize object.
* support/xthread.h: Add xpthread_attr_setguardsize prototype.
* benchtests/Makefile (bench-pthread): Add thread_create.
* nptl/allocatestack.c (allocate_stack): Call mmap with PROT_NONE and
then mprotect the required area.
2017-01-31 20:01:59 +00:00
|
|
|
|
bench-pthread := pthread_once thread_create
|
2014-04-15 09:03:06 +00:00
|
|
|
|
|
2015-12-08 18:45:14 +00:00
|
|
|
|
bench-string := ffs ffsll
|
|
|
|
|
|
2017-11-28 14:27:46 +00:00
|
|
|
|
ifeq (${BENCHSET},)
|
2015-12-08 18:45:14 +00:00
|
|
|
|
bench := $(bench-math) $(bench-pthread) $(bench-string)
|
2017-11-28 14:27:46 +00:00
|
|
|
|
else
|
|
|
|
|
bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
|
|
|
|
|
endif
|
2013-05-22 05:35:04 +00:00
|
|
|
|
|
2013-04-16 12:07:24 +00:00
|
|
|
|
# String function benchmarks.
|
2019-02-12 17:19:51 +00:00
|
|
|
|
string-benchset := memccpy memchr memcmp memcpy memmem memmove \
|
2015-12-08 18:45:14 +00:00
|
|
|
|
mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
|
|
|
|
|
strcat strchr strchrnul strcmp strcpy strcspn strlen \
|
|
|
|
|
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
|
|
|
|
|
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok \
|
2017-10-05 16:19:37 +00:00
|
|
|
|
strcoll memcpy-large memcpy-random memmove-large memset-large \
|
2017-10-05 16:23:13 +00:00
|
|
|
|
memcpy-walk memset-walk memmove-walk
|
2016-04-20 07:49:01 +00:00
|
|
|
|
|
|
|
|
|
# Build and run locale-dependent benchmarks only if we're building natively.
|
|
|
|
|
ifeq (no,$(cross-compiling))
|
2015-12-08 18:45:14 +00:00
|
|
|
|
wcsmbs-benchset := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat \
|
|
|
|
|
wcscmp wcsncmp wcschr wcschrnul wcsrchr wcsspn wcspbrk wcscspn \
|
|
|
|
|
wmemchr wmemset wmemcmp
|
2016-04-20 07:49:01 +00:00
|
|
|
|
else
|
|
|
|
|
wcsmbs-benchset :=
|
|
|
|
|
endif
|
|
|
|
|
|
2015-12-08 18:45:14 +00:00
|
|
|
|
string-benchset-all := $(string-benchset) ${wcsmbs-benchset}
|
2013-04-16 12:07:24 +00:00
|
|
|
|
|
2016-04-20 07:49:01 +00:00
|
|
|
|
ifeq (no,$(cross-compiling))
|
2015-05-12 17:22:14 +00:00
|
|
|
|
# We have to generate locales
|
|
|
|
|
LOCALES := en_US.UTF-8 tr_TR.UTF-8 cs_CZ.UTF-8 fa_IR.UTF-8 fr_FR.UTF-8 \
|
|
|
|
|
ja_JP.UTF-8 si_LK.UTF-8 en_GB.UTF-8 vi_VN.UTF-8 ar_SA.UTF-8 \
|
|
|
|
|
da_DK.UTF-8 pl_PL.UTF-8 pt_PT.UTF-8 el_GR.UTF-8 ru_RU.UTF-8 \
|
2016-02-19 07:27:11 +00:00
|
|
|
|
he_IL.UTF-8 is_IS.UTF-8 es_ES.UTF-8 hi_IN.UTF-8 sv_SE.UTF-8 \
|
2015-05-12 17:22:14 +00:00
|
|
|
|
hu_HU.UTF-8 it_IT.UTF-8 sr_RS.UTF-8 zh_CN.UTF-8
|
|
|
|
|
include ../gen-locales.mk
|
2016-04-20 07:49:01 +00:00
|
|
|
|
endif
|
2015-05-12 17:22:14 +00:00
|
|
|
|
|
2015-12-08 18:45:14 +00:00
|
|
|
|
stdlib-benchset := strtod
|
2013-11-11 13:23:02 +00:00
|
|
|
|
|
2015-12-08 18:45:14 +00:00
|
|
|
|
stdio-common-benchset := sprintf
|
2015-05-21 14:01:34 +00:00
|
|
|
|
|
2015-09-18 15:02:38 +00:00
|
|
|
|
math-benchset := math-inlines
|
|
|
|
|
|
2017-11-28 14:27:46 +00:00
|
|
|
|
ifeq (${BENCHSET},)
|
2015-12-08 18:45:14 +00:00
|
|
|
|
benchset := $(string-benchset-all) $(stdlib-benchset) $(stdio-common-benchset) \
|
2015-09-18 15:02:38 +00:00
|
|
|
|
$(math-benchset)
|
2017-11-28 14:27:46 +00:00
|
|
|
|
else
|
|
|
|
|
benchset := $(foreach B,$(filter %-benchset,${BENCHSET}), ${${B}})
|
|
|
|
|
endif
|
2013-04-16 12:07:24 +00:00
|
|
|
|
|
2014-03-31 14:58:19 +00:00
|
|
|
|
CFLAGS-bench-ffs.c += -fno-builtin
|
|
|
|
|
CFLAGS-bench-ffsll.c += -fno-builtin
|
2016-10-21 21:18:03 +00:00
|
|
|
|
CFLAGS-bench-sqrt.c += -fno-builtin
|
2016-12-16 19:10:58 +00:00
|
|
|
|
CFLAGS-bench-fmin.c += -fno-builtin
|
2016-12-19 13:00:45 +00:00
|
|
|
|
CFLAGS-bench-fminf.c += -fno-builtin
|
2016-12-16 19:10:58 +00:00
|
|
|
|
CFLAGS-bench-fmax.c += -fno-builtin
|
2016-12-19 13:00:45 +00:00
|
|
|
|
CFLAGS-bench-fmaxf.c += -fno-builtin
|
2017-09-19 12:59:01 +00:00
|
|
|
|
CFLAGS-bench-trunc.c += -fno-builtin
|
|
|
|
|
CFLAGS-bench-truncf.c += -fno-builtin
|
2019-03-27 14:10:13 +00:00
|
|
|
|
CFLAGS-bench-isnan.c += -fsignaling-nans
|
|
|
|
|
CFLAGS-bench-isinf.c += -fsignaling-nans
|
|
|
|
|
CFLAGS-bench-isfinite.c += -fsignaling-nans
|
2014-03-31 14:58:19 +00:00
|
|
|
|
|
2017-11-28 14:27:46 +00:00
|
|
|
|
ifeq (${BENCHSET},)
|
2019-02-14 16:37:11 +00:00
|
|
|
|
bench-malloc := malloc-thread malloc-simple
|
2017-11-28 14:27:46 +00:00
|
|
|
|
else
|
|
|
|
|
bench-malloc := $(filter malloc-%,${BENCHSET})
|
|
|
|
|
endif
|
2013-09-11 14:47:12 +00:00
|
|
|
|
|
Use existing makefile variables for dependencies on glibc libraries.
glibc's Makeconfig defines some variables such as $(libm) and $(libdl)
for linking with libraries built by glibc, and nptl/Makeconfig
(included by the toplevel Makeconfig) defines others such as
$(shared-thread-library).
In some places glibc's Makefiles use those variables when linking
against the relevant libraries, but in other places they hardcode the
location of the libraries in the build tree. This patch cleans up
various places to use the variables that already exist (in the case of
libm, replacing several duplicate definitions of a $(link-libm)
variable in subdirectory Makefiles). (It's not necessarily exactly
equivalent to what the existing code does - in particular,
$(shared-thread-library) includes libpthread_nonshared, but is
replacing places that just referred to libpthread.so. But I think
that change is desirable on the general principle of linking things as
close as possible to the way in which they would be linked with an
installed library, unless there is a clear reason not to do so.)
To support running tests with an installed copy of glibc without
needing the full build tree from when that copy was built, I think it
will be useful to use such variables more generally and systematically
- every time the rules for building a test refer to some file from the
build tree that's also installed by glibc, use a makefile variable so
that the installed-testing case can point those variables to installed
copies of the files. This patch just deals with straightforward cases
where such variables already exist.
It's quite possible some uses of $(shared-thread-library) should
actually be a new $(thread-library) variable that's set appropriately
in the --disable-shared case, if those uses would in fact work without
shared libraries. I didn't change the status quo that those cases
hardcode use of a shared library whether or not it's actually needed
(but other uses such as $(libm) and $(libdl) would now get the static
library if the shared library isn't built, when some previously
hardcoded use of the shared library - if they actually need shared
libraries, the test itself needs an enable-shared conditional anyway).
Tested x86_64.
* benchtests/Makefile
($(addprefix $(objpfx)bench-,$(bench-math))): Depend on $(libm),
not $(common-objpfx)math/libm.so.
($(addprefix $(objpfx)bench-,$(bench-pthread))): Depend on
$(shared-thread-library), not $(common-objpfx)nptl/libpthread.so.
* elf/Makefile ($(objpfx)noload): Depend on $(libdl), not
$(common-objpfx)dlfcn/libdl.so.
($(objpfx)tst-audit8): Depend on $(libm), not
$(common-objpfx)math/libm.so.
* malloc/Makefile ($(objpfx)libmemusage.so): Depend on $(libdl),
not $(common-objpfx)dlfcn/libdl.so.
* math/Makefile
($(addprefix $(objpfx),$(filter-out $(tests-static),$(tests)))):
Depend on $(libm), not $(objpfx)libm.so. Do not condition on
[$(build-shared) = yes].
($(objpfx)test-fenv-tls): Depend on $(shared-thread-library), not
$(common-objpfx)nptl/libpthread.so.
* misc/Makefile ($(objpfx)tst-tsearch): Depend on $(libm), not
$(common-objpfx)math/libm.so$(libm.so-version) or
$(common-objpfx)math/libm.a depending on [$(build-shared) = yes].
* nptl/Makefile ($(objpfx)tst-unload): Depend on $(libdl), not
$(common-objpfx)dlfcn/libdl.so.
* setjmp/Makefile (link-libm): Remove variable.
($(objpfx)tst-setjmp-fp): Depend on $(libm), not $(link-libm).
* stdio-common/Makefile (link-libm): Remove variable.
($(objpfx)tst-printf-round): Depend on $(libm), not $(link-libm).
* stdlib/Makefile (link-libm): Remove variable.
($(objpfx)bug-getcontext): Depend on $(libm), not $(link-libm).
($(objpfx)tst-strtod-round): Likewise.
($(objpfx)tst-tininess): Likewise.
($(objpfx)tst-strtod-underflow): Likewise.
($(objpfx)tst-strtod6): Likewise.
($(objpfx)tst-tls-atexit): Depend on $(shared-thread-library) and
$(libdl), not $(common-objpfx)nptl/libpthread.so and
$(common-objpfx)dlfcn/libdl.so.
2014-05-16 21:38:08 +00:00
|
|
|
|
$(addprefix $(objpfx)bench-,$(bench-math)): $(libm)
|
2015-09-18 15:02:38 +00:00
|
|
|
|
$(addprefix $(objpfx)bench-,$(math-benchset)): $(libm)
|
Use existing makefile variables for dependencies on glibc libraries.
glibc's Makeconfig defines some variables such as $(libm) and $(libdl)
for linking with libraries built by glibc, and nptl/Makeconfig
(included by the toplevel Makeconfig) defines others such as
$(shared-thread-library).
In some places glibc's Makefiles use those variables when linking
against the relevant libraries, but in other places they hardcode the
location of the libraries in the build tree. This patch cleans up
various places to use the variables that already exist (in the case of
libm, replacing several duplicate definitions of a $(link-libm)
variable in subdirectory Makefiles). (It's not necessarily exactly
equivalent to what the existing code does - in particular,
$(shared-thread-library) includes libpthread_nonshared, but is
replacing places that just referred to libpthread.so. But I think
that change is desirable on the general principle of linking things as
close as possible to the way in which they would be linked with an
installed library, unless there is a clear reason not to do so.)
To support running tests with an installed copy of glibc without
needing the full build tree from when that copy was built, I think it
will be useful to use such variables more generally and systematically
- every time the rules for building a test refer to some file from the
build tree that's also installed by glibc, use a makefile variable so
that the installed-testing case can point those variables to installed
copies of the files. This patch just deals with straightforward cases
where such variables already exist.
It's quite possible some uses of $(shared-thread-library) should
actually be a new $(thread-library) variable that's set appropriately
in the --disable-shared case, if those uses would in fact work without
shared libraries. I didn't change the status quo that those cases
hardcode use of a shared library whether or not it's actually needed
(but other uses such as $(libm) and $(libdl) would now get the static
library if the shared library isn't built, when some previously
hardcoded use of the shared library - if they actually need shared
libraries, the test itself needs an enable-shared conditional anyway).
Tested x86_64.
* benchtests/Makefile
($(addprefix $(objpfx)bench-,$(bench-math))): Depend on $(libm),
not $(common-objpfx)math/libm.so.
($(addprefix $(objpfx)bench-,$(bench-pthread))): Depend on
$(shared-thread-library), not $(common-objpfx)nptl/libpthread.so.
* elf/Makefile ($(objpfx)noload): Depend on $(libdl), not
$(common-objpfx)dlfcn/libdl.so.
($(objpfx)tst-audit8): Depend on $(libm), not
$(common-objpfx)math/libm.so.
* malloc/Makefile ($(objpfx)libmemusage.so): Depend on $(libdl),
not $(common-objpfx)dlfcn/libdl.so.
* math/Makefile
($(addprefix $(objpfx),$(filter-out $(tests-static),$(tests)))):
Depend on $(libm), not $(objpfx)libm.so. Do not condition on
[$(build-shared) = yes].
($(objpfx)test-fenv-tls): Depend on $(shared-thread-library), not
$(common-objpfx)nptl/libpthread.so.
* misc/Makefile ($(objpfx)tst-tsearch): Depend on $(libm), not
$(common-objpfx)math/libm.so$(libm.so-version) or
$(common-objpfx)math/libm.a depending on [$(build-shared) = yes].
* nptl/Makefile ($(objpfx)tst-unload): Depend on $(libdl), not
$(common-objpfx)dlfcn/libdl.so.
* setjmp/Makefile (link-libm): Remove variable.
($(objpfx)tst-setjmp-fp): Depend on $(libm), not $(link-libm).
* stdio-common/Makefile (link-libm): Remove variable.
($(objpfx)tst-printf-round): Depend on $(libm), not $(link-libm).
* stdlib/Makefile (link-libm): Remove variable.
($(objpfx)bug-getcontext): Depend on $(libm), not $(link-libm).
($(objpfx)tst-strtod-round): Likewise.
($(objpfx)tst-tininess): Likewise.
($(objpfx)tst-strtod-underflow): Likewise.
($(objpfx)tst-strtod6): Likewise.
($(objpfx)tst-tls-atexit): Depend on $(shared-thread-library) and
$(libdl), not $(common-objpfx)nptl/libpthread.so and
$(common-objpfx)dlfcn/libdl.so.
2014-05-16 21:38:08 +00:00
|
|
|
|
$(addprefix $(objpfx)bench-,$(bench-pthread)): $(shared-thread-library)
|
2019-02-14 16:37:11 +00:00
|
|
|
|
$(addprefix $(objpfx)bench-,$(bench-malloc)): $(shared-thread-library)
|
2013-09-19 11:25:27 +00:00
|
|
|
|
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Rules to build and execute the benchmarks. Do not put any benchmark
|
|
|
|
|
# parameters beyond this point.
|
|
|
|
|
|
2013-04-16 12:07:24 +00:00
|
|
|
|
# We don't want the benchmark programs to run in parallel since that could
|
|
|
|
|
# affect their performance.
|
|
|
|
|
.NOTPARALLEL:
|
|
|
|
|
|
2017-08-21 17:28:54 +00:00
|
|
|
|
bench-extra-objs = json-lib.o
|
|
|
|
|
|
|
|
|
|
extra-objs += $(bench-extra-objs)
|
|
|
|
|
others-extras = $(bench-extra-objs)
|
|
|
|
|
|
2013-03-15 07:00:03 +00:00
|
|
|
|
include ../Rules
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
|
|
|
|
binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
|
2013-04-16 12:07:24 +00:00
|
|
|
|
binaries-benchset := $(addprefix $(objpfx)bench-,$(benchset))
|
2013-09-11 14:47:12 +00:00
|
|
|
|
binaries-bench-malloc := $(addprefix $(objpfx)bench-,$(bench-malloc))
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
2019-04-24 14:38:49 +00:00
|
|
|
|
# The default duration: 1 seconds.
|
2013-04-30 08:40:20 +00:00
|
|
|
|
ifndef BENCH_DURATION
|
2019-04-24 14:38:49 +00:00
|
|
|
|
BENCH_DURATION := 1
|
2013-04-30 08:40:20 +00:00
|
|
|
|
endif
|
|
|
|
|
|
2018-03-15 15:44:58 +00:00
|
|
|
|
CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC
|
2013-04-30 08:40:20 +00:00
|
|
|
|
|
2018-10-24 09:19:15 +00:00
|
|
|
|
# On x86 processors, use RDTSCP, instead of RDTSC, to measure performance
|
|
|
|
|
# of functions. All x86 processors since 2010 support RDTSCP instruction.
|
|
|
|
|
ifdef USE_RDTSCP
|
|
|
|
|
CPPFLAGS-nonlib += -DUSE_RDTSCP
|
|
|
|
|
endif
|
2013-05-13 08:14:32 +00:00
|
|
|
|
|
2014-03-29 04:10:19 +00:00
|
|
|
|
DETAILED_OPT :=
|
|
|
|
|
|
|
|
|
|
ifdef DETAILED
|
|
|
|
|
DETAILED_OPT := -d
|
|
|
|
|
endif
|
|
|
|
|
|
2013-04-16 13:04:03 +00:00
|
|
|
|
# This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
|
|
|
|
|
# for all these modules.
|
2013-09-11 14:47:12 +00:00
|
|
|
|
cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c) \
|
|
|
|
|
$(binaries-bench-malloc:=.c)
|
2013-04-16 13:04:03 +00:00
|
|
|
|
lib := nonlib
|
Rename cppflags-iterator.mk to libof-iterator.mk, remove extra-modules.mk.
cppflags-iterator.mk no longer has anything to do with CPPFLAGS; all
it does is set libof-$(foo) for a list of files. extra-modules.mk
does the same thing, but with a different input variable, and doesn't
let the caller control the module. Therefore, this patch gives
cppflags-iterator.mk a better name, removes extra-modules.mk, and
updates all uses of both.
* extra-modules.mk: Delete file.
* cppflags-iterator.mk: Rename to ...
* libof-iterator.mk: ...this. Adjust comments.
* Makerules, extra-lib.mk, benchtests/Makefile, elf/Makefile
* elf/rtld-Rules, iconv/Makefile, locale/Makefile, malloc/Makefile
* nscd/Makefile, sunrpc/Makefile, sysdeps/s390/Makefile:
Use libof-iterator.mk instead of cppflags-iterator.mk or
extra-modules.mk.
* benchtests/strcoll-inputs/filelist#en_US.UTF-8: Remove
extra-modules.mk and cppflags-iterator.mk, add libof-iterator.mk.
2017-05-08 19:52:26 +00:00
|
|
|
|
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
|
2013-04-16 13:04:03 +00:00
|
|
|
|
|
2013-05-13 08:14:32 +00:00
|
|
|
|
bench-deps := bench-skeleton.c bench-timing.h Makefile
|
2013-04-15 05:47:01 +00:00
|
|
|
|
|
2013-04-12 09:31:44 +00:00
|
|
|
|
run-bench = $(test-wrapper-env) \
|
Don't require test wrappers to preserve environment variables, use more consistent environment.
One wart in the original support for test wrappers for cross testing,
as noted in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00722.html>, is the
requirement for test wrappers to pass a poorly-defined set of
environment variables from the build system to the system running the
glibc under test. Although some variables are passed explicitly via
$(test-wrapper-env), including LD_* variables that simply can't be
passed implicitly because of the side effects they'd have on the build
system's dynamic linker, others are passed implicitly, including
variables such as GCONV_PATH and LOCPATH that could potentially affect
the build system's libc (so effectively relying on any such effects
not breaking the wrappers). In addition, the code in
cross-test-ssh.sh for preserving environment variables is fragile (it
depends on how bash formats a list of exported variables, and could
well break for multi-line variable definitions where the contents
contain things looking like other variable definitions).
This patch moves to explicitly passing environment variables via
$(test-wrapper-env). Makefile variables that previously used
$(test-wrapper) are split up into -before-env and -after-env parts
that can be passed separately to the various .sh files used in
testing, so those files can then insert environment settings between
the two parts.
The common default environment settings in make-test-out are made into
a separate makefile variable that can also be passed to scripts,
rather than many scripts duplicating those settings (for testing an
installed glibc, it is desirable to have the GCONV_PATH setting on
just one place, so just that one place needs to support it pointing to
an installed sysroot instead of the build tree). The default settings
are included in the variables such as $(test-program-prefix), so that
if tests do not need any non-default settings they can continue to use
single variables rather than the split-up variables.
Although this patch cleans up LC_ALL=C settings (that being part of
the common defaults), various LANG=C and LANGUAGE=C settings remain.
Those are generally unnecessary and I propose a subsequent cleanup to
remove them. LC_ALL takes precedence over LANG, and while LANGUAGE
takes precedence over LC_ALL, it only does so for settings other than
LC_ALL=C. So LC_ALL=C on its own is sufficient to ensure the C
locale, and anything that gets LC_ALL=C does not need the other
settings.
While preparing this patch I noticed some tests with .sh files that
appeared to do nothing beyond what the generic makefile support for
tests can do (localedata/tst-wctype.sh - the makefiles support -ENV
variables and .input files - and localedata/tst-mbswcs.sh - just runs
five tests that could be run individually from the makefile). So I
propose another subsequent cleanup to move those to using the generic
support instead of special .sh files.
Tested x86_64 (native) and powerpc32 (cross).
* Makeconfig (run-program-env): New variable.
(run-program-prefix-before-env): Likewise.
(run-program-prefix-after-env): Likewise.
(run-program-prefix): Define in terms of new variables.
(built-program-cmd-before-env): New variable.
(built-program-cmd-after-env): Likewise.
(built-program-cmd): Define in terms of new variables.
(test-program-prefix-before-env): New variable.
(test-program-prefix-after-env): Likewise.
(test-program-prefix): Define in terms of new variables.
(test-program-cmd-before-env): New variable.
(test-program-cmd-after-env): Likewise.
(test-program-cmd): Define in terms of new variables.
* Rules (make-test-out): Use $(run-program-env).
* scripts/cross-test-ssh.sh (env_blacklist): Remove variable.
(help): Do not mention environment variables. Mention
--timeoutfactor option.
(timeoutfactor): New variable.
(blacklist_exports): Remove function.
(exports): Remove variable.
(command): Do not include ${exports}.
* manual/install.texi (Configuring and compiling): Do not mention
test wrappers preserving environment variables. Mention that last
assignment to a variable must take precedence.
* INSTALL: Regenerated.
* benchtests/Makefile (run-bench): Use $(run-program-env).
* catgets/Makefile ($(objpfx)test1.cat): Use
$(built-program-cmd-before-env), $(run-program-env) and
$(built-program-cmd-after-env).
($(objpfx)test2.cat): Do not specify environment variables
explicitly.
($(objpfx)de/libc.cat): Use $(built-program-cmd-before-env),
$(run-program-env) and $(built-program-cmd-after-env).
($(objpfx)test-gencat.out): Use $(test-program-cmd-before-env),
$(run-program-env) and $(test-program-cmd-after-env).
($(objpfx)sample.SJIS.cat): Do not specify environment variables
explicitly.
* catgets/test-gencat.sh: Use test_program_cmd_before_env,
run_program_env and test_program_cmd_after_env arguments.
* elf/Makefile ($(objpfx)tst-pathopt.out): Use $(run-program-env).
* elf/tst-pathopt.sh: Use run_program_env argument.
* iconvdata/Makefile ($(objpfx)iconv-test.out): Use
$(test-wrapper-env) and $(run-program-env).
* iconvdata/run-iconv-test.sh: Use test_wrapper_env and
run_program_env arguments.
* iconvdata/tst-table.sh: Do not set GCONV_PATH explicitly.
* intl/Makefile ($(objpfx)tst-gettext.out): Use
$(test-program-prefix-before-env), $(run-program-env) and
$(test-program-prefix-after-env).
($(objpfx)tst-gettext2.out): Likewise.
* intl/tst-gettext.sh: Use test_program_prefix_before_env,
run_program_env and test_program_prefix_after_env arguments.
* intl/tst-gettext2.sh: Likewise.
* intl/tst-gettext4.sh: Do not set environment variables
explicitly.
* intl/tst-gettext6.sh: Likewise.
* intl/tst-translit.sh: Likewise.
* malloc/Makefile ($(objpfx)tst-mtrace.out): Use
$(test-program-prefix-before-env), $(run-program-env) and
$(test-program-prefix-after-env).
* malloc/tst-mtrace.sh: Use test_program_prefix_before_env,
run_program_env and test_program_prefix_after_env arguments.
* math/Makefile (run-regen-ulps): Use $(run-program-env).
* nptl/Makefile ($(objpfx)tst-tls6.out): Use $(run-program-env).
* nptl/tst-tls6.sh: Use run_program_env argument. Set LANG=C
explicitly with each use of ${test_wrapper_env}.
* posix/Makefile ($(objpfx)wordexp-tst.out): Use
$(test-program-prefix-before-env), $(run-program-env) and
$(test-program-prefix-after-env).
* posix/tst-getconf.sh: Do not set environment variables
explicitly.
* posix/wordexp-tst.sh: Use test_program_prefix_before_env,
run_program_env and test_program_prefix_after_env arguments.
* stdio-common/tst-printf.sh: Do not set environment variables
explicitly.
* stdlib/Makefile ($(objpfx)tst-fmtmsg.out): Use
$(test-program-prefix-before-env), $(run-program-env) and
$(test-program-prefix-after-env).
* stdlib/tst-fmtmsg.sh: Use test_program_prefix_before_env,
run_program_env and test_program_prefix_after_env arguments.
Split $test calls into $test_pre and $test.
* timezone/Makefile (build-testdata): Use
$(built-program-cmd-before-env), $(run-program-env) and
$(built-program-cmd-after-env).
localedata/ChangeLog:
* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
$(built-program-cmd-before-env), $(run-program-env) and
$(built-program-cmd-after-env).
($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
$(run-program-env) and $(test-program-prefix-after-env).
($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
$(run-program-env) and $(run-program-prefix-after-env).
($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
$(run-program-env) and $(built-program-cmd-after-env).
($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
$(run-program-env), $(run-program-prefix-after-env),
$(test-program-prefix-before-env) and
$(test-program-prefix-after-env).
($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
$(run-program-env) and $(test-program-cmd-after-env).
($(objpfx)tst-wctype.out): Likewise.
($(objpfx)tst-langinfo.out): Likewise.
($(objpfx)tst-langinfo-static.out): Likewise.
* gen-locale.sh: Use localedef_before_env, run_program_env and
localedef_after_env arguments.
* sort-test.sh: Use test_program_prefix_before_env,
run_program_env and test_program_prefix_after_env arguments.
* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
tst_ctype_after_env arguments.
* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
and run_program_prefix_after_env arguments.
* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
and tst_langinfo_after_env arguments.
* tst-locale.sh: Use localedef_before_env, run_program_env and
localedef_after_env arguments.
* tst-mbswcs.sh: Do not set environment variables explicitly.
* tst-numeric.sh: Likewise.
* tst-rpmatch.sh: Likewise.
* tst-trans.sh: Use run_program_prefix_before_env,
run_program_env, run_program_prefix_after_env,
test_program_prefix_before_env and test_program_prefix_after_env
arguments.
* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
tst_wctype_after_env arguments.
2014-06-06 22:19:27 +00:00
|
|
|
|
$(run-program-env) \
|
2016-03-08 12:53:24 +00:00
|
|
|
|
$($*-ENV) $(test-via-rtld-prefix) $${run}
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
2014-03-29 04:07:44 +00:00
|
|
|
|
timing-type := $(objpfx)bench-timing-type
|
|
|
|
|
|
2013-04-16 08:37:21 +00:00
|
|
|
|
bench-clean:
|
|
|
|
|
rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench))
|
2013-04-16 12:07:24 +00:00
|
|
|
|
rm -f $(binaries-benchset) $(addsuffix .o,$(binaries-benchset))
|
2013-09-11 14:47:12 +00:00
|
|
|
|
rm -f $(binaries-bench-malloc) $(addsuffix .o,$(binaries-bench-malloc))
|
2014-03-29 04:07:44 +00:00
|
|
|
|
rm -f $(timing-type) $(addsuffix .o,$(timing-type))
|
2016-04-20 05:49:49 +00:00
|
|
|
|
rm -f $(addprefix $(objpfx),$(bench-extra-objs))
|
2013-04-16 12:07:24 +00:00
|
|
|
|
|
2017-11-28 14:27:46 +00:00
|
|
|
|
# Validate the passed in BENCHSET
|
|
|
|
|
ifneq ($(strip ${BENCHSET}),)
|
|
|
|
|
VALIDBENCHSETNAMES := bench-pthread bench-math bench-string string-benchset \
|
|
|
|
|
wcsmbs-benchset stdlib-benchset stdio-common-benchset math-benchset \
|
2019-02-14 16:37:11 +00:00
|
|
|
|
malloc-thread malloc-simple
|
2017-11-28 14:27:46 +00:00
|
|
|
|
INVALIDBENCHSETNAMES := $(filter-out ${VALIDBENCHSETNAMES},${BENCHSET})
|
|
|
|
|
ifneq (${INVALIDBENCHSETNAMES},)
|
|
|
|
|
$(info The following values in BENCHSET are invalid: ${INVALIDBENCHSETNAMES})
|
|
|
|
|
$(info The valid ones are: ${VALIDBENCHSETNAMES})
|
|
|
|
|
$(error Invalid BENCHSET value)
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2016-04-20 07:49:01 +00:00
|
|
|
|
bench: bench-build bench-set bench-func bench-malloc
|
2016-12-22 17:37:52 +00:00
|
|
|
|
|
2016-04-20 07:49:01 +00:00
|
|
|
|
# Target to only build the benchmark without running it. We generate locales
|
|
|
|
|
# only if we're building natively.
|
|
|
|
|
ifeq (no,$(cross-compiling))
|
|
|
|
|
bench-build: $(gen-locales) $(timing-type) $(binaries-bench) \
|
|
|
|
|
$(binaries-benchset) $(binaries-bench-malloc)
|
|
|
|
|
else
|
|
|
|
|
bench-build: $(timing-type) $(binaries-bench) $(binaries-benchset) \
|
|
|
|
|
$(binaries-bench-malloc)
|
|
|
|
|
endif
|
2013-04-16 12:07:24 +00:00
|
|
|
|
|
|
|
|
|
bench-set: $(binaries-benchset)
|
|
|
|
|
for run in $^; do \
|
|
|
|
|
echo "Running $${run}"; \
|
|
|
|
|
$(run-bench) > $${run}.out; \
|
|
|
|
|
done
|
2013-04-16 08:37:21 +00:00
|
|
|
|
|
2013-09-11 14:47:12 +00:00
|
|
|
|
bench-malloc: $(binaries-bench-malloc)
|
2017-11-28 14:27:46 +00:00
|
|
|
|
for run in $^; do \
|
2019-02-14 16:37:11 +00:00
|
|
|
|
echo "$${run}"; \
|
|
|
|
|
if [ `basename $${run}` = "bench-malloc-thread" ]; then \
|
2017-11-28 14:27:46 +00:00
|
|
|
|
for thr in 1 8 16 32; do \
|
|
|
|
|
echo "Running $${run} $${thr}"; \
|
2019-02-14 16:37:11 +00:00
|
|
|
|
$(run-bench) $${thr} > $${run}-$${thr}.out; \
|
|
|
|
|
done;\
|
|
|
|
|
else \
|
|
|
|
|
for thr in 8 16 32 64 128 256 512 1024 2048 4096; do \
|
|
|
|
|
echo "Running $${run} $${thr}"; \
|
|
|
|
|
$(run-bench) $${thr} > $${run}-$${thr}.out; \
|
|
|
|
|
done;\
|
|
|
|
|
fi;\
|
2013-09-11 14:47:12 +00:00
|
|
|
|
done
|
|
|
|
|
|
2014-03-29 04:07:44 +00:00
|
|
|
|
# Build and execute the benchmark functions. This target generates JSON
|
|
|
|
|
# formatted bench.out. Each of the programs produce independent JSON output,
|
|
|
|
|
# so one could even execute them individually and process it using any JSON
|
|
|
|
|
# capable language or tool.
|
2013-04-16 12:07:24 +00:00
|
|
|
|
bench-func: $(binaries-bench)
|
2017-11-28 14:27:46 +00:00
|
|
|
|
if [ -n '$^' ] ; then \
|
2014-04-08 09:18:16 +00:00
|
|
|
|
{ timing_type=$$($(timing-type)); \
|
2017-11-28 14:27:46 +00:00
|
|
|
|
echo "{\"timing_type\": \"$${timing_type}\","; \
|
|
|
|
|
echo " \"functions\": {"; \
|
|
|
|
|
for run in $^; do \
|
|
|
|
|
if ! [ "x$${run}" = "x$<" ]; then \
|
|
|
|
|
echo ","; \
|
|
|
|
|
fi; \
|
|
|
|
|
echo "Running $${run}" >&2; \
|
|
|
|
|
$(run-bench) $(DETAILED_OPT); \
|
|
|
|
|
done; \
|
|
|
|
|
echo; \
|
|
|
|
|
echo " }"; \
|
|
|
|
|
echo "}"; \
|
|
|
|
|
} > $(objpfx)bench.out-tmp; \
|
|
|
|
|
if [ -f $(objpfx)bench.out ]; then \
|
|
|
|
|
mv -f $(objpfx)bench.out $(objpfx)bench.out.old; \
|
2014-03-29 04:07:44 +00:00
|
|
|
|
fi; \
|
2017-11-28 14:27:46 +00:00
|
|
|
|
mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out; \
|
|
|
|
|
$(PYTHON) scripts/validate_benchout.py $(objpfx)bench.out \
|
|
|
|
|
scripts/benchout.schema.json; \
|
|
|
|
|
fi
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
2019-04-25 08:41:52 +00:00
|
|
|
|
ifeq ($(bind-now),yes)
|
|
|
|
|
link-bench-bind-now = -Wl,-z,now
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
bench-link-targets = $(timing-type) $(binaries-bench) $(binaries-benchset) \
|
|
|
|
|
$(binaries-bench-malloc)
|
|
|
|
|
|
|
|
|
|
$(bench-link-targets): %: %.o $(objpfx)json-lib.o \
|
2016-12-17 19:52:29 +00:00
|
|
|
|
$(link-extra-libs-tests) \
|
2013-04-12 09:31:44 +00:00
|
|
|
|
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
|
|
|
|
|
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
2016-03-08 12:53:24 +00:00
|
|
|
|
$(+link-tests)
|
2013-04-12 09:31:44 +00:00
|
|
|
|
|
2019-04-25 08:41:52 +00:00
|
|
|
|
$(bench-link-targets): LDFLAGS += $(link-bench-bind-now)
|
|
|
|
|
|
2013-04-15 05:47:01 +00:00
|
|
|
|
$(objpfx)bench-%.c: %-inputs $(bench-deps)
|
2013-04-12 09:31:44 +00:00
|
|
|
|
{ if [ -n "$($*-INCLUDE)" ]; then \
|
|
|
|
|
cat $($*-INCLUDE); \
|
|
|
|
|
fi; \
|
2016-01-13 16:00:57 +00:00
|
|
|
|
$(PYTHON) scripts/bench.py $(patsubst %-inputs,%,$<); } > $@-tmp
|
2013-04-12 09:31:44 +00:00
|
|
|
|
mv -f $@-tmp $@
|