Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speeding up Android (AOSP) build time

I'm on a Intel i7 laptop with 16Gb of RAM and an SSD. Other than specifying the -j parameter and enabling CCACHE, are there any other tricks I can employ to speed up the compile time of AOSP? Currently it's at ~2hrs.

I have found that -j12 has the best performance given my CPU.

like image 563
MarkP Avatar asked Sep 11 '14 14:09

MarkP


1 Answers

I have two sugguestions:

1.) Set /tmp up as a ramdisk

Here is a great link about setting up your /tmp directory to be a ramdisk in Ubuntu

http://cpiekarski.com/2013/01/02/speeding-up-aosp-builds/

Sacrificing just a few MB of RAM (~60 MB) for a system temp directory (/tmp) ramdisk can reduce compile time anywhere from ~2%-10% depending on total system throughput (other hardware specs).

To do this all you need to do is add the following to the /etc/fstab file:

ramdisk /tmp tmpfs mode=1777,size=2g 

Where size is equal to the amount of ram you wish to use. In this case 2 Gigabytes

2.) Swap Usage

Once again a link: http://ubuntuguide.net/optimize-the-usage-of-swap-to-speed-up-response-for-ubuntu

There’s a swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. It ranges from 0 to 100, and when swappiness=0 it tells the kernel to avoid swapping processes out of physical memory for as long as possible, when swappiness=100 it tells the kernel to aggressively swap processes out of physical memory and move them to swap cache.

To check your swap factor, open a terminal and type:

cat /proc/sys/vm/swappiness

Temporarily change swappiness’ value to 10 using following command, and it will be reverted in next restart.

sudo sysctl vm.swappiness=10

To permanently change the value, open /etc/sysctl.conf in a text editor and change the value of vm.swappiness. If this value does not exist add it to the end, for example:

vm.swappiness=10 

As mentioned in other posts, make -j and CCache are also very important and helpful. There's a program called schedtool that schedules CPU processes. They claim that it works well for long-running non-interactive tasks (i.e AOSP builds), but I have yet to try it.

Cheers and Happy Building

like image 132
Stephen Weaver Avatar answered Nov 15 '22 07:11

Stephen Weaver