adbd: configure jemalloc to not immediately purge.
Profiling of adb_benchmark revealed that something like half of the CPU time was being spent in malloc and free, which was odd because the benchmark repeatedly mallocs and frees allocations of the same size. It turns out that our default configuration of jemalloc will purge after every free. Configure jemalloc to not do this, for gains of over 100% on adb_benchmark, and up to 25% (on walleye USB3) in real-life. Test: adb_benchmark Change-Id: I602dd1645c3d21709c7f6a78903511ce4d576558
This commit is contained in:
parent
9c59649e0b
commit
218f766e21
|
@ -19,10 +19,11 @@
|
|||
#include "sysdeps.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <malloc.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include <memory>
|
||||
|
@ -213,6 +214,9 @@ int adbd_main(int server_port) {
|
|||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Set M_DECAY_TIME so that our allocations aren't immediately purged on free.
|
||||
mallopt(M_DECAY_TIME, 1);
|
||||
|
||||
while (true) {
|
||||
static struct option opts[] = {
|
||||
{"root_seclabel", required_argument, nullptr, 's'},
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
@ -171,6 +172,9 @@ ADB_CONNECTION_BENCHMARK(BM_Connection_Echo, ThreadPolicy::SameThread);
|
|||
ADB_CONNECTION_BENCHMARK(BM_Connection_Echo, ThreadPolicy::MainThread);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Set M_DECAY_TIME so that our allocations aren't immediately purged on free.
|
||||
mallopt(M_DECAY_TIME, 1);
|
||||
|
||||
android::base::SetMinimumLogSeverity(android::base::WARNING);
|
||||
adb_trace_init(argv);
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
|
|
Loading…
Reference in New Issue