diff options
author | Vic Yang <victoryang@google.com> | 2019-05-15 21:10:22 -0700 |
---|---|---|
committer | Vic Yang <victoryang@google.com> | 2019-05-16 12:10:10 -0700 |
commit | d8bef67153c51984380cf25edaf1bb9710fcb000 (patch) | |
tree | baca2e9c825daf03b02d20115563c10361c935eb /libc/malloc_hooks/malloc_hooks.cpp | |
parent | 3d64506c02674668cfcd89278f006f17ab22d9bd (diff) |
Staticlly allocate string buffers for realpath_fd()
Creating two huge buffers with std::vector, as it is now, is very
expensive, because it ends up being satisfied with mmap()/munmap().
Instead, we statically allocate a large string buffer while resizing
the other one to be a smaller and more appropriate size so that it can
be placed on the stack.
Note that this does mean that we increase linker data segment by 4KB
and that increases the overall system memory usage by about 400KB.
However, since that additional page is mostly zeroed with only some
ASCII text, it should be fairly easy to compress when it's swapped out
to ZRAM.
Test: Run with strace and observe no mmap/munmap around readlinkat().
Test: Measure average linker time of starting cameraserver on a Go
device and see ~3% speed-up.
Bug: 132783386
Change-Id: I600cc7a92be316ef67440a9a28c05d18de229f6c
Diffstat (limited to 'libc/malloc_hooks/malloc_hooks.cpp')
0 files changed, 0 insertions, 0 deletions