Skip to content

Commit e6f606e

Browse files
arter97neobuddy89
authored andcommitted
bionic: use jemalloc by default and allow opt-in to scudo (3/4)
Overall, jemalloc performs 23.4% better than Scudo while consuming 1.7% less amount of memory in system/extra's real-world memory_replay traces: https://docs.google.com/spreadsheets/d/19wLanILSw_l2d7oot3VvcZiFSLzPRWNb_a5ZyA3aFSU/edit?usp=sharing Scudo performs fairly well for a hardened memory allocator, but we're optimizing for performance. Tests were performed by statically linking memory_replay under QSSI 14. Android userspace has been stopped before performing all benchmarks, and each test was executed 10 times with an idle detector in between to reduce noise and errors. The entire test took about 3 days: https://github.com/arter97/android_memory_replay_helper This commit has been inspired from ProtonAOSP/android_bionic@b220489 Change-Id: I5f6955bac87d87f9ef931c9be2fd43ac5d8fbcd7 Signed-off-by: Juhyung Park <qkrwngud825@gmail.com> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 parent c14fb41 commit e6f606e

1 file changed

Lines changed: 10 additions & 49 deletions

File tree

‎libc/Android.bp‎

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -119,32 +119,15 @@ cc_defaults {
119119
// warning since this is intended right now.
120120
ldflags: ["-Wl,-z,muldefs"],
121121

122-
multilib: {
123-
lib64: {
124-
product_variables: {
125-
malloc_zero_contents: {
126-
cflags: ["-DSCUDO_ZERO_CONTENTS"],
127-
},
128-
malloc_pattern_fill_contents: {
129-
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
130-
},
131-
malloc_not_svelte: {
132-
cflags: ["-DUSE_SCUDO"],
133-
},
134-
},
122+
product_variables: {
123+
malloc_zero_contents: {
124+
cflags: ["-DSCUDO_ZERO_CONTENTS"],
135125
},
136-
lib32: {
137-
product_variables: {
138-
malloc_zero_contents: {
139-
cflags: ["-DSCUDO_ZERO_CONTENTS"],
140-
},
141-
malloc_pattern_fill_contents: {
142-
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
143-
},
144-
malloc_not_svelte_libc32: {
145-
cflags: ["-DUSE_SCUDO"],
146-
},
147-
},
126+
malloc_pattern_fill_contents: {
127+
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
128+
},
129+
malloc_use_scudo: {
130+
cflags: ["-DUSE_SCUDO"],
148131
},
149132
},
150133

@@ -158,18 +141,7 @@ cc_defaults {
158141
}
159142

160143
libc_scudo_product_variables = {
161-
malloc_not_svelte: {
162-
cflags: ["-DUSE_SCUDO"],
163-
whole_static_libs: ["libscudo"],
164-
exclude_static_libs: [
165-
"libjemalloc5",
166-
"libc_jemalloc_wrapper",
167-
],
168-
},
169-
}
170-
171-
libc32_scudo_product_variables = {
172-
malloc_not_svelte_libc32: {
144+
malloc_use_scudo: {
173145
cflags: ["-DUSE_SCUDO"],
174146
whole_static_libs: ["libscudo"],
175147
exclude_static_libs: [
@@ -179,12 +151,8 @@ libc32_scudo_product_variables = {
179151
},
180152
}
181153

182-
183154
// Defaults for native allocator libs/includes to make it
184155
// easier to change.
185-
// To disable scudo for the non-svelte config remove the line:
186-
// product_variables: libc_scudo_product_variables,
187-
// in the cc_defaults below.
188156
// ========================================================
189157
cc_defaults {
190158
name: "libc_native_allocator_defaults",
@@ -194,14 +162,7 @@ cc_defaults {
194162
"libc_jemalloc_wrapper",
195163
],
196164
header_libs: ["gwp_asan_headers"],
197-
multilib: {
198-
lib64: {
199-
product_variables: libc_scudo_product_variables,
200-
},
201-
lib32: {
202-
product_variables: libc32_scudo_product_variables,
203-
}
204-
},
165+
product_variables: libc_scudo_product_variables,
205166
}
206167

207168
// Functions not implemented by jemalloc directly, or that need to

0 commit comments

Comments
 (0)