Commit graph

23 commits

Author SHA1 Message Date
Nate Myren
08b0a68d6d Unmap appcompat properties in property benchmark
Otherwise, they'll leak and cause failures

Fixes: 305838406
Test: adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_property
Change-Id: I2d6ed4aa30012dd7aa92eed8dc564699e6505c8f
2023-11-10 11:09:46 -08:00
Nate Myren
58df4dfe9a Modify benchmark for appcompat properties, exit when init fails
The property_benchmark needs to use the `load_default_path` parameter in
when writing its test, which is necessary now. Also, the benchmark
seemed to retry infinitely when the initialization failed, so it has now
been modified to exit when the initialization fails, and send a message
as it does so.

Bug: 305838406
Test: adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_property
Change-Id: Idb235b0e7c119fa08ace5b814d7f7404dd0eaeb3
2023-11-07 15:20:49 -08:00
Tom Cherry
bdb678c9bd Merge "Add an end-to-end property benchmark." 2020-02-03 13:58:11 +00:00
Raman Tenneti
b481a2e743 Revert "Revert "Make system property reads wait-free""
This reverts commit de39d9242a.

Reason for revert: This revert is not needed

Change-Id: I34af8e5d75c724f6c4066fafbfc6bc7d58377601
2019-11-12 20:41:55 +00:00
Raman Tenneti
de39d9242a Revert "Make system property reads wait-free"
This reverts commit 0cf90556de.

Reason for revert: Device boot failures - 144355953

Change-Id: Icd4fc8c7a1d06d688a6d37e6f1c1aa45563f711b
2019-11-12 18:24:06 +00:00
Daniel Colascione
0cf90556de Make system property reads wait-free
Right now, when we read a system property, we first (assuming we've
already looked up the property's prop_info) read the property's serial
number; if we find that the low bit (the dirty bit) in the serial
number is set, we futex-wait for that serial number to become
non-dirty. By doing so, we spare readers from seeing partially-updated
property values if they race with the property service's non-atomic
memcpy to the property value slot. (The futex-wait here isn't
essential to the algorithm: spinning while dirty would suffice,
although it'd be somewhat less efficient.)

The problem with this approach is that readers can wait on the
property service process, potentially causing delays due to scheduling
variance. Property reads are not guaranteed to complete in finite time
right now.

This change makes property reads wait-free and ensures that they
complete in finite time in all cases. In the new approach, we prevent
value tearing by backing up each property we're about to modify and
directing readers to the backup copy if they try to read a property
with the dirty bit set.

(The wait freedom is limited to the case of readers racing against
*one* property update. A writer can still delay readers by rapidly
updating a property --- but after this change, readers can't hang due
to PID 1 scheduling delays.)

I considered adding explicit atomic access to short property values,
but between binary compatibility with the existing property database
and the need to carefully handle transitions of property values
between "short" (compatible with atomics) and "long" (incompatible
with atomics) length domains, I figured the complexity wasn't worth it
and that making property reads wait-free would be adequate.

Test: boots
Bug: 143561649
Change-Id: Ifd3108aedba5a4b157b66af6ca0a4ed084bd5982
2019-11-11 11:17:00 -08:00
Mark Salyzyn
ba1a723ad1 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14 15:46:49 -08:00
Yi Kong
32bc0fcf69 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-08-02 18:09:44 -07:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
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
2018-02-21 15:10:17 -08:00
Tom Cherry
64d03a287e Add an end-to-end property benchmark.
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
2017-12-19 11:25:42 -08:00
Tom Cherry
e275d6d72d Split properties into their own class to make testing better
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
2017-12-18 15:17:55 -08:00
Christopher Ferris
858e33698d Generate all the benchmarks to run.
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
2017-11-30 09:09:41 -08:00
Anders Lewis
a7b0f88997 Implement interface for bionic benchmarks.
Test: Unit tests.
Change-Id: Ic61932f61ddd572e2f045b601f9da6e090cdc45d
2017-08-07 13:16:09 -07:00
Victor Khimenko
4a92ffd302 Stop using __system_property_area__
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
2017-03-01 20:43:42 +01:00
Martijn Coenen
be763d85c8 Fix deprecated range_x() calls.
Test: builds with new libbenchmark.
Change-Id: I91c0e5c1b5cf75b8e551f3c59d83ac9352817c4a
2016-11-15 09:07:11 +01:00
Chih-Hung Hsieh
956df72eb0 Fix google-explicit-constructor warning.
Bug: 28341362
Change-Id: I85d2f83a3ca35699cfab54e725a64aaf3013c8f1
2016-04-22 10:25:10 -07:00
Elliott Hughes
281e06ba69 Switch bionic over to google-benchmark.
Also removes the old benchmarking library.

Change-Id: I4791ae69fa5dea03644d3d411c60b7c6d1fceae3
2016-03-07 13:50:50 -08:00
Christopher Ferris
df4942c04a Refactor the benchmark code.
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
2015-02-19 14:58:24 -08:00
Christopher Ferris
53531ccebb Make sure not to construct illegal property names.
Change-Id: I37624e69aec51efd4291f076fb87af3f35d33025
2014-07-15 19:26:28 -07:00
Brigid Smith
28417e6314 Added a __system_property_serial benchmark.
Change-Id: Ifc2116f26acb242f4dcdb6eefe128899a9dc63bb
2014-07-09 15:48:37 -07:00
Brigid Smith
a304476145 Added __system_propery_read benchmark.
Change-Id: Ic0e9118859a013aa04841de25822a81a7fc74b3c
2014-07-09 10:26:17 -07:00
Christopher Ferris
8b1ade5c0b Modify hard-coded directory.
Use the ANDROID_DATA environment variable instead of the hard-coded
directory for these benchmarks.

Change-Id: I00bae7b4a24e81e77fc8f52e1fe99f4d4918f520
2014-05-01 13:10:48 -07:00
Colin Cross
bd3efbc9b5 bionic: move benchmarks out of tests directory
Change-Id: I4d054965198af22c9a9c821d1bc53f4e9ea01248
2013-12-10 18:24:30 -08:00
Renamed from tests/property_benchmark.cpp (Browse further)