platform_system_core/base
yusukes d3b9404241 Prevent WaitForProperty() from using ~100% of CPU time on 32bit builds
Since 'struct timespec' members (time_t and long) are both 32bit on
32bit systems, and std::chrono::{seconds,nanoseconds}::rep are both
>32bit, timespec members assigned in DurationToTimeSpec() can have a
negative value, especially when WaitForProperty() is called with the
default timeout value which is std::chrono::milliseconds::max().

Regarding functionality, passing a negative value to
__system_property_wait() is okay because WaitForProperty() still
waits for the property value (so unit tests are passing), but while
WaitForProperty() does that, the function, to be more exact,
SystemProperties::Wait() in bionic/, consumes ~100% of CPU time. This
happens because SystemProperties::Wait() which implements
__system_property_wait() has a tight while-loop with a __futex_wait()
call, and the futex call immediately returns EINVAL when the timespec
passed in has a negative value.

With this CL, WaitForProperty() will never pass a negative timespec
to __system_property_wait(), and therefore the __futex_wait() call
in bionic works as expected without consuming too much CPU time even
on 32bit systems.

Bug: None
Test: libbase_test32 still passes
Test: strace no longer shows repeated EINVALs from __futex_wait
Change-Id: Id1834fac8cd2876b02dbe4479bf3d3eda2fa7da1
2018-02-14 10:07:54 -08:00
..
include/android-base base: adb.exe build error 2018-02-05 09:33:10 -08:00
.clang-format Remove extraneous .clang-format files 2017-03-14 14:06:31 -07:00
Android.bp base: adb.exe build error 2018-02-05 09:33:10 -08:00
CPPLINT.cfg Don't show lint errors for rvalue references. 2015-04-02 18:38:01 -07:00
OWNERS Add OWNERS. 2017-12-07 13:30:03 -08:00
chrono_utils.cpp base: adb.exe build error 2018-02-05 09:33:10 -08:00
chrono_utils_test.cpp Move Timer from init to libbase 2017-07-10 09:28:24 -07:00
endian_test.cpp Add cross-platform <android-base/endian.h>. 2017-02-24 14:03:36 -08:00
errors_test.cpp base: add SystemErrorCodeToString() function. 2016-02-01 12:18:26 -08:00
errors_unix.cpp base: add SystemErrorCodeToString() function. 2016-02-01 12:18:26 -08:00
errors_windows.cpp base: add SystemErrorCodeToString() function. 2016-02-01 12:18:26 -08:00
file.cpp libziparchive: Use ReadAtOffset exclusively 2017-07-25 18:12:12 +00:00
file_test.cpp Keep the ReadFileToString/ReadFdToString overhead down. 2017-03-21 13:43:08 -07:00
logging.cpp Use LOG_TAG instead of binary name as a tag. 2017-12-20 10:59:46 -08:00
logging_test.cpp Fix / suppress new unused warnings for mingw+clang 2017-11-29 21:37:28 -08:00
parsedouble_test.cpp libbase: add parsedouble.h. 2016-10-19 11:19:42 -07:00
parseint_test.cpp Move off std::sto* function which abort on failure. 2016-10-13 15:34:05 -07:00
parsenetaddress.cpp base: add network address parsing function from adb. 2016-01-21 20:03:33 -08:00
parsenetaddress_test.cpp base: add network address parsing function from adb. 2016-01-21 20:03:33 -08:00
properties.cpp Prevent WaitForProperty() from using ~100% of CPU time on 32bit builds 2018-02-14 10:07:54 -08:00
properties_test.cpp Fix timeouts for android::base::WaitForProperty* 2017-03-27 18:05:58 -07:00
quick_exit.cpp Remove mutex.h and its uses. 2016-09-16 15:58:00 -07:00
quick_exit_test.cpp base: add quick_exit emulation. 2016-09-13 17:54:50 -07:00
scopeguard_test.cpp Add android::base::ScopeGuard 2017-04-05 16:15:33 -07:00
stringprintf.cpp Track rename of base/ to android-base/. 2015-12-04 22:00:26 -08:00
stringprintf_test.cpp Track rename of base/ to android-base/. 2015-12-04 22:00:26 -08:00
strings.cpp Add std::string StartsWith*/EndsWith* overloads. 2017-12-20 09:42:22 -08:00
strings_test.cpp Add std::string StartsWith*/EndsWith* overloads. 2017-12-20 09:42:22 -08:00
test_main.cpp Track rename of base/ to android-base/. 2015-12-04 22:00:26 -08:00
test_utils.cpp base: allow creating tempfile in a custom temporary dir. 2017-12-06 14:20:07 -08:00
test_utils_test.cpp base: extract {ASSERT,EXPECT}_MATCH helpers from debuggerd_test. 2017-12-19 17:16:12 -08:00
utf8.cpp Fix / suppress new unused warnings for mingw+clang 2017-11-29 21:37:28 -08:00
utf8_test.cpp Add (partial) support for Windows long paths 2017-06-28 17:12:37 +00:00