aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2022-05-18 10:38:44 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-05-18 10:38:44 +0000
commitad84a5a58de3deefa02659ab364f42e615ba1f46 (patch)
tree4e91d7f043bfb61dfb301319ca606e8cd0f13462
parent9645fcd9a0589b5d21ef58fabd9135724ad1f2e0 (diff)
parentf88052ae38c966b0f30c4f034389ea721d0895c9 (diff)
downloadlinux-x86-ad84a5a58de3deefa02659ab364f42e615ba1f46.tar.gz
Merge "Docs for benchmarking Clang's build performance" am: f88052ae38
Original change: https://android-review.googlesource.com/c/platform/prebuilts/clang/host/linux-x86/+/2097194 Change-Id: I9f9c87e3f96db476bf9b6ec5a003bf8c149fc4a2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--docs/build_performance.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/build_performance.md b/docs/build_performance.md
new file mode 100644
index 000000000..c9b9c13d5
--- /dev/null
+++ b/docs/build_performance.md
@@ -0,0 +1,37 @@
+# Benchmarking Build Performance of Android Clang
+
+Build performance is a vital metric as it affects development velocity, CI
+resource usage and the headroom for more sophisticated optimisation techniques.
+We heavily optimise Android Clang for peak performance.
+
+The Android Clang's compiler wrapper provides a convenient way to analyse the
+time spent building the Android platform. It can be produced by running:
+
+```
+rm -f /tmp/rusage.txt
+TOOLCHAIN_RUSAGE_OUTPUT=/tmp/rusage.txt m -j{processor count / 4}
+```
+
+We decrease the parallelism to reduce noise caused by resource contention. Also
+make sure RBE is off for the build. The resulting `rusage.txt` can be analysed
+with the following Python script:
+
+```
+#! /usr/bin/env python3
+
+import json
+
+total_clang_time = 0
+total_clang_tidy_time = 0
+
+with open('/tmp/rusage_bolt.txt', 'r') as rusage:
+ for line in rusage:
+ data = json.loads(line)
+ if 'clang-tidy' in data['compiler']:
+ total_clang_tidy_time += data['elapsed_real_time']
+ else:
+ total_clang_time += data['elapsed_real_time']
+
+print('Total clang time', total_clang_time)
+print('Total clang-tidy time', total_clang_tidy_time)
+```