From 15786e407fd9d22ec1c71ff922e5aa0d3c05a8ec Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 28 Jul 2020 10:56:12 -0700 Subject: Cleanup for #inclusivefixit. Test: build Change-Id: Ib2f264feae69fbbda5fe1e1c315b6116ecf520fa --- libc/system_properties/contexts_split.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/system_properties/contexts_split.cpp') diff --git a/libc/system_properties/contexts_split.cpp b/libc/system_properties/contexts_split.cpp index 96b01a47c..ccb5bcd69 100644 --- a/libc/system_properties/contexts_split.cpp +++ b/libc/system_properties/contexts_split.cpp @@ -269,7 +269,7 @@ bool ContextsSplit::InitializeProperties() { if (!InitializePropertiesFromFile("/system/etc/selinux/plat_property_contexts")) { return false; } - // Don't check for failure here, so we always have a sane list of properties. + // Don't check for failure here, since we don't always have all of these partitions. // E.g. In case of recovery, the vendor partition will not have mounted and we // still need the system / platform properties to function. if (access("/vendor/etc/selinux/vendor_property_contexts", R_OK) != -1) { -- cgit v1.2.3 From a5744e213f4467091a84c1988215d7e1b59c24cc Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 1 Sep 2020 22:35:56 +0000 Subject: Add benchmark for property mapping This benchmarks mapping property prefixes to property contexts with two algorithms: the 'Legacy' method used before Android P and the 'Trie' used afterwards (the code in this directory). It uses input mappings from both Oreo and the latest in AOSP ('S'). Note that there is nearly a 10x increase in the number of mappings in S as there was in Oreo, which was predicted when the trie was designed. Results on cuttlefish: ----------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------- LegacyLookupOreo 683576 ns 673538 ns 1060 LegacyLookupS 5683109 ns 5596982 ns 124 TrieLookupOreo 299851 ns 295696 ns 2378 TrieLookupS 584831 ns 576801 ns 1204 The results show that the legacy look up uses 8.3x more CPU time to handle the number of mappings added through S, whereas the Trie lookup uses less than 2x more CPU time, showing that the trie scales better with added mappings. Test: run this benchmark Change-Id: I35c3aa4429f049e327a891f9cbe1901d8855d7ba --- libc/system_properties/contexts_split.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libc/system_properties/contexts_split.cpp') diff --git a/libc/system_properties/contexts_split.cpp b/libc/system_properties/contexts_split.cpp index ccb5bcd69..f71d70aa7 100644 --- a/libc/system_properties/contexts_split.cpp +++ b/libc/system_properties/contexts_split.cpp @@ -324,10 +324,16 @@ bool ContextsSplit::Initialize(bool writable, const char* filename, bool* fsetxa return true; } -prop_area* ContextsSplit::GetPropAreaForName(const char* name) { +PrefixNode* ContextsSplit::GetPrefixNodeForName(const char* name) { auto entry = ListFind(prefixes_, [name](PrefixNode* l) { return l->prefix[0] == '*' || !strncmp(l->prefix, name, l->prefix_len); }); + + return entry; +} + +prop_area* ContextsSplit::GetPropAreaForName(const char* name) { + auto entry = GetPrefixNodeForName(name); if (!entry) { return nullptr; } -- cgit v1.2.3