Commit 1049fe8
[Bazel] Improve Mobile-Install Incremental Manifest Generating by applying multi-thread
**Background**
While using `mobile-Install`, we noticed that it constantly takes more to run on incremental build. Take our app for example, the incremental build metrics for a single line kotlin code change looks like this:
| Command | Time |
|---------------------------|------|
| bazel build + adb install | 63s |
| mobile-install | 91s |
After digging into it, I found that the bottleneck is the "Incremental Manifest Generating" action which takes a lot of time (35+ sec) for multidex build. The time is spent on the checksum calculation for all dex files. The SHA256 checksum for each dex file takes around 1-2 sec. Currently in our app we have 10 dex shards and each dex zip contains 2-3 dex files, processing them sequentially takes more than 30 seconds.
**Change**
In this PR, I added multithread support for this script so that the checksum calculation can be done concurrently and it improved the "Incremental Manifest Generating" to be done in 6 second (80%+ improvement).
**Result & Test**
After applying this change, the total incremental build time has been reduced to 43 seconds, with a 30s+ improvement from `Incremental Manifest Generating` step.
Before:
<img width=400 src="https://user-images.githubusercontent.com/6951238/92814439-f678ef80-f377-11ea-967f-92767a08587e.png">
After:
<img width=400 src="https://user-images.githubusercontent.com/6951238/92814445-fb3da380-f377-11ea-8de6-ff8c6b77c3f8.png">
You can also easily verify this from command line:
```
jchen tmp % time python ../build_incremental_dexmanifest.py ../output/outmanifest.txt shard1.dex.zip shard10.dex.zip shard2.dex.zip shard3.dex.zip shard4.dex.zip shard5.dex.zip shard6.dex.zip shard7.dex.zip shard8.dex.zip shard9.dex.zip
python ../build_incremental_dexmanifest.py ../output/outmanifest.txt 0.70s user 0.72s system 31% cpu 4.583 total
jchen tmp % time python ../build_incremental_dexmanifest_before.py ../output/outmanifest.txt shard1.dex.zip shard10.dex.zip shard2.dex.zip shard3.dex.zip shard4.dex.zip shard5.dex.zip shard6.dex.zip shard7.dex.zip shard8.dex.zip shard9.dex.zip
python ../build_incremental_dexmanifest_before.py ../output/outmanifest.txt 0.65s user 0.64s system 3% cpu 37.908 total
```
Closes #12085.
PiperOrigin-RevId: 3409968831 parent f9f8ce7 commit 1049fe8
1 file changed
Lines changed: 53 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | | - | |
59 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
| |||
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
69 | | - | |
| 79 | + | |
70 | 80 | | |
71 | | - | |
72 | | - | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
79 | 91 | | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
93 | 115 | | |
94 | 116 | | |
95 | 117 | | |
| |||
116 | 138 | | |
117 | 139 | | |
118 | 140 | | |
119 | | - | |
| 141 | + | |
| 142 | + | |
120 | 143 | | |
121 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
122 | 154 | | |
123 | 155 | | |
124 | 156 | | |
| |||
0 commit comments