f9dd1a760a
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 |
||
---|---|---|
.. | ||
arch | ||
Android.bp | ||
dlfcn.cpp | ||
ld.config.format.md | ||
ld_android.cpp | ||
ldd | ||
linked_list.h | ||
linked_list_test.cpp | ||
linker.arm.map | ||
linker.cpp | ||
linker.generic.map | ||
linker.h | ||
linker_block_allocator.cpp | ||
linker_block_allocator.h | ||
linker_block_allocator_test.cpp | ||
linker_cfi.cpp | ||
linker_cfi.h | ||
linker_common_types.h | ||
linker_config.cpp | ||
linker_config.h | ||
linker_config_test.cpp | ||
linker_debug.cpp | ||
linker_debug.h | ||
linker_debuggerd.h | ||
linker_debuggerd_android.cpp | ||
linker_debuggerd_stub.cpp | ||
linker_dlwarning.cpp | ||
linker_dlwarning.h | ||
linker_gdb_support.cpp | ||
linker_gdb_support.h | ||
linker_globals.cpp | ||
linker_globals.h | ||
linker_gnu_hash.h | ||
linker_gnu_hash_benchmark.cpp | ||
linker_gnu_hash_test.cpp | ||
linker_libc_support.c | ||
linker_libcxx_support.cpp | ||
linker_logger.cpp | ||
linker_logger.h | ||
linker_main.cpp | ||
linker_main.h | ||
linker_mapped_file_fragment.cpp | ||
linker_mapped_file_fragment.h | ||
linker_memory.cpp | ||
linker_namespaces.cpp | ||
linker_namespaces.h | ||
linker_note_gnu_property.cpp | ||
linker_note_gnu_property.h | ||
linker_note_gnu_property_test.cpp | ||
linker_phdr.cpp | ||
linker_phdr.h | ||
linker_reloc_iterators.h | ||
linker_relocate.cpp | ||
linker_relocate.h | ||
linker_relocs.h | ||
linker_sdk_versions.cpp | ||
linker_sleb128.h | ||
linker_sleb128_test.cpp | ||
linker_soinfo.cpp | ||
linker_soinfo.h | ||
linker_test_globals.cpp | ||
linker_tls.cpp | ||
linker_tls.h | ||
linker_translate_path.cpp | ||
linker_translate_path.h | ||
linker_utils.cpp | ||
linker_utils.h | ||
linker_utils_test.cpp | ||
linker_wrapper.cpp | ||
MODULE_LICENSE_APACHE2 | ||
NOTICE | ||
rt.cpp |