How to build AOSP with 8GB RAM

2379 views
Skip to first unread message

Ravishankar S

unread,
Jun 8, 2021, 10:25:13 PM6/8/21
to Android Building
I have completed by AOSP build on a 4 core 8GB machine with the following specs:

Ryzen 3 3300u, 1TB HDD, 8GB Dual channel RAM. 
Usable is 5.81G when fully booted into Kubuntu 20.04 (no apps running)

1) FIrst enable the zram on you system and reboot: sudo apt install zram-config.

2) Default swapfile size is 2G. Its barely sufficient for the initial soong_ui phase.  Just scraped through. It should be increased to least 4GB. If you have the swapfile on SSD or  can move it to an SSD then its even better.

(For sure this phase takes a lot of RAM (~12G) and lots of disk IO. It will take more time than normal as there is lots of swapping)

3)  Still in case the soong_ui phase does not get through then you can try to reduce  reduce the number of jobs say m -j3 or m -j2.

4) The next phase is just compilation and other stuff that is not RAM intensive but mainly CPU and some Disk I/O. You can speed up this phase slightly by using tmfs for the /tmp folder.

5) The last phase is the documentation where Java is used and for this no amount of swap space will help and the system will crash for sure. We have the use the solution provided here and restart the make with just 1 job (m -j1)


export _JAVA_OPTIONS="-Xmx4g"

You can try to use m-j2 but it seemed fast enough with m -j1 and less pressure on RAM.

Other resources are: 110GB disk space after checkout and 170GB after build.


  

Igor Kukushkin

unread,
Jun 9, 2021, 9:59:05 PM6/9/21
to android-...@googlegroups.com
Hi,
what was the overall compilation time though, Mr. Ravishankar? (Also, what branch/tag, board and make target were used?)

For those who is limited with resources, It can be stripped even more, (one can save ~16gb by removing .repo dir, some memory can be recovered by using zram/compressed swap, and couple more gbs can be saved by using btrfs with compression set to zstd=3,
   mount ... -o compress=zstd:3 
   btrfs property set /build/aosp/out compression ""
To get some extra boost to compilation speed (in this configuration it'll be more about preventing CPU choking), pass "mitigations=off selinux=0 audit=0" as kernel options and reboot; to run builds, try to stay lean (make snod, m - ok, make all - not ok since it'll build some tests).

And since this is not super obvious for some people, -Xmx4g is required in this case because Java won't allocate enough heap without it, if there's not enough physical memory. To investigate what takes time, one can open build trace:
> Just open $OUT_DIR/build.trace.gz in Chrome’s chrome://tracing,

Enjoy,

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/bc27d026-a038-46c1-9143-c745e40a3b65n%40googlegroups.com.

Ravishankar S

unread,
Jun 15, 2021, 6:34:15 PM6/15/21
to Android Building
Hi Igor

I didn't measure the time taken using time as many things I was checking how it works with different options etc. 
It took me around 4-5 hours in my estimate. I could have made it faster had I used an SDD for the swapfile.

I was building the branch as described here:  https://github.com/antmicro/kvm-aosp-jetson-nano.

"For those who is limited with resources, It can be stripped even more, (one can save ~16gb by removing .repo dir, some memory can be recovered by using zram/compressed swap, and couple more gbs can be saved by using btrfs with compression set to zstd=3,
   mount ... -o compress=zstd:3 
   btrfs property set /build/aosp/out compression "

Does this save RAM or disk space ?

Thanks


Ravishankar S

unread,
Jul 13, 2021, 11:55:48 PM7/13/21
to android-...@googlegroups.com
An update.
This only works upto AOSP 10.

Does not work with AOSP 11. I am trying out this article


And nothing works. 

I tried setting some Vm args with some info from this article. 
droiddoc.go:            Flag("-J-Xmx6144m").
droiddoc.go:            Flag("-J-Xmx6144m").
droiddoc.go:            cmd.Flag("-J-Xmx6144m").

I also used -j1. But nothing helped !  

I hope AOSP will provide a way to disable the documentation build part of it. Can someone from Google help me out here..?

Kind Regards
Ravishankar

You received this message because you are subscribed to a topic in the Google Groups "Android Building" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-building/5G2l5JR3jWE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/CAK-rsLK%3Dg73oJBNvT_8XYq3Zwpm2oY-0%2BZK6rY9y4wGWFpJOvg%40mail.gmail.com.

Ravishankar S

unread,
Jul 13, 2021, 11:56:43 PM7/13/21
to Android Building
This process given below (for the Droid documentation build) does not work for AOSP11 build! We have to use the method given below:


Thanks and Regards
Ravishankar

Dan Willemsen

unread,
Jul 14, 2021, 12:10:42 AM7/14/21
to android-...@googlegroups.com
I hope AOSP will provide a way to disable the documentation build part of it. Can someone from Google help me out here..?

Unfortunately, the documentation part of the build also generates code stubs and other information extracted from the code/docs (@hidden is a javadoc tag, not an annotation / etc), so it cannot be disabled.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.

Ravishankar S

unread,
Jul 29, 2021, 11:35:01 AM7/29/21
to Android Building
A way to save disk space is to use --depth=1 and repo sync with -c option as given here:


Size of AOSP10 reduced from: 51G to 18G

Now I can keep by AOSP On SDD for speed and have the out folder on HDD.
On Thursday, June 10, 2021 at 7:29:05 AM UTC+5:30 igo...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages