Commit Graph

263 Commits

Author SHA1 Message Date
Wilco Dijkstra
a173d09f85 Improve bench-memmem
Improve bench-memmem by replacing simple_memmem with a more efficient
implementation.  Add the Two-way implementation to enable direct comparison
with the optimized memmem.

	* benchtests/bench-memmem.c (simple_memmem): Remove function.
	(basic_memmem): Add function.
	(twoway_memmem): Add function.
2019-04-09 11:46:28 +01:00
Wilco Dijkstra
6103c0a811 Remove TIMING_INIT
Remove TIMING_INIT since it's no longer used.

	* benchtests/bench-malloc-simple.c: Remove TIMING_INIT.
	* benchtests/bench-malloc-thread.c: Likewise.
	* benchtests/bench-skeleton.c: Likewise.
	* benchtests/bench-strtod.c: Likewise.
	* benchtests/bench-timing.h: Likewise.
2019-04-09 11:38:24 +01:00
Wilco Dijkstra
7621e38bf3 Add generic hp-timing support
Add missing generic hp_timing support.  It uses clock_gettime (CLOCK_MONOTONIC)
which has unspecified starting time, nano-second accuracy, and should faster on
architectures that implementes the symbol as vDSO.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked the builds for all afected ABIs.

	* benchtests/Makefile (USE_CLOCK_GETTIME) Remove.
	* benchtests/README: Update description.
	* benchtests/bench-timing.h: Default to hp-timing.
	* sysdeps/generic/hp-timing.h (HP_TIMING_DIFF, HP_TIMING_ACCUM_NT,
	HP_TIMING_PRINT): Remove.
	(HP_TIMING_NOW): Add generic implementation.
	(hp_timing_t): Change to uint64_t.
2019-03-22 17:30:44 -03:00
Adhemerval Zanella
1e372ded4f Refactor hp-timing rtld usage
This patch refactor how hp-timing is used on loader code for statistics
report.  The HP_TIMING_AVAIL and HP_SMALL_TIMING_AVAIL are removed and
HP_TIMING_INLINE is used instead to check for hp-timing avaliability.
For alpha, which only defines HP_SMALL_TIMING_AVAIL, the HP_TIMING_INLINE
is set iff for IS_IN(rtld).

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked the builds for all afected ABIs.

	* benchtests/bench-timing.h: Replace HP_TIMING_AVAIL with
	HP_TIMING_INLINE.
	* nptl/descr.h: Likewise.
	* elf/rtld.c (RLTD_TIMING_DECLARE, RTLD_TIMING_NOW, RTLD_TIMING_DIFF,
	RTLD_TIMING_ACCUM_NT, RTLD_TIMING_SET): Define.
	(dl_start_final_info, _dl_start_final, dl_main, print_statistics):
	Abstract hp-timing usage with RTLD_* macros.
	* sysdeps/alpha/hp-timing.h (HP_TIMING_INLINE): Define iff IS_IN(rtld).
	(HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Remove.
	* sysdeps/generic/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL,
	HP_TIMING_NONAVAIL): Likewise.
	* sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL):
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/hp-timing.h (HP_TIMING_AVAIL,
	HP_SMALL_TIMING_AVAIL): Likewise.
	* sysdeps/powerpc/powerpc64/hp-timing.h (HP_TIMING_AVAIL,
	HP_SMALL_TIMING_AVAIL): Likewise.
	* sysdeps/sparc/sparc32/sparcv9/hp-timing.h (HP_TIMING_AVAIL,
	HP_SMALL_TIMING_AVAIL): Likewise.
	* sysdeps/sparc/sparc64/hp-timing.h (HP_TIMING_AVAIL,
	HP_SMALL_TIMING_AVAIL): Likewise.
	* sysdeps/x86/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL):
	Likewise.
	* sysdeps/generic/hp-timing-common.h: Update comment with
	HP_TIMING_AVAIL removal.
2019-03-22 17:30:44 -03:00
Joseph Myers
c4f50205e1 Add some spaces before '('.
This patch fixes various places where a space should have been present
before '(' in accordance with the GNU Coding Standards.  Most but not
all of the fixes in this patch are for calls to sizeof (but it's not
exhaustive regarding such calls that should be fixed).

Tested for x86_64, and with build-many-glibcs.py.

	* benchtests/bench-strcpy.c (do_test): Use space before '('.
	* benchtests/bench-string.h (cmdline_process_function): Likewise.
	* benchtests/bench-strlen.c (do_test): Likewise.
	(test_main): Likewise.
	* catgets/gencat.c (read_old): Likewise.
	* elf/cache.c (load_aux_cache): Likewise.
	* iconvdata/bug-iconv8.c (do_test): Likewise.
	* math/test-tgmath-ret.c (do_test): Likewise.
	* nis/nis_call.c (rec_dirsearch): Likewise.
	* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
	* nptl/tst-audit-threads.c (do_test): Likewise.
	* nptl/tst-cancel4-common.h (set_socket_buffer): Likewise.
	* nss/nss_test1.c (init): Likewise.
	* nss/test-netdb.c (test_hosts): Likewise.
	* posix/execvpe.c (maybe_script_execute): Likewise.
	* stdio-common/tst-fmemopen4.c (do_test): Likewise.
	* stdio-common/tst-printf.c (do_test): Likewise.
	* stdio-common/vfscanf-internal.c (__vfscanf_internal): Likewise.
	* stdlib/fmtmsg.c (NKEYWORDS): Likewise.
	* stdlib/qsort.c (STACK_SIZE): Likewise.
	* stdlib/test-canon.c (do_test): Likewise.
	* stdlib/tst-swapcontext1.c (do_test): Likewise.
	* string/memcmp.c (OPSIZ): Likewise.
	* string/test-strcpy.c (do_test): Likewise.
	(do_random_tests): Likewise.
	* string/test-strlen.c (do_test): Likewise.
	(test_main): Likewise.
	* string/test-strrchr.c (do_test): Likewise.
	(do_random_tests): Likewise.
	* string/tester.c (test_memrchr): Likewise.
	(test_memchr): Likewise.
	* sysdeps/generic/memcopy.h (OPSIZ): Likewise.
	* sysdeps/generic/unwind-dw2.c (execute_stack_op): Likewise.
	* sysdeps/generic/unwind-pe.h (read_sleb128): Likewise.
	(read_encoded_value_with_base): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_runtime_setup): Likewise.
	* sysdeps/hppa/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/ia64/fpu/sfp-machine.h (TI_BITS): Likewise.
	* sysdeps/mach/hurd/spawni.c (__spawni): Likewise.
	* sysdeps/posix/spawni.c (maybe_script_execute): Likewise.
	* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (query_auxv):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs.h (ELF_NGREG): Likewise.
	* sysdeps/unix/sysv/linux/arm/ioperm.c (init_iosys): Likewise.
	* sysdeps/unix/sysv/linux/csky/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h (ELF_NGREG):
	Likewise.
	* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs.h (ELF_NGREG): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sigcontext.h
	(FP_XSTATE_MAGIC2_SIZE): Likewise.
	* sysdeps/x86/fpu/sfp-machine.h (TI_BITS): Likewise.
	* time/test_time.c (main): Likewise.
2019-02-27 13:55:45 +00:00
Joseph Myers
34a5a1460e Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one.  This patch fixes various
code to do this.  It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting.  It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups).  Some files changed are shared with
gnulib, but most are specific to glibc.  Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).

This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).

Tested for x86_64, and with build-many-glibcs.py.

	* benchtests/bench-memmem.c (simple_memmem): Break lines before
	rather than after operators.
	* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
	* crypt/md5.c (md5_finish_ctx): Likewise.
	* crypt/sha256.c (__sha256_finish_ctx): Likewise.
	* crypt/sha512.c (__sha512_finish_ctx): Likewise.
	* elf/cache.c (load_aux_cache): Likewise.
	* elf/dl-load.c (open_verify): Likewise.
	* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
	* elf/readelflib.c (process_elf_file): Likewise.
	* elf/rtld.c (dl_main): Likewise.
	* elf/sprof.c (generate_call_graph): Likewise.
	* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
	* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
	* hurd/dtable.c (reauth_dtable): Likewise.
	* hurd/getdport.c (__getdport): Likewise.
	* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
	* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
	* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
	Likewise.
	* hurd/hurdioctl.c (fioctl): Likewise.
	* hurd/hurdselect.c (_hurd_select): Likewise.
	* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
	(STOPSIGS): Likewise.
	* hurd/hurdstartup.c (_hurd_startup): Likewise.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
	* hurd/msgportdemux.c (msgport_server): Likewise.
	* hurd/setauth.c (_hurd_setauth): Likewise.
	* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
	* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
	* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
	* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
	* login/tst-utmp.c (do_check): Likewise.
	(simulate_login): Likewise.
	* mach/lowlevellock.h (lll_lock): Likewise.
	(lll_trylock): Likewise.
	* math/test-fenv.c (ALL_EXC): Likewise.
	* math/test-fenvinline.c (ALL_EXC): Likewise.
	* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
	* nis/nis_call.c (__do_niscall3): Likewise.
	* nis/nis_callback.c (cb_prog_1): Likewise.
	* nis/nis_defaults.c (searchaccess): Likewise.
	* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
	* nis/nis_ismember.c (internal_ismember): Likewise.
	* nis/nis_local_names.c (nis_local_principal): Likewise.
	* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
	Likewise.
	* nis/ypclnt.c (yp_match): Likewise.
	(yp_first): Likewise.
	(yp_next): Likewise.
	(yp_master): Likewise.
	(yp_order): Likewise.
	* nscd/hstcache.c (cache_addhst): Likewise.
	* nscd/initgrcache.c (addinitgroupsX): Likewise.
	* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
	(internal_getpwuid_r): Likewise.
	* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
	* posix/glob.h (__GLOB_FLAGS): Likewise.
	* posix/regcomp.c (peek_token): Likewise.
	(peek_token_bracket): Likewise.
	(parse_expression): Likewise.
	* posix/regexec.c (sift_states_iter_mb): Likewise.
	(check_node_accept_bytes): Likewise.
	* posix/tst-spawn3.c (do_test): Likewise.
	* posix/wordexp-test.c (testit): Likewise.
	* posix/wordexp.c (parse_tilde): Likewise.
	(exec_comm): Likewise.
	* posix/wordexp.h (__WRDE_FLAGS): Likewise.
	* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
	* setjmp/sigjmp.c (__sigjmp_save): Likewise.
	* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
	* stdio-common/tst-fileno.c (do_test): Likewise.
	* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
	* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
	* stdlib/strtod_l.c (round_and_return): Likewise.
	(____STRTOF_INTERNAL): Likewise.
	* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
	* string/strcspn.c (STRCSPN): Likewise.
	* string/test-memmem.c (simple_memmem): Likewise.
	* termios/tcsetattr.c (tcsetattr): Likewise.
	* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
	* time/asctime.c (asctime_internal): Likewise.
	* time/strptime_l.c (__strptime_internal): Likewise.
	* time/sys/time.h (timercmp): Likewise.
	* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
Wilco Dijkstra
20d0195c71 Add missing bench-malloc-simple.c file. 2019-02-14 17:10:47 +00:00
Wilco Dijkstra
3904fd85d3 Add malloc micro benchmark
Add a malloc micro benchmark to enable accurate testing of the
various paths in malloc and free.  The benchmark does a varying
number of allocations of a given block size, then frees them again.

It tests 3 different scenarios: single-threaded using main arena,
multi-threaded using thread-arena, main arena with SINGLE_THREAD_P
false.

	* benchtests/Makefile: Add malloc-simple benchmark.
	* benchtests/bench-malloc-simple.c: New benchmark.
2019-02-14 16:37:11 +00:00
Siddhesh Poyarekar
24ca04febe benchtests: Remove useless ORIG_SRC in memmove benchmarks
The ORIG_SRC argument is likely a useless relic from the original
correctness tests that are not needed in the benchmarks.  Remove the
argument and use S1 to point to the source to avoid confusion.

        * benchtests/bench-memmove.c (do_one_test): Remove unused
        ORIG_SRC.
        (do_test): Adjust.
        * benchtests/bench-memmove-large.c (do_one_test): Remove unused
        ORIG_SRC.
        (do_test): Adjust.
2019-02-14 08:22:34 +05:30
Wilco Dijkstra
16f87cfd63 String benchtest cleanup
Continue cleanup of the string benchtests.  Remove simplistic
byte-oriented versions with faster generic implementations.
Remove bcopy/bzero benchmarks (bcopy/bzero are obsolete and never
emitted by compilers).  Remove builtin versions of memcpy, memset
and strlen.  Remove all remaining "stupid" implementations given
they are always slower than the "simple" variants and thus don't
add anything useful.

	* benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove.
	* benchtests/bench-strcasestr.c (stupid_strcasestr): Remove.
	* benchtests/bench-strchr.c (stupid_strchr): Remove.
	* benchtests/bench-strcmp.c (stupid_strcmp): Remove.
	* benchtests/bench-strcspn.c (stupid_strcspn): Remove.
	* benchtests/bench-strlen.c (builtin_strlen): Remove.
	* benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove.
	* benchtests/bench-strncmp.c (stupid_strncmp): Remove.
	* benchtests/bench-strpbrk.c (stupid_strpbrk): Remove.
	* benchtests/bench-strspn.c (stupid_strspn): Remove.
	* benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c.
	* benchtests/bench-bcopy.c: Delete file.
	* benchtests/bench-bzero.c: Likewise.
	* benchtests/bench-memccpy.c (stupid_memccpy): Remove.
	(simple_memccpy): Remove.
	(generic_memccpy): Add function.
	* benchtests/bench-memcpy.c: (builtin_memcpy): Remove.
	* benchtests/bench-memmove.c (simple_bcopy): Remove.
	* benchtests/bench-mempcpy.c (simple_mempcpy): Remove.
	(generic_mempcpy): Add new function.
	* benchtests/bench-memset.c (simple_bzero): Remove.
	(builtin_bzero): Remove.
	(builtin_memset): Remove.
	* benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove.
	(generic_rawmemchr): Add new function.
2019-02-12 17:19:51 +00:00
Joseph Myers
04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Wilco Dijkstra
5289f1f56b Improve bench-strlen
The current bench-strlen compares against a slow byte-oriented strlen which
is not useful given it's too easy to beat.  Remove it and compare against the
generic C strlen version and memchr.

	* benchtests/bench-strlen.c (generic_strlen): New function.
	(memchr_strlen): New function.
2018-12-27 14:56:23 +00:00
Wilco Dijkstra
90d3320d7f Refactor string benchtests
Refactor string benchtests by moving duplicated defines into
bench-string.h.

	* benchtests/bench-memchr.c: Cleanup defines.
	* benchtests/bench-memcmp.c: Likewise.
	* benchtests/bench-memset.c: Likewise.
	* benchtests/bench-memset-large.c: Likewise.
	* benchtests/bench-memset-walk.c: Likewise.
	* benchtests/bench-stpcpy.c: Likewise.
	* benchtests/bench-stpncpy.c: Likewise.
	* benchtests/bench-strcat.c: Likewise.
	* benchtests/bench-strchr.c: Likewise.
	* benchtests/bench-strcmp.c: Likewise.
	* benchtests/bench-strcpy.c: Likewise.
	* benchtests/bench-strcspn.c: Likewise.
	* benchtests/bench-string.h: Likewise.
	* benchtests/bench-strlen.c: Likewise.
	* benchtests/bench-strncat.c: Likewise.
	* benchtests/bench-strncmp.c: Likewise.
	* benchtests/bench-strncpy.c: Likewise.
	* benchtests/bench-strnlen.c: Likewise.
	* benchtests/bench-strpbrk.c: Likewise.
	* benchtests/bench-strrchr.c: Likewise.
	* benchtests/bench-strspn.c: Likewise.
