platform_bionic/linker
Elliott Hughes f9dd1a760a 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
2021-01-11 09:57:46 -08:00
..
arch
Android.bp linker: Enable PGO 2020-12-09 19:03:53 +00:00
dlfcn.cpp Store soname as a std::string. 2021-01-11 09:57:46 -08:00
ld.config.format.md linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
ld_android.cpp
ldd
linked_list.h
linked_list_test.cpp
linker.arm.map
linker.cpp Store soname as a std::string. 2021-01-11 09:57:46 -08:00
linker.generic.map
linker.h Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_block_allocator.cpp
linker_block_allocator.h
linker_block_allocator_test.cpp Changes for #inclusivefixit. 2020-07-21 16:34:58 -07:00
linker_cfi.cpp Store soname as a std::string. 2021-01-11 09:57:46 -08:00
linker_cfi.h
linker_common_types.h
linker_config.cpp linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
linker_config.h linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
linker_config_test.cpp linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
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 Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_globals.h Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
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 Remove debug.ld.greylist_disabled property 2020-07-30 19:29:17 -07:00
linker_logger.h Remove debug.ld.greylist_disabled property 2020-07-30 19:29:17 -07:00
linker_main.cpp Use ELF notes to set the desired memory tagging level. 2021-01-06 16:08:18 -08:00
linker_main.h
linker_mapped_file_fragment.cpp
linker_mapped_file_fragment.h
linker_memory.cpp
linker_namespaces.cpp linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
linker_namespaces.h Store soname as a std::string. 2021-01-11 09:57:46 -08:00
linker_note_gnu_property.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_note_gnu_property.h Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_note_gnu_property_test.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_phdr.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_phdr.h Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
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 Store soname as a std::string. 2021-01-11 09:57:46 -08:00
linker_soinfo.h Store soname as a std::string. 2021-01-11 09:57:46 -08:00
linker_test_globals.cpp
linker_tls.cpp Add a thread-properties API 2020-08-11 16:51:43 +00:00
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