Similar to expf/exp2f, this patch add two benchmarks for sinf, cosf, and
sincosf: one which measures thoughput as default and one which measures
latency.
The input in 512 random value divided in 8 ranges:
1. 0.0 <= x < 0.1
2. 0.1 <= x < 0.7
3. 0.7 <= x < 3.1
4. -3.1 <= x < 3.1
5. 3.3 <= x < 33.3
6. 100.0 <= x < 1000.0
7. 1e6 <= x < 1e32
8. 1e32 < x < FLT_MAX
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I92bc2f1fac911c573c5122911d08ca590311578a
Similar to expf/exp2f, this patch add two benchmarks for logf and log2f:
one which measures thoughput and one which measures latency.
The input data is based on a reduced trace based on 2.8 billion samples
extracted from specpu2017 521.wrf_r benchmark.
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: If4fbd7eb3d40f8e155935149a82f162b222d5506
As for expf/exp2f benchmark, this patch add two benchmark for powf:
one which measures thoughput and one which measures latency.
The input data is based on a reduced trace from 2.3 billion samples
extracted from specpu2017 521.wrf_r benchmark.
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: Id8943d90dd5452146e55fb75708daaf7bf0e25fa
This patch add two benchmarks for both expf and exp2f, one which
measures thoughput, as default, and one which measures latency. The
latency benchmark works by creating a dependency on the previous
iteration and with a zero multiply to avoid changing the input value.
The input is based on a reduced trace based on 2.4 billion samples
extracted from specpu2017 521.wrf_r benchmark.
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: Ic0d40cc4977dd6875fb7431146fc38ea0e6e0bc2
Make sure that all the variables are properly initialized.
Remove the code that verifies the core to enable using get_schedaffinity
since that make it impossible to change the cpu for different tests.
Change the cpu_to_lock to an int, it really didn't need to be a long.
Fix a few missing tests.
Test: Ran unit tests.
Test: Built the tests and ran on different cpus, verifying that the
Test: chosen cpu was correct.
Test: Created an xml file that had different cpus for different tests
Test: and verified that it locked to each cpu properly.
Change-Id: Ie7b4ad8f306f13d6e968d118e71bb5dc0221552a
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed. This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.
Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
We've been using #pragma once for new internal files, but let's be more bold.
Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
Add fast path calling PIMutexTryLock() in pthread_mutex_lock.
Add trace for pi mutex waiting.
Bug: http://b/29177606
Test: run bionic-unit-tests.
Test: run bionic-benchmarks.
Change-Id: I30b6436692d5ea6b63ca9905df745edb843b5528
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
There were a bunch more unreasonable/incorrect ones, but these ones
seemed legit. Nothing very interesting, though.
Bug: N/A
Test: ran tests, benchmarks
Change-Id: If66971194d4a7b4bf6d0251bedb88e8cdc88a76f
Also fix the tests for some missing benchmarks that have been
added recently.
Test: Ran bionic benchmarks tests and all pass.
Test: Ran bionic benchmarks to verify that there are no crashes.
Change-Id: I8501553e8a229c0c6ea81e894e91ac2f5f2fe26c
This change adds an end-to-end property benchmark that finds each
property currently accessible on the system via
__system_property_find().
Test: run this benchmark
Change-Id: I7d20cc9caf36bf3650c3bb3f58500b7df09a908a
Add a hand-rolled maps line parser as something to compare our realistic
sscanf benchmark against. Also add benchmarks for the ato*/strto* family.
This patch doesn't fix the tests, which seem to have been broken by
the recent google-benchmark upgrade despite the benchmarks themselves
all working just fine. To me that's a final strike against these tests
which are hard to maintain and not obviously useful, but we can worry
about what to do with them -- whether to just delete them or to try to
turn them into tests that actually have some value -- in a separate CL.
Bug: N/A
Test: ran benchmarks
Change-Id: I6c9a77ece98d624baeb049b360876ef5c35ea7f2
Reinitializing system properties can result in crashes later in the
program, and is generally not recommended or even supported. This
change moves the actual logic for system properties into a class that
can be tested in isolation, without reinitializing the actual system
property area used in libc.
Bug: 62197783
Test: boot devices, ensure properties work
Test: system property unit tests and benchmarks
Change-Id: I9ae6e1b56c62f51a4d3fdb5b62b8926cef545649
Provide a means to check vdso kernel performance for all reasoned
combinations of clock_getres, same set of ids as clock_gettime.
Add to suites/vdso.xml
Test: /data/nativetest{64}/bionic-benchmarks-tests/bionic-benchmarks-tests
/data/benchmarktest{64}/bionic-benchmarks/bionic-benchmarks \
--bionic_xml=vdso.xml --benchmark_filter=BM_time_clock_getres*
Bug: 63737556
Change-Id: I11ea200f67aec2a2f6ad9284960f2941298da222
Provide a means to check vdso kernel performance for each of
CLOCK_MONOTONIC (current), CLOCK_MONOTONIC_COARSE,
CLOCK_MONOTONIC_RAW, CLOCK_REALTIME, CLOCK_REALTIME_COARSE,
CLOCK_BOOTTIME.
Add a suites/vdso.xml to select subset of tests impacted by
vdso implementations.
Test: /data/nativetest{64}/bionic-benchmarks-tests/bionic-benchmarks-tests
/data/benchmarktest{64}/bionic-benchmarks/bionic-benchmarks \
--bionic_xml=vdso.xml --benchmark_filter=BM_time_clock_gettime*
Bug: 63737556
Change-Id: Ibc48e838e50929527ce8d221dd1a608bf185cbc2
Add a bunch of extra options to allow greater flexibility for creating
benchmarks. Add a pattern option that can be used to represent any
one buffer or two buffer possibility. This should fully replace the
functionality of microbench.
Add a single option for one buffer benchmarks and two buffer benchmarks
that represents all of the possible options to run a string benchmark.
Add a string test suite that includes all string benchmarks using the
above option.
Test: New unit tests to cover all the new options, and all pass.
Test: Ran new string test suite with a single bionic iteration.
Change-Id: Idb13ea15e44cec626e9f46672ccd648d7ca72ba6
Instead of requiring the need to maintain a list of all the benchmarks,
add a programmatic way to generate all of the benchmarks.
This generation runs the benchmarks in alphabetical order.
Add a new macro BIONIC_BENCHMARK_WITH_ARG that will be the default argument
to pass to the benchmark. Change the benchmarks that require default arguments.
Add a small example xml file, and remove the full.xml/host.xml files.
Update readme.
Test: Ran new unit tests, verified all tests are added.
Change-Id: I8036daeae7635393222a7a92d18f34119adba745
Android is UTF-8. Don't make everyone pay to convert UTF-8 to ASCII just
so we can recognize '%'. With UTF-8 we can just strchr forwards.
Before:
---------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------
BM_stdio_printf_literal 1290 ns 1290 ns 442554
BM_stdio_printf_s 1204 ns 1204 ns 582446
BM_stdio_printf_d 1206 ns 1206 ns 578311
BM_stdio_printf_1$s 2263 ns 2263 ns 310002
After:
---------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------
BM_stdio_printf_literal 178 ns 178 ns 3394001
BM_stdio_printf_s 246 ns 246 ns 2850284
BM_stdio_printf_d 252 ns 252 ns 2778610
BM_stdio_printf_1$s 363 ns 363 ns 1929011
Add missing __find_arguments error checking to the wide variant to match
the regular one.
Also replace various char/wchar_t differences with the macro.
Bug: http://b/67371539
Test: ran tests
Change-Id: I18f122009c22699943ab5d666a98ea594a972c40
PauseTiming and ResumeTiming are thread-local, and unbalanced calls to
them leads to obviously bogus results like:
Benchmark Time CPU Iterations
-----------------------------------------------------------------
BM_pthread_exit_and_join 212600 ns 59981418 ns 12
BM_pthread_create_and_run 212997341 ns -1569132344 ns 1000
Bug: http://b/68170209
Test: ran bionic benchmarks
Change-Id: Ia88cd6af9ff524443850d834a96cf5dd9c7f3ed9
These are still needed for backwards compatibility with code built by old
versions of the NDK, but we don't need to pollute the headers with them.
Also lose the hand-written code for these. The compiler-generated code
is either the same or better, and no new code is calling these functions
anyway.
Bug: N/A
Test: ran tests
Change-Id: Ib01ad9805034433e0105aec882608cc8e6526f78
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.
Test: m host
Test: mmma bionic
Change-Id: I966e2f88c24fba5e412bee6b6382045a2026a8e4
Also start breaking up the monolithic top level README.md, pulling the
32-bit ABI stuff out into its own file, and moving the remaining benchmark
documentation in with the rest of the benchmark documentation.
Bug: N/A
Test: N/A
Change-Id: Ic1b9995e27b5044199ed34883cc0b8faa894df0e
- Add a default xml file to run if nothing is specified on the command-line.
- Add a way to specify a xml file in suites without having to specify the
full path name.
- Move all of the test xml files into their own directory.
- Add the suites directory for to glibc benchmarks.
- Add a new test for help data.
- Modify the full suite test to verify the default xml is chosen and use
the real full.xml instead of the test one. Delete the test_full.xml.
- Move the property tests to the end of the suite.
- Add skipping of xml comments.
Test: Ran the unit tests and ran the bionic benchmarks.
Change-Id: Ie99965f86fe915af0175de46c7780ab79e2b0843
On Pixel 2016, there's about 1us overhead for getline versus
fgets. fgetln(3) is worse still because of the intermediate buffering
(though it might actually be better if you were only reading one line
whose length was less than BUFSIZ).
Also use somewhat realistic input for these benchmarks: /dev/zero makes
no sense at all.
Bug: N/A
Test: ran benchmarks
Change-Id: I4a319825a37ac3849014c4c6b31523c1e200c641
Can't write to a read-only file. (Mode "rw" isn't meaningful, but isn't
considered an error by any libc I know of.)
Bug: http://b/64585477
Test: ran benchmarks
Change-Id: Ifec1d68414bfc8f3cc8d7f912cb135dccb2e7a41
Warnings:
bionic/libc/bionic/fts.c:722:5: warning: Null passed to a callee that
requires a non-null 1st parameter
bionic/libc/bionic/sched_cpualloc.c:34:25: warning: Result of 'malloc'
is converted to a pointer of type 'cpu_set_t', which is incompatible
with sizeof operand type 'unsigned long'
bionic/linker/linker_main.cpp:315:7: warning: Access to field 'e_type'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')
bionic/linker/linker_main.cpp:493:66: warning: Access to field 'e_phoff'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')
bionic/linker/linker_main.cpp:90:14: warning: Access to field 'next'
results in a dereference of a null pointer (loaded from variable 'prev')
Bug: None
Test: mma; analyzer warnings are gone. CtsBionicTestCases pass.
Change-Id: I699a60c2c6f64c50b9ea06848a680c98a8abb44a
Apparently that "backdoor" is no longer needed - the proper way is
to reinitialize properties:
https://android-review.googlesource.com/#/c/181794/24/tests/system_properties_test.cpp
Also removes mentions of libnativehelper test (it no longer uses
__system_property_area__) and removes useless "extern" declaration
(actual use was removed long ago).
Test: refactoring CL, existsing tests still pass
BUG=21852512
BUG=34114501
Change-Id: I2223cab2fcb671ea180ad4470a7aba5c9cd20bd8
The intent here is to confirm that the compiler behaves as expected,
and to guide optimization efforts, particularly where there is a
choice between primitives.
Test: Built and ran benchmark on Angler repeatedly. Manually confirmed
that the compiler behaves roughly as expected.
Change-Id: I059b245d1ba8296e9b28602559b53eafafe0a30f
The compile-time tests and a few custom libraries for dynamic linker
testing are still compiled in make.
Also converts the make rules to run tests on the host to shell scripts
in tests/run-on-host.sh and benchmarks/run-on-host.sh
Change-Id: I6f174b3a69d58c4ed74d29f4e79332d483681534
Add parentheses around macro arguments used beside operators,
or use constexpr for simple constants.
Bug: 28705665
Change-Id: I378c8aad92d3ec8e8c4b0440b5c2c99dfe01ce79
When using the --benchmark_filter option, all of the test objects
get created, but not all are run. Previously, if this test didn't run
it would get into an infinite loop waiting for the test to complete.
This change only waits for the test to complete if it was actually
executed.
Change-Id: I5151a0b4b3d5349b978e716ec4a02ebd8b4eae00
Don't enable the inlines when building libm itself. Otherwise clang gets
upset by seeing both an inline and a non-inline definition.
This reverts commit c5deb0f883.
Change-Id: If7abdb351f5a5549d6a331b33af408e8fcfa9868
Also remove cruft meant to support long-obsolete compilers. More
benchmarks.
Bug: http://b/23195789
Change-Id: Ief538e41e77a77e8013b2f4f359584e8df2c47d8
The * flag to printf() wants an int instead of size_t, and these are
distinct types on 64-bit. To accomodate this, make the name column
width helpers return int.
In theory this truncates things, but in practice this only matters if
you have a benchmark with more than INT_MAX characters in its name (in
which case you have bigger problems).
Change-Id: I3338948c25a3a8d84f1ead2f5b457c05da8a01cf
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Changes:
- Modify the benchmarks to derive from a single Benchmark object.
- Rewrite the main iteration code. This includes changing the iteration
code to use the actual total time calculated by the benchmark as a basis
for determining whether there are enough iterations instead of using
the time it takes to run the benchmark.
- Allow benchmarks to take no argument, int, or double.
- Fix the PrettyInt printer for negative integers.
- Modify the max column width name to include the whole name including
the arg part.
- Reformat property_benchmark.cpp in line with the rest of the code.
- Modify a few of the math benchmarks to take an argument instead of
separate benchmarks for the same function with different args.
- Create a vector of regex_t structs to represent the args all at
once instead of when running each benchmark.
This change is in preparation for adding new math based benchmarks.
Tested by running on a nexus flo running at max using the new code
and the old code and comparing. All of the numbers are similar, but
some of the iterations are different due to the slightly different
algorithm used.
Change-Id: I57ad1f3ff083282b9ffeb72e687cab369ce3523a
This test reports the overhead of sem_post to sem_wake for a low thread count
and a high thread count.
Change-Id: Ic30dcc8a78d754979117446bf3a28b7575cabac7
This test tries its best to report the producer side underlying futex
wake syscall overhead wthin sem_post. It does not measure the time it
takes for the wakeup to propagate to the consumer. It suffers from
clock_gettime syscall overhead, so subtract that. Lock the CPU speed
for consistent results as we may not reach >50% cpu utilization.
Change-Id: I02fa9dab2e6ac27202f0290115150bd3c8de00f2
The old __isthreaded hack was never very useful on Android because all user
code runs in a VM where there are lots of threads running. But __fsetlocking
lets a caller say "I'll worry about the locking for this FILE*", which is
useful for the normal case where you don't share a FILE* between threads
so you don't need any locking.
Bug: 17154740
Bug: 18593728
Change-Id: I2a8dddc29d3edff39a3d7d793387f2253608a68d
Also switch throughput to GiB/s. I did play with using the new code,
but having consistent units for all results seemed easier to use
anyway (and doesn't require extra code).
Change-Id: I466fd573373bd05619e6f6e6d3dedd7dae0d9362
The benchmark run loop tries to run until 1s of time has been
accumulated between StartBenchmarkTiming() and StopBenchmarkTiming().
If a majority of the time is spent stopped this can lead to
benchmarks running for very long periods of time. This can easily
happen when benchmarking something that requires initialization or
cleanup on each iteration.
Modify the loop to run for 1s of real time instead of 1s of
benchmark time. For existing benchmarks this shouldn't make much
of a difference.
Change-Id: Iaba8a13b4dfc4a5e2cd9992041c9173ea556f9cc
Benchmarks for the following sequences:
1) pthread_rwlock_rdlock -> pthread_rwlock_unlock
2) pthread_rwlock_wrlock -> pthread_rwlock_unlock
Change-Id: I8d87d4d8afab8637ea7ff5d23a0b3a81d6d40835
In practice, with this implementation we never need to make a system call.
We get the main thread's tid (which is the same as our pid) back from
the set_tid_address system call we have to make during initialization.
A new pthread will have the same pid as its parent, and a fork child's
main (and only) thread will have a pid equal to its tid, which we get for
free from the kernel before clone returns.
The only time we'd actually have to make a getpid system call now is if
we take a signal during fork and the signal handler calls getpid. (That,
or we call getpid in the dynamic linker while it's still dealing with its
own relocations and hasn't even set up the main thread yet.)
Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
This patch fixes the ARM64 ABI for libm. fenv_t is now split in 32bit status
and 32bit control. This mirrors the AArch64 FPU control and status
registers (FPCR, FPSR).
The patch also refactors the libm implementation for ARM64 into a finer
grained control over the FPU registers.
Bionic-benchmarks has been expanded with 3 more benchmarks for floating
point operations. The new libm implementation for ARM64 performs better
over all the math benchmarks available.
Change-Id: I2a7f81d6b4e55c91f8a63a4c69614fc8b1bcf2db
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
System calls can be pretty slow. This is mako, which has one of our
lowest latencies:
iterations ns/op
BM_unistd_getpid 10000000 209
BM_unistd_gettid 200000000 8
Bug: 15297299 (kernel panic from too many gettid calls)
Bug: 15315766 (excessive gettid overhead in liblogd)
Change-Id: I49656c0fc5b5d092390264a59e4f2c0d8a8b1aeb
Use the ANDROID_DATA environment variable instead of the hard-coded
directory for these benchmarks.
Change-Id: I00bae7b4a24e81e77fc8f52e1fe99f4d4918f520
Also move isinf and isnan into libc like everyone else.
Also move fpclassify to libc like the BSDs (but unlike glibc). We need
this to be able to upgrade our float/double/long double parsing to gdtoa.
Also add some missing aliases. We now have all of:
isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl,
isinf, __isinf, isinff, __isinff, isinfl, __isinfl,
__fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl.
Bug: 13469877
Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
This patch adds minor fixes to the bionic unit tests.
Change-Id: Ie10f33c631ed6c10987923d678711d22931ddb05
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>