2018-12-21 18:52:40 +00:00
Leonardo Sandoval
de099757b6 benchtests: send non-consumable data to stderr
Non-consumable data, alias data not related to benchmarks, should be sent to
the standard error, thus pipelines can work as expected.

	* benchtests/scripts/compare_bench.py (do_compare): write to stderr in case
    stat is not present.
	* benchtests/scripts/compare_bench.py (plot_graphs): write to stderr in case
    timings field is not present. Also string showing the output filename goes
    into the stderr.
2018-12-12 11:05:22 -06:00
Leonardo Sandoval
1990185f5f benchtests: include --stats parameter
Allows user to pick a statistic, defaulting to min and mean, from command
line. At the same time, if stat does not exit, catch the run-time exception
and keep comparing the rest of benchmarked functions. Finally, take care of
division-by-zero exceptions and as the latter, keep comparing the rest of the
functions, turning the script a bit more fault tolerant thus useful.

	* benchtests/scripts/compare_bench.py (do_compare): Catch KeyError and
    ZeroDivisorError exceptions.
	* benchtests/scripts/compare_bench.py (compare_runs): Use stats argument to
    loop through user provided statistics.
	* benchtests/scripts/compare_bench.py (main): Include the --stats argument.
2018-12-12 11:05:22 -06:00
Leonardo Sandoval
587426d499 benchtests: keep comparing even if function timings do not match
Allows other functions to be processed, making the script a bit more fault
tolerant thus useful.

	* benchtests/scripts/compare_bench.py (compare_runs): Continue instead of return.
2018-12-12 11:05:22 -06:00
Joseph Myers
c6982f7efc Patch to require Python 3.4 or later to build glibc.
This patch makes Python 3.4 or later a required tool for building
glibc, so allowing changes of awk, perl etc. code used in the build
and test to Python code without any such changes needing makefile
conditionals or to handle older Python versions.

This patch makes the configure test for Python check the version and
give an error if Python is missing or too old, and removes makefile
conditionals that are no longer needed.  It does not itself convert
any code from another language to Python, and does not remove any
compatibility with older Python versions from existing scripts.

Tested for x86_64.

	* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER.  Set
	critic_missing for versions before 3.4.
	* configure: Regenerated.
	* manual/install.texi (Tools for Compilation): Document
	requirement for Python to build glibc.
	* INSTALL: Regenerated.
	* Rules [PYTHON]: Make code unconditional.
	* benchtests/Makefile [PYTHON]: Likewise.
	* conform/Makefile [PYTHON]: Likewise.
	* manual/Makefile [PYTHON]: Likewise.
	* math/Makefile [PYTHON]: Likewise.
2018-10-29 15:28:05 +00:00
H.J. Lu
7cc65773f0 x86: Support RDTSCP for benchtests
RDTSCP waits until all previous instructions have executed and all
previous loads are globally visible before reading the counter.  RDTSC
doesn't wait until all previous instructions have been executed before
reading the counter.  All x86 processors since 2010 support RDTSCP
instruction.  This patch adds RDTSCP support to benchtests.

	* benchtests/Makefile (CPPFLAGS-nonlib): Add -DUSE_RDTSCP if
	USE_RDTSCP is defined.
	* sysdeps/x86/hp-timing.h (HP_TIMING_NOW): Use RDTSCP if
	USE_RDTSCP is defined.
2018-10-24 02:19:34 -07:00
Andreas Schwab
ce5a7de6cd Don't reduce test timeout to less than default
This removes all overrides of TIMEOUT that are less than or equal to the
default timeout.
2018-10-17 09:34:13 +02:00
Leonardo Sandoval
c892ae04f4 benchtests: Set float type on --threshold argument
Otherwise, we see the following runtime error when using the parameter:

  File "./glibc/benchtests/scripts/compare_bench.py", line 46, in do_compare
    if d > threshold:
TypeError: '>' not supported between instances of 'float' and 'str'

	* benchtests/scripts/compare_bench.py (main): set float type on
	threshold argument.
2018-10-08 09:11:30 -05:00
Siddhesh Poyarekar
34f86d6168 Reallocate buffers for every run in strlen
Try and avoid influencing performance of neighbouring functions.
2018-08-16 14:11:57 +05:30
Siddhesh Poyarekar
953a5a4a59 Print strlen benchmark output in json
Allow reading the benchmark using the compare_strings.py script.
2018-08-16 14:11:56 +05:30
Siddhesh Poyarekar
8cac1f2635 [benchtests] Add workload test properties to schema
Add the workload test properties (max-throughput, latency, etc.) to
the schema to prevent benchmark output validation from failing.

	* benchtests/scripts/benchout.schema.json (properties): Add
	new properties.
2018-08-11 18:55:09 +05:30
Siddhesh Poyarekar
44727aec4f [benchtests] Add mandatory attributes to workload tests
Add the duration and iterations attributes to the workloads tests to
make the json schema parser happy

	* benchtests/bench-skeleton.c (main): Add duration and
	iterations attributes.
2018-08-11 18:55:07 +05:30
Siddhesh Poyarekar
014efdd7ea benchtests: Clean up the alloc_bufs
Drop realloc_bufs in favour of making alloc_bufs transparently
reallocate the buffers if it had allocated before.  Also consolidate
computation of buffer lengths so that they don't get repeated on every
reallocation.

	* benchtests/bench-string.h (buf1_size, buf2_size): New
	variables.
	(init_sizes): New function.
	(test_init): Use it.
	(alloc_buf, exit_error): New functions.
	(alloc_bufs): Use ALLOC_BUF.
	(realloc_bufs): Remove.
	* benchtests/bench-memcmp.c (do_test): Adjust.
	* benchtests/bench-memset-large.c (do_test): Likewise.
	* benchtests/bench-memset-walk.c (do_test): Likewise.
	* benchtests/bench-memset.c (do_test): Likewise.
	* benchtests/bench-strncmp.c (do_test): Likewise.
2018-08-08 00:44:56 +05:30
Siddhesh Poyarekar
d67d634bef [benchtests] Fix compare_strings.py for python2
Python 2 does not have a FileNotFoundError so drop it in favour of
simply printing out the last (and most informative) line of the
exception.

	* benchtests/scripts/compare_strings.py: Import traceback.
	(parse_file): Pretty-print error.
2018-08-03 00:26:45 +05:30
Leonardo Sandoval
1cf4ae7fe6 benchtests: improve argument parsing through argparse library
The argparse library is used on compare_bench script to improve command line
argument parsing. The 'schema validation file' is now optional, reducing by
one the number of required parameters.

	* benchtests/scripts/compare_bench.py (__main__): use the argparse
	library to improve command line parsing.
	(__main__): make schema file as optional parameter (--schema),
	defaulting to benchtests/scripts/benchout.schema.json.
	(main): move out of the parsing stuff to __main_  and leave it
	only as caller of main comparison functions.
2018-07-19 14:53:37 -05:00
Wilco Dijkstra
3ae725dfb6 Improve strstr performance
Improve strstr performance.  Strstr tends to be slow because it uses
many calls to memchr and a slow byte loop to scan for the next match.
Performance is significantly improved by using strnlen on larger blocks
and using strchr to search for the next matching character.  strcasestr
can also use strnlen to scan ahead, and memmem can use memchr to check
for the next match.

On the GLIBC bench tests the performance gains on Cortex-A72 are:
strstr: +25%
strcasestr: +4.3%
memmem: +18%

On a 256KB dataset strstr performance improves by 67%, strcasestr by 47%.

    Reviewd-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-07-16 17:51:52 +01:00
H.J. Lu
cb8f6affed benchtests: Add -f/--functions argument
On x86-64, there may be multiple IFUNC implementations for a given
function.  But we may be only interested in a subset of them.  This
patch adds -f/--functions argument to compare a subset of IFUNC
implementations.

	* benchtests/scripts/compare_strings.py (process_results): Add
	funcs argument.  Compare only functions which are selected.
	(main): Check if base function is among selected functions.
	Pass selected functions to process_results.
	(__main__): Add -f/--functions argument.
2018-06-12 09:10:42 -07:00
Leonardo Sandoval
a650b05ebe benchtests: Catch exceptions in input arguments
Catch runtime exceptions in case the user provided: wrong base
function, attribute(s) or input file. In any of the latter, quit
immediately with non-zero return code.

	* benchtests/scripts/compare_string.py: (process_results) Catch
	exception in non-existent base_func and catch exception in
	non-existent attribute.
	(parse_file) Catch exception in non-existent input file.
2018-06-01 16:32:43 -05:00
Leonardo Sandoval
195abbf4cd benchtests: Add --no-diff and --no-header options
Having a string comparison report with neither diff numbers nor header
yields a more useful output to be consumed by other tools.

	* benchtests/scripts/compare_string.py: Add --no-diff and --no-header
	options to avoid diff calculation and omit header, respectively.
	(main): process --no-diff and --no-header
2018-06-01 16:32:43 -05:00
Siddhesh Poyarekar
543477f78b benchtests: Move iterator declaration into loop header
This is a minor style change to move the definition of I to its usage
scope instead of at the top of the function.  This is consistent with
glibc style guidelines and more importantly it was getting in the way
of my testing.

	* benchtests/bench-memcpy-walk.c (do_test): Move declaration
	of I into loop header.
	* benchtests/bench-memmove-walk.c (do_test): Likewise.
2018-05-07 20:54:31 +05:30
Wilco Dijkstra
fbce6f7260 Undefine attribute_hidden to fix benchtests
Add an undefine of attribute_hidden since it may be defined in some cases
(it must be defined since it is used by some hp-timing configurations).

	* benchtests/bench-timing.h (attribute_hidden): Undefine.
2018-03-19 10:53:14 +00:00
Wilco Dijkstra
f1c8185d34 Use correct includes in benchtests
Currently the benchtests are run with internal GLIBC headers, which is incorrect.
Defining _ISOMAC in the makefile ensures the internal headers are bypassed.
Fix all tests which were relying on internal defines or includes.

	* benchtests/Makefile: Define _ISOMAC.
	* benchtests/bench-strcoll.c: Add missing sys/stat.h include.
	* benchtests/bench-string.h: Define inhibit_loop_to_libcall macro.
	* benchtests/bench-strstr.c: Define empty libc_hidden_builtin_def.
	* benchtests/bench-strtok.c (oldstrtok): Use rawmemchr.
	* benchtests/bench-timing.h: Define attribute_hidden.
2018-03-15 15:44:58 +00:00
Siddhesh Poyarekar
0963ea8e8c benchtests: Don't benchmark 0 length calls for strncmp
The 0 length strncmp is interesting for correctness but not for
performance.

	* benchtests/bench-strncmp.c (test_main): Remove 0 length tests.
	(do_test_limit): Likewise.
2018-03-06 18:29:57 +05:30
Siddhesh Poyarekar
7bb3a8a556 benchtests: Reallocate buffers for every strncmp implementation
Don't reuse buffers for different strncmp implementations since the
earlier implementation will end up warming the cache for the later
one.  Eventually there should be a more elegant way to do this.

	* benchtests/bench-strncmp.c (do_test_limit): Reallocate buffers
	for every implementation.
	(do_test): Likewise.
2018-03-06 18:29:52 +05:30
Siddhesh Poyarekar
ad4e816e06 benchtests: Convert strncmp benchmark output to json
Make the output usable through the compare_strings.py script.

	* benchtests/bench-strncmp.c: Convert output to json.
2018-03-06 18:29:34 +05:30
Wilco Dijkstra
c3d466cba1 Remove slow paths from pow
Remove the slow paths from pow.  Like several other double precision math
functions, pow is exactly rounded.  This is not required from math functions
and causes major overheads as it requires multiple fallbacks using higher
precision arithmetic if a result is close to 0.5ULP.  Ridiculous slowdowns
of up to 100000x have been reported when the highest precision path triggers.

