summaryrefslogtreecommitdiff
path: root/tests/malloc_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-01-11 09:04:58 -0800
committerElliott Hughes <enh@google.com>2021-01-11 09:57:46 -0800
commitf9dd1a760af7e3b285169bc38fb33739e54b4636 (patch)
tree2b1fcd3ac740a1380267c867f321dd1c37737813 /tests/malloc_test.cpp
parent771af5efc6954f7dfb1420328faeef961378c196 (diff)
Store soname as a std::string.
Once upon a time (and, indeed, to this very day if you're on LP32) the soinfo struct used a fixed-length buffer for the soname. This caused some issues, mainly with app developers who accidentally included a full Windows "C:\My Computer\...\libfoo.so" style path. To avoid all this we switched to just pointing into the ELF file itself, where the DT_SONAME is already stored as a NUL-terminated string. And all was well for many years. Now though, we've seen a bunch of slow startup traces from dogfood where `dlopen("libnativebridge.so")` in a cold start takes 125-200ms on a recent device, despite no IO contention. Even though libnativebridge.so is only 20KiB. Measurement showed that every library whose soname we check required pulling in a whole page just for the (usually) very short string. Worse, there's readahead. In one trace we saw 18 pages of libhwui.so pulled in just for `"libhwui.so\0"`. In fact, there were 3306 pages (~13MiB) added to the page cache during `dlopen("libnativebridge.so")`. 13MiB for a 20KiB shared library! This is the obvious change to use a std::string to copy the sonames instead. This will dirty slightly more memory, but massively improve locality. Testing with the same pathological setup took `dlopen("libnativebridge.so")` down from 192ms to 819us. Bug: http://b/177102905 Test: tested with a pathologically modified kernel Change-Id: I33837f4706adc25f93c6fa6013e8ba970911dfb9
Diffstat (limited to 'tests/malloc_test.cpp')
0 files changed, 0 insertions, 0 deletions