summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@google.com>2019-10-29 15:40:16 -0700
committerDaniel Colascione <dancol@google.com>2019-11-11 11:17:00 -0800
commit0cf90556de2bde53a1957c5946036b2fe2e4e429 (patch)
tree25b69c933cd0ca4d776d7845ad22a8692157a0cd /benchmarks
parent5d9ba9ea702a4d20b99639996b8bd27f121d5bd7 (diff)
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
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/property_benchmark.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 77814bf8a..ba54ed1e6 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -184,7 +184,7 @@ static void BM_property_serial(benchmark::State& state) {
size_t i = 0;
while (state.KeepRunning()) {
- pa.system_properties().Serial(pinfo[i]);
+ __system_property_serial(pinfo[i]);
i = (i + 1) % nprops;
}