All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1).
The worst case error is ~0.506ULP.  A simple test over a few hundred million
values shows pow is 10% faster on average.  This fixes BZ #13932.

	[BZ #13932]
	* sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove.
	* benchtests/pow-inputs: Update comment for slow path cases.
	* manual/probes.texi (slowpow_p10): Delete removed probe.
	(slowpow_p10): Likewise.
	* math/Makefile: Remove halfulp.c and slowpow.c.
	* sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/generic/math_private.h (__exp1): Remove error argument.
	(__halfulp): Remove.
	(__slowpow): Remove.
	* sysdeps/i386/fpu/halfulp.c: Delete file.
	* sysdeps/i386/fpu/slowpow.c: Likewise.
	* sysdeps/ia64/fpu/halfulp.c: Likewise.
	* sysdeps/ia64/fpu/slowpow.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument,
	improve comments and add error analysis.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis.
	(power1): Remove function:
	(log1): Remove error argument, add error analysis.
	(my_log2): Remove function.
	* sysdeps/ieee754/dbl-64/halfulp.c: Delete file.
	* sysdeps/ieee754/dbl-64/slowpow.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise.
	* sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c.
	* sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1.
	* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c,
	slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file.
	* sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
2018-02-12 10:47:09 +00:00
Siddhesh Poyarekar
96e6a7167e benchtests: Make bench-memcmp print json
The benchamrk result can now be studied using the compare_strings.py
script.

	* benchtests/bench-memcmp.c: Print json instead of plain text.
2018-02-02 09:56:47 +05:30
Siddhesh Poyarekar
3dfcbfa1a4 benchtests: Reallocate buffers for every test run
Keeping the buffers the same across test runs gives later invocations
the advantage since they access cached data.  Reallocate so that all
test runs are on equal grounds.

	* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
	every test run.
2018-02-02 09:55:45 +05:30
Joseph Myers
688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Siddhesh Poyarekar
5f1603c331 Convert strcmp benchmark output to json format
The format is now parseable with the compare_strings.py script.
2017-12-15 02:31:41 +05:30
Victor Rodriguez
0422ed1e84 benchtests: Enable BENCHSET to run subset of tests
This patch adds BENCHSET variable to benchtests/Makefile in order to
provide the capability to run a list of subsets of benchmark tests, ie;

    make bench BENCHSET="bench-pthread bench-math malloc-thread"

This helps users to benchmark specific glibc area

ChangeLog:

        * benchtests/Makefile:Add BENCHSET to allow subsets of
        benchmarks to be run.
        * benchtests/README: Add documentation for: Running subsets of
        benchmarks.

Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Reviewed-By: Siddhesh Poyarekar <siddhesh@sourceware.org>
2017-11-28 19:57:46 +05:30
Victor Rodriguez
d5090db30e benchtests: Expand range of tests names in schema.json
When executing bench-math the benchmark output is invalid with this
error msg:

    Invalid benchmark output: 'workload-spec2006.wrf' does not match any of
    the regexes: '^[_a-zA-Z0-9]*$¹ or Invalid benchmark output: Additional
    properties are not allowed ('workload-spec2006.wrf' was unexpected)

The error was seen when running the test:
workload-spec2006.wrf, 'stack=1024,guard=1' and 'stack=1024,guard=2'.
The problem is that the current regex's do not accept the hyphen, dot, equal
and comma in the output.

This patch changes the regex in benchout.schema.json to accept symbols in
benchmark tests names.

ChangeLog:

        * benchtests/scripts/benchout.schema.json: Fix regex to accept a
        wider range of tests names.

Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
Reviewed-By: Siddhesh Poyarekar <siddhesh@sourceware.org>
2017-11-28 19:52:57 +05:30
Victor Rodriguez
0595e36034 benchtests: Adjust valid and accepted properties
Benchmark workload-spec2006.wrf does not produce max, min or mean
results but instead produce throughput. This is represented in
benchtests/bench-skeleton.c. This patch adjust benchout.schema.json to consider
bench.out from bench-math benchmarks as valid

ChangeLog:

	* benchtests/scripts/benchout.schema.json: Add throughput as accepted
	result from property and remove "max", min" and "mean" from required
	properties based on benchtests/bench-skeleton.c.

Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
Reviewed-By: Siddhesh Poyarekar <siddhesh@sourceware.org>
2017-11-28 19:49:59 +05:30
Siddhesh Poyarekar
eb332f9feb benchtests: Bump start size since smaller sizes are noisy
Numbers for very small sizes (< 128B) are much noisier for non-cached
benchmarks like the walk benchmarks, so don't include them.

	* benchtests/bench-memcpy-walk.c (START_SIZE): Set to 128.
	* benchtests/bench-memmove-walk.c (START_SIZE): Likewise.
	* benchtests/bench-memset-walk.c (START_SIZE): Likewise.
2017-11-20 18:03:32 +05:30
Siddhesh Poyarekar
4d7632ff68 benchtests: Fix walking sizes and directions for *-walk benchmarks
Make the walking benchmarks walk only backwards since copying both
ways is biased in favour of implementations that use non-temporal
stores for larger sizes; falkor is one of them.  This also fixes up
bugs in computation of the result which ended up multiplying the
length with the timing result unnecessarily.

	* benchtests/bench-memcpy-walk.c (do_one_test): Copy only
	backwards.  Fix timing computation.
	* benchtests/bench-memmove-walk.c (do_one_test): Likewise.
	* benchtests/bench-memset-walk.c (do_one_test): Walk backwards
	on memset by N at a time.  Fix timing computation.
2017-11-20 18:03:32 +05:30
Rajalakshmi Srinivasaraghavan
077ee12978 Benchtests for sinf, cosf and sincosf
Numbers used from cos and sin inputs.
2017-10-13 14:19:45 +05:30
Siddhesh Poyarekar
5bfb04042d benchtests: Memory walking benchmark for memmove
This benchmark is an attempt to eliminate cache effects from string
benchmarks.  The benchmark walks both ways through a large memory area
and copies different sizes of memory and alignments one at a time
instead of looping around in the same memory area.  This is a good
metric to have alongside the simple memmove benchmark (which is only
really useful for smaller sizes) especially for larger sizes where the
likelihood of the call being done only once is pretty high.

This benchmark is different from memcpy in that it also tests
overlapping copies.

	* benchtests/bench-memmove-walk.c: New file.
	* benchtests/Makefile (string-benchset): Add it.
2017-10-05 22:20:23 +05:30
Siddhesh Poyarekar
36bb8edf51 benchtests: Memory walking benchmark for memset
This benchmark is an attempt to eliminate cache effects from string
benchmarks.  The benchmark walks backward through a large memory area
and sets different sizes of memory and alignments one at a time
instead of looping around in the same memory area.  This is a good
metric to have alongside the simple memset benchmark (which is only
really useful for smaller sizes) especially for larger sizes where the
likelihood of the call being done only once is pretty high.

	* benchtests/bench-memset-walk.c: New file.
	* benchtests/Makefile (string-benchset): Add it.
2017-10-05 22:20:23 +05:30
Siddhesh Poyarekar
9ec87fd2b1 benchtests: Memory walking benchmark for memcpy
This benchmark is an attempt to eliminate cache effects from string
benchmarks.  The benchmark walks both ways through a large memory area
and copies different sizes of memory and alignments one at a time
instead of looping around in the same memory area.  This is a good
metric to have alongside the other memcpy benchmarks, especially for
larger sizes where the likelihood of the call being done only once is
pretty high.

	* benchtests/bench-memcpy-walk.c: New file.
	* benchtests/Makefile (string-benchset): Add it.
2017-10-05 22:20:23 +05:30
Szabolcs Nagy
0525ce4850 Add exp2f and log2f benchmark trace
exp2f and log2f benchmark traces are just copies of the existing
expf and logf traces from wrf_r.

	* benchtests/Makefile: Add exp2f and log2f benchmarks.
	* benchtests/exp2f-inputs: Copy of expf-inputs.
	* benchtests/log2f-inputs: Copy of logf-inputs.
2017-09-20 10:04:12 +01:00
Wilco Dijkstra
a5dcc87e77 Add logf trace
Add a trace for logf.  This is a reduced trace based on 2.8 billion
samples extracted from wrf_r.

	* benchtests/Makefile: Add logf benchmark.
	* benchtests/logf-inputs: Add reduced trace from wrf_r.
2017-09-19 15:14:46 +01:00
Wilco Dijkstra
7024d5446d Add expf trace
Add a trace for expf.  This is a reduced trace based on 2.4 billion
samples extracted from wrf_r.

	* benchtests/Makefile: Add expf benchmark.
	* benchtests/expf-inputs: Add reduced trace from wrf_r.
2017-09-19 15:14:18 +01:00
Joseph Myers
eb375def3d Add benchtests for trunc and truncf.
This patch adds benchtests for the trunc and truncf functions.  The
inputs listed are fairly arbitrary; I do not assert they are
representative of any particular application.

	* benchtests/Makefile (bench-math): Add trunc and truncf.
	(CFLAGS-bench-trunc.c): New variable.
	(CFLAGS-bench-truncf.c): Likewise.
	* benchtests/trunc-inputs: New file.
	* benchtests/truncf-inputs: Likewise.
2017-09-19 12:59:01 +00:00
Siddhesh Poyarekar
140647ea6f benchtests: New -g option to generate graphs in compare_strings.py
The compare_strings.py option unconditionally generates a graph PNG
image of the input data, which can be unnecessary and slow.  Put this
behind an optional flag -g.

	* benchtests/scripts/compare_strings.py: New option -g.
	(draw_graph): Print a message that a graph is being generated.
	(process_results): Generate graph only if -g is passed.
	(main): Process option -g.
2017-09-16 15:24:00 +05:30
Siddhesh Poyarekar
5a6547b7b9 benchtests: Make compare_strings.py output a bit prettier
Make the column widths for the outputs fixed so that they look a
little less messy.  They will still look bad with lots of IFUNCs (like
on x86) but it's still a step forward.

	* benchtests/scripts/compare_strings.py (process_results):
	Better spacing for output.
2017-09-16 15:23:12 +05:30
Siddhesh Poyarekar
06b1de2378 benchtests: Use argparse to parse arguments
Make the script more usable by adding proper command line options
along with a way to query the options.  The script is capable of doing
a bunch of things right now like choosing a base for comparison,
choosing to generate graphs, etc. and they should be accessible via
command line switches.

	* benchtests/scripts/compare_strings.py: Use argparse.
	* benchtests/README: Document existence of compare_strings.py.
2017-09-16 11:47:32 +05:30
Siddhesh Poyarekar
503c92c37a benchtests: Reallocate buffers for memset
Keeping the same buffers along with copying the same size of data into
the same location means that the first routine is typically the
slowest since it has to bear the cost of fetching data into to cache.
Reallocating buffers stabilizes numbers by a bit.

	* benchtests/bench-string.h (realloc_bufs): New function.
	(test_init): Call it.
	* benchtests/bench-memset-large.c (do_test): Likewise.
	* benchtests/bench-memset.c (do_test): Likewise.
2017-09-14 22:54:24 +05:30
Siddhesh Poyarekar
29c933fb35 benchtests: Make memset benchmarks print json
Make the memset benchmarks (bench-memset and bench-memset-large) print
their output in JSON so that they can be evaluated using the
compare_strings.py script.

	* benchtests/bench-memset-large.c: Print output in JSON
	format.
	* benchtests/bench-memset.c: Likewise.
2017-09-14 22:54:23 +05:30
Mike FABIAN
799c8d6905 Add new codepage charmaps/IBM858 [BZ #21084]
This code page is identical to code page 850 except that X'D5'
has been changed from LI61 (dotless i) to SC20 (euro symbol).

The code points from /x01 to /x1f in the /localedata/charmaps/IBM858
file have the same mapping as those in localedata/charmaps/ANSI_X3.4-1968.
That means they disagree with with

ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00858.txt

in that range.
For example, localedata/charmaps/IBM858 and localedata/charmaps/ANSI_X3.4-1968 have:

   “<U0001>     /x01         START OF HEADING (SOH)”

whereas CP00858.txt has:

   “01 SS000000        Smiling Face”

That means that CP00858.txt is not really ASCII-compatible and to make
it ASCII-compatible we deviate fro CP00858.txt in the code points from /x01
to /x1f.

	[BZ #21084]
	* benchtests/strcoll-inputs/filelist#en_US.UTF-8: Add IBM858 and ibm858.c.
	* iconvdata/Makefile: Add IBM858.
	* iconvdata/gconv-modules: Add IBM858.
	* iconvdata/ibm858.c: New file.
	* iconvdata/tst-tables.sh: Add IBM858
	* localedata/charmaps/IBM858: New file.
2017-09-14 15:50:57 +02:00
Florian Weimer
4504783c0f benchtests: Do not compile benchmark objects as libc modules [BZ #21864]
Otherwise, this will lead to link failures due to hidden symbol
references.
2017-08-21 19:28:54 +02:00
Wilco Dijkstra
d4505b895f Add math benchmark latency test
This patch further improves math function benchmarking by adding a latency
test in addition to throughput.  This enables more accurate comparisons of the
math functions. The latency test works by creating a dependency on the previous
iteration: func_res = F (func_res * zero + input[i]). The multiply by zero
avoids changing the input.

It reports reciprocal throughput and latency in nanoseconds (depending on the
timing header used) and max/min throughput in iterations per second:

   "workload-spec2006.wrf": {
    "reciprocal-throughput": 100,
    "latency": 200,
    "max-throughput": 1.0e+07,
    "min-throughput": 5.0e+06
   }

	* benchtests/bench-skeleton.c (main): Add support for
	latency benchmarking.
	* benchtests/scripts/bench.py: Add support for latency benchmarking.
2017-08-17 16:27:20 +01:00
Siddhesh Poyarekar
86c6519ee7 benchtests: Print json in memmove benchmark
Make the memmove benchmarks (bench-memmove and bench-memmove-large)
print their output in JSON so that they can be evaluated using the
compare_strings.py script.

	* benchtests/bench-memmove-large.c: Print output in JSON
	format.
	* benchtests/bench-memmove.c: Likewise.
2017-08-11 12:19:27 +05:30
Siddhesh Poyarekar
61c982910d benchtests: Remove verification runs from benchmark tests
The test run is unnecessary and interferes with the benchmark.  The
tests are done during make check, so they're unnecessary here.

	* benchtests/bench-memccpy.c (do_one_test): Remove checks.
	* benchtests/bench-memchr.c (do_one_test): Likewise.
	* benchtests/bench-memcpy-large.c (do_one_test): Likewise.
	* benchtests/bench-memcpy.c (do_one_test): Likewise.
	* benchtests/bench-memmove-large.c (do_one_test): Likewise.
	* benchtests/bench-memmove.c (do_one_test): Likewise.
	* benchtests/bench-memset-large.c (do_one_test): Likewise.
	* benchtests/bench-memset.c (do_one_test): Likewise.
	* benchtests/bench-string.h (test_init): Remove memsets.
2017-08-11 12:19:26 +05:30
Siddhesh Poyarekar
dd3e86ad7c benchtests: Avoid a display error when running in text terminal
The compare_strings.py script generates a graph for the benchmarks it
performs a comparison on and that fails if X is not available.  Avoid
the error and ensure that only the graph is generated and saved as a
PNG file.

	* benchtests/scripts/compare_strings.py: Avoid display error
	when generating graph.
2017-08-08 00:56:10 +05:30
Siddhesh Poyarekar
b115e819af benchtests: Allow selecting baseline for compare_string.py
This patch allows one to provide the function name using an optional
-base option to compare all other functions against.  This is useful
when pitching one implementation of a string function against
alternatives.  In the absence of this option, comparisons are done
against the first ifunc in the list.

	* benchtests/scripts/compare_strings.py (main): Add an
	optional -base option.
	(process_results): New argument base_func.
2017-08-08 00:55:12 +05:30
Siddhesh Poyarekar
7ee38e6040 benchtests: Use TEST_NAME instead of hardcoding memcpy
The hardcoded 'memcpy' name turns up in other derived tests like
mempcpy.

       * benchtests/bench-memcpy.c (test_main): Use TEST_NAME instead of
       hardcoding memcpy.
       * benchtests/bench-memcpy-large.c (test_name): Likewise.
       * benchtests/bench-memcpy-random.c (test_name): Likewise.
2017-08-08 00:44:00 +05:30
Siddhesh Poyarekar
25d5247277 benchtests: New script to parse memcpy results
Read the memcpy results in json and print out the results in tabular
form, in addition to generating a graph of the results to compare all
of the implementations.

The format of the output is extensible enough to allow this kind of
analysis to be done on other string functions as well.

	* benchtests/scripts/benchout_strings.schema.json: New file.
	* benchtests/scripts/compare_strings.py: New file.
2017-06-22 23:44:51 +05:30
Siddhesh Poyarekar
5ee1e3cebc benchtests: Make memcpy benchmarks print results in json
Print the benchmark output for various memcpy benchmarks in json so
that it can be predictably parsed and analyzed.

	* benchtests/bench-memcpy-large.c: Include json-lib.h.
	(do_one_test): Print json.
	(do_test): Likewise.
	(test_main): Likewise.
	* benchtests/bench-memcpy-random.c: Include json-lib.h.
	(do_one_test): Print json.
	(do_test): Likewise.
	(test_main): Likewise.
	* benchtests/bench-memcpy.c: Include json-lib.h.
	(do_one_test): Print json.
	(do_test): Likewise.
	(test_main): Likewise.
2017-06-22 23:44:19 +05:30
Siddhesh Poyarekar
738a9914a0 benchtests: Print string array elements, int and uint in json
Enhance the json module in benchtests to print signed and unsigned
integers and string array elements.

	* benchtests/json-lib.h: Include inttypes.h.
	(json_attr_int, json_attr_int, json_element_string,
	json_element_int, json_element_uint): New functions.
	* benchtests/json-lib.c: (json_attr_int, json_attr_int,
	json_element_string, json_element_int, json_element_uint): New
	functions.
2017-06-22 23:44:12 +05:30
Wilco Dijkstra
18b759355d Add powf trace
Add a workload for powf.  This is a reduced trace based on 2.3 billion
samples extracted from wrf.  The distribution of values, in particular
frequency of commonly used operands is the same as in the full trace.

    * benchtests/powf-inputs: Add reduced trace from wrf.
2017-06-20 16:50:37 +01:00
Wilco Dijkstra
beb52f502f Improve math benchmark infrastructure
Improve support for math function benchmarking.  This patch adds
a feature that allows accurate benchmarking of traces extracted
from real workloads.  This is done by iterating over all samples
rather than repeating each sample many times (which completely
ignores branch prediction and cache effects).  A trace can be
added to existing math function inputs via
"## name: workload-<name>", followed by the trace.

        * benchtests/README: Describe workload feature.
        * benchtests/bench-skeleton.c (main): Add support for
        benchmarking traces from workloads.
2017-06-20 16:26:26 +01:00
Paul Clarke
4cedcaea8d Add powf bench tests
Add powf() bench test with input which covers these cases:
- positive base to positive exponent
- exponent 0
- negative base to even exponent
- exponent 1
- exponent -1
- squared
- squareroot
- 1 to negative exponent
- -1 to negative exponent
- base 0
- -1 to even exponent
- small base
- small exponent

	* benchtests/Makefile (bench-math): Add powf.
	* benchtests/powf-inputs: New file.
2017-06-20 10:14:42 -03:00
Adhemerval Zanella
0edbf12301 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-06-14 17:22:35 -03:00
H.J. Lu
6b69f98dcd benchtests: Add more tests for memrchr
bench-memchr.c is shared with bench-memrchr.c.  This patch adds some
tests for positions close to the beginning for memrchr, which are
equivalent to positions close to the end for memchr.

	* benchtests/bench-memchr.c (do_test): Print out both length
	and position.
	(test_main): Also test the position close to the beginning for
	memrchr.
2017-06-04 09:45:09 -07:00
Zack Weinberg
2bfdaeddaa 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-09 07:06:29 -04:00
Steve Ellcey
29d92a8eda Change TEST_NAME to memcpy to fix IFUNC testing of multiple versions.
* benchtests/bench-memcpy-random.c (TEST_NAME): Change to memcpy.
	(IMPL) Call with 1 instead of 0 as argument.
2017-03-28 09:07:03 -07:00
Siddhesh Poyarekar
d01cbb6e8e Actually add bench-memcpy-random
git-add and commit the benchmark that Wilco posted on the list.
2017-03-26 19:01:50 +05:30
Wilco Dijkstra
8d2030d659 Add a new randomized memcpy test for copies up to 256 bytes. The distribution
of the size and alignment is based on a trace of SPEC2006.  Instead of
repeating the same copy over and over again like the existing tests, it times
several thousand different copies to more accurately estimate the overhead of
branch prediction.

	* benchtests/Makefile (string-benchset): Add memcpy-random.
	* benchtests/bench-memcpy-random.c: New file.
2017-03-23 19:00:02 +00:00
Joseph Myers
bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Siddhesh Poyarekar
8ce8299f94 Add configure check for python program
Add a configure check that looks for python3 and python in that order
since we had agreed in the past to prefer python3 over python in all
our code.  The patch also adjusts invocations through the various
Makefiles to use the set variable.

	* configure.ac: Check for python3 or python.
	* configure: Regenerated.
	* config.make.in (PYTHON): New variable.
	* benchtests/Makefile: Don't define PYTHON.
	(bench): Define target only if PYTHON was defined.
	* Rules: Don't define PYTHON.
	Define pretty printer targets only if PYTHON was defined.
	(tests-printers): Add to tests-unsupported if PYTHON is not
	found.
	(python-flags, python-invoke): Remove.
	(tests-printers-out): Use PYTHON instead of python-invoke.
2016-12-22 23:07:52 +05:30
Wilco Dijkstra
5625f666ce This patch cleans up the strsep implementation and improves performance.
Currently strsep calls strpbrk is is now a veneer to strcspn.  Calling
strcspn directly is faster.  Since it handles a delimiter string of size
1 as a special case, this is not needed in strsep itself.  Although this
means there is a slightly higher overhead if the delimiter size is 1,
all other cases are slightly faster.  The overall performance gain is 5-10%
on AArch64.

The string/bits/string2.h header contains optimizations for constant
delimiters of size 1-3.  Benchmarking these showed similar performance for
size 1 (since in all cases strchr/strchrnul is used), while size 2 and 3
can give up to 2x speedup for small input strings.  However if these cases
are common it seems much better to add this optimization to strcspn.
So move these header optimizations to string-inlines.c.

Improve the strsep benchmark so that it actually benchmarks something.
The current version contains a delimiter character at every position in the
input string, so there is very little work to do, and the extremely inefficent
simple_strsep implementation appears fastest in every case.  The new version
has either no match in the input for the fail case and a match halfway in the
input for the success case.  The input is then restored so that each iteration
does exactly the same amount of work.  Reduce the number of testcases since
simple_strsep takes a lot of time now.

	* benchtests/bench-strsep.c (oldstrsep): Add old implementation.
	(do_one_test) Restore original string so iteration works.
	* string/string-inlines.c (do_test): Create better input strings.
	(test_main) Reduce number of testruns.
	* string/string-inlines.c (__old_strsep_1c): New function.
	(__old_strsep_2c): Likewise.
	(__old_strsep_3c): Likewise.
	* string/strsep.c (__strsep): Remove case of small delim string.
	Call strcspn directly rather than strpbrk.
	* string/bits/string2.h (__strsep): Remove define.
	(__strsep_1c): Remove.
	(__strsep_2c): Remove.
	(__strsep_3c): Remove.
	(strsep): Remove.
	* sysdeps/unix/sysv/linux/internal_statvfs.c
	(__statvfs_getflags): Rename to __strsep.
2016-12-21 15:16:29 +00:00
Adhemerval Zanella
da16c9b524 benchtests: Add fmaxf/fminf benchmarks
This patch adds fmaxf and fminf benchtests.  It is based on
math/s_fmax_template.c implementation which checks for basically four
different classes:

  1. if x is greater or equal than y.
  2. if x is less than y.
  3. if x or y is signaling.
  4. if y is nan.

Cases 1 and 2 are used for default input number (by mixing normal double
numbers and infinity), while case 3 and 4 are used each for on for a
benchmark class.

Checked on x86_64-linux-gnu and powerpc64-linux-gnu.

	* benchtests/Makefile (bench-math): Add fminf and fmaxf.
	(CFLAGS-bench-fmaxf.c): New rule.
	(CFLAGS-bench-fminf.c): Likewise.
        * benchtests/fmaxf-inputs: New file.
        * benchtests/fminf-inputs: Likewise.
2016-12-19 16:04:16 -02:00
Adhemerval Zanella
5d1f604a87 benchtests: Add fmax/fmin benchmarks
This patch adds fmax and fmin benchtests.  It is based math/s_fmax_template.c
implementation which checks for basically four different classes:

  1. if x is greater or equal than y.
  2. if x is less than y.
  3. if x or y is signaling.
  4. if y is nan.

Cases 1 and 2 are used for default input number (by mixing normal double
numbers and infinity), while case 3 and 4 are used each for on for a
benchmark class.

Checked on x86_64-linux-gnu and powerpc64-linux-gnu.

	* benchtests/Makefile (bench-math): Add fmin and fmax.
	(CFLAGS-bench-fmax.c): New rule.
	(CFLAGS-bench-fmin.c): New rule.
	* benchtests/fmax-inputs: New file.
	* benchtests/fmin-inputs: Likewise.
2016-12-19 16:04:16 -02:00
Adhemerval Zanella
b598e13477 Adjust benchtests to new support library.
This patch basically replaces the test-skeleton.c inclusion by
support/test-driver.c and also minor adjustments in bench-string.h.

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

	* benchtests/bench-string.h (TEST_FUNCTION): Use name without
	parenthesis.
	(CMDLINE_PROCESS): Define using function instead of macro.
	* benchtests/bench-memccpy.c: Include <support/test-driver.c> instead
	of test-skeleton.
	* benchtests/bench-memchr.c: Likewise.
	* benchtests/bench-memcmp.c: Likewise.
	* benchtests/bench-memcpy-large.c: Likewise.
	* benchtests/bench-memcpy.c: Likewise.
	* benchtests/bench-memmem.c: Likewise.
	* benchtests/bench-memmove-large.c: Likewise.
	* benchtests/bench-memmove.c: Likewise.
	* benchtests/bench-memset-large.c: Likewise.
	* benchtests/bench-memset.c: Likewise.
	* benchtests/bench-rawmemchr.c: Likewise.
	* benchtests/bench-strcasecmp.c: Likewise.
	* benchtests/bench-strcasestr.c: Likewise.
	* benchtests/bench-strcat.c: Likewise.
	* benchtests/bench-strchr.c: Likewise.
	* benchtests/bench-strcmp.c: Likewise.
	* benchtests/bench-strcpy.c: Likewise.
	* benchtests/bench-strcpy_chk.c: Likewise.
	* benchtests/bench-strlen.c: Likewise.
	* benchtests/bench-strncasecmp.c: Likewise.
	* benchtests/bench-strncmp.c: Likewise.
	* benchtests/bench-strncpy.c: Likewise.
	* benchtests/bench-strnlen.c: Likewise.
	* benchtests/bench-strpbrk.c: Likewise.
	* benchtests/bench-strrchr.c: Likewise.
	* benchtests/bench-strsep.c: Likewise.
	* benchtests/bench-strspn.c: Likewise.
	* benchtests/bench-strstr.c: Likewise.
	* benchtests/bench-strtok.c: Likewise.
2016-12-19 16:04:16 -02:00
Siddhesh Poyarekar
009ba649b4 Link benchset tests against libsupport
Benchsets in benchtests use test-skeleton, so they too need to be
linked against the new libsupport DSO.

       * benchtests/Makefile (binaries-benchset): Depend on libsupport
       DSO.
2016-12-18 01:22:29 +05:30
Wilco Dijkstra
d58ab810a6 Improve strtok and strtok_r performance. Instead of calling strpbrk which
calls strcspn, call strcspn directly so we get the end of the token without
an extra call to rawmemchr.  Also avoid an unnecessary call to strcspn after
the last token by adding an early exit for an empty string.  Change strtok
to tailcall strtok_r to avoid unnecessary code duplication.

Remove the special header optimization for strtok_r of a 1-character
constant string - both strspn and strcspn contain optimizations for this
case.  Benchmarking this showed similar performance in the worst case,
but up to 5.5x better performance in the "found" case for large inputs.

	* benchtests/bench-strtok.c (oldstrtok): Add old implementation.
	* string/strtok.c (strtok): Change to tailcall __strtok_r.
	* string/strtok_r.c (__strtok_r): Optimize for performance.
	* string/string-inlines.c (__old_strtok_r_1c): New function.
	* string/bits/string2.h (__strtok_r): Move to string-inlines.c.
2016-12-14 15:12:18 +00:00
Joseph Myers
7a8330c01b Use -fno-builtin for sqrt benchmark.
This patch makes the sqrt benchmark use -fno-builtin, as already done
for benchmarks of ffs and ffsll, so that it actually benchmarks the
glibc function as (presumably) intended even in the presence of the
compiler inlining sqrt.

Tested for x86_64 and also used for benchmarking my ARM sqrt patch.

	* benchtests/Makefile (CFLAGS-bench-sqrt.c): New variable.
2016-10-21 21:18:03 +00:00
H.J. Lu
447720b03b Clear destination buffer updated by the previous run
Clear the destination buffer updated by the previous run in bench-memcpy.c
and test-memcpy.c to catch the error when the following implementations do
not copy anything.

	[BZ #19907]
	* benchtests/bench-memcpy.c (do_one_test): Clear the destination
	buffer updated by the previous run.
	* string/test-memcpy.c (do_one_test): Likewise.
	* benchtests/bench-memmove.c (do_one_test): Add a comment.
	* string/test-memmove.c (do_one_test): Likewise.
2016-05-18 05:51:59 -07:00
Siddhesh Poyarekar
2d304f3c6f benchtests: Support for cross-building benchmarks
This patch adds full support for cross-building benchmarks.  Some
benchmarks like those that need locales to be generated cannot be
built and are hence skipped for cross builds.

Tested by cross building for aarch64 on x86_64 and then running the
generated benchmark on aarch64.

	* benchtests/Makefile (wcsmbs-benchset): Include only for
	native builds and runs.
	(LOCALES): Likewise.
	(bench-build): Build timing-type here instead of the bench
	target.  Generate locale only for native builds.
	* benchtests/README: Add note for cross-building.
2016-04-20 13:19:01 +05:30
Siddhesh Poyarekar
d7aea0cf06 benchtests: Clean up extra-objs
The bench-clean target would leave behind json-lib.o.  Fix up to clean
up all extra-objs registered in benchtests.
2016-04-20 13:15:50 +05:30
Siddhesh Poyarekar
bfdda211c6 benchtests: Update README to include instructions for bench-build target 2016-04-20 10:58:20 +05:30
Siddhesh Poyarekar
a00d3f4a8c New make target to only build benchmark binaries
For situations where we are cross-building or where we want to avoid
building on the target system, we want a way to only build benchmarks
and then copy them over to the target system to run them.  I have also
added a simple enhancement for the 'bench' target where all benchmark
binaries are built and then the benchmarks executed.

Tested on arm.

	Makefile.in (bench-build): New target.
	Rules (PHONY): Add bench-build target.
	benchtests/Makefile (bench): Depend on bench-build.
	(bench-build): New target.
2016-04-20 10:23:28 +05:30
Mike Frysinger
20003c4988 localedata: iw_IL: delete old/deprecated locale [BZ #16137]
From the bug:
Obsolete locale.  The ISO-639 code for Hebrew was changed from 'iw'
to 'he' in 1989, according to Bruno Haible on libc-alpha 2003-09-01.

Reported-by: Chris Leonard <cjlhomeaddress@gmail.com>
2016-04-08 18:56:34 -04:00
H.J. Lu
a25322f4e8 Add memcpy/memmove/memset benchmarks with large data
Add memcpy, memmove and memset benchmarks with large data sizes.

	* benchtests/Makefile (string-benchset): Add memcpy-large,
	memmove-large and memset-large.
	* benchtests/bench-memcpy-large.c: New file.
	* benchtests/bench-memmove-large.c: Likewise.
	* benchtests/bench-memmove-large.c: Likewise.
	* benchtests/bench-string.h (TIMEOUT): Don't redefine.
2016-04-06 08:37:39 -07:00
H.J. Lu
344303f3cf Test 64-byte alignment in memset benchtest
Add 64-byte alignment tests in memset benchtest for 64-byte vector
registers.

	* benchtests/bench-memset.c (do_test): Support 64-byte
	alignment.
	(test_main): Test 64-byte alignment.
2016-04-01 10:00:12 -07:00
H.J. Lu
aea44bf61a Test 64-byte alignment in memmove benchtest
Add 64-byte alignment tests in memmove benchtest for 64-byte vector
registers.

	* benchtests/bench-memmove.c (test_main): Test 64-byte
	alignment.
2016-04-01 09:59:09 -07:00
H.J. Lu
32b28d24a1 Test 64-byte alignment in memcpy benchtest
Add 64-byte alignment tests in memcpy benchtest for 64-byte vector
registers.

	* benchtests/bench-memcpy.c (test_main): Test 64-byte alignment.
2016-04-01 09:57:53 -07:00
H.J. Lu
87da630b22 Support --enable-hardcoded-path-in-tests in benchtests
benchtests should use $(test-via-rtld-prefix) and $(+link-tests) like
other glibc tests.

	[BZ #19783]
	* benchtests/Makefile (run-bench): Replace $(rtld-prefix) with
	$(test-via-rtld-prefix).
	($(binaries-bench)): Replace $(+link) with $(+link-tests).
2016-03-08 04:53:38 -08:00