This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Android related improvements
ClosedPublic

Authored by cryptoad on Sep 6 2019, 10:54 AM.

Details

Summary

This changes a few things to improve memory footprint and performances
on Android, and fixes a test compilation error:

  • add stdlib.h to wrappers_c_test.cc to address https://bugs.llvm.org/show_bug.cgi?id=42810
  • change Android size class maps, based on benchmarks, to improve performances and lower the Svelte memory footprint. Also change the 32-bit region size for said configuration
  • change the reallocate logic to reallocate in place for sizes larger than the original chunk size, when they still fit in the same block. This addresses patterns from memory_replay dumps like the following:
202: realloc 0xb48fd000 0xb4930650 12352
202: realloc 0xb48fd000 0xb48fd000 12420
202: realloc 0xb48fd000 0xb48fd000 12492
202: realloc 0xb48fd000 0xb48fd000 12564
202: realloc 0xb48fd000 0xb48fd000 12636
202: realloc 0xb48fd000 0xb48fd000 12708
202: realloc 0xb48fd000 0xb48fd000 12780
202: realloc 0xb48fd000 0xb48fd000 12852
202: realloc 0xb48fd000 0xb48fd000 12924
202: realloc 0xb48fd000 0xb48fd000 12996
202: realloc 0xb48fd000 0xb48fd000 13068
202: realloc 0xb48fd000 0xb48fd000 13140
202: realloc 0xb48fd000 0xb48fd000 13212
202: realloc 0xb48fd000 0xb48fd000 13284
202: realloc 0xb48fd000 0xb48fd000 13356
202: realloc 0xb48fd000 0xb48fd000 13428
202: realloc 0xb48fd000 0xb48fd000 13500
202: realloc 0xb48fd000 0xb48fd000 13572
202: realloc 0xb48fd000 0xb48fd000 13644
202: realloc 0xb48fd000 0xb48fd000 13716
202: realloc 0xb48fd000 0xb48fd000 13788
...
In this situation we were deallocating the old chunk, and
allocating a new one for every single one of those, but now we can
keep the same chunk (we just updated the header), which saves some
heap operations.

Event Timeline

cryptoad created this revision.Sep 6 2019, 10:54 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added subscribers: Restricted Project, delcypher, srhines. · View Herald Transcript
cryptoad updated this revision to Diff 219143.Sep 6 2019, 10:58 AM

Add a LIKELY to be compliant with our stance that Primary based
allocations are likelier.

cryptoad edited the summary of this revision. (Show Details)Sep 6 2019, 1:03 PM
cryptoad edited the summary of this revision. (Show Details)
cryptoad updated this revision to Diff 219185.Sep 6 2019, 3:04 PM

SCM update.

This revision is now accepted and ready to land.Sep 10 2019, 2:20 PM
This revision was automatically updated to reflect the committed changes.