aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTao Bao2017-11-04 02:08:08 -0500
committerTao Bao2017-11-09 01:04:28 -0600
commit160514bf2bac2ad8b1af6cb5a72d88439596ada1 (patch)
treebc3891d724748c24cb41bda94b0141113ed6791b /tests
parent16b8b8fd1cf9055c9206ddfced90847b21acc340 (diff)
downloadplatform-bootable-recovery-160514bf2bac2ad8b1af6cb5a72d88439596ada1.tar.gz
platform-bootable-recovery-160514bf2bac2ad8b1af6cb5a72d88439596ada1.tar.xz
platform-bootable-recovery-160514bf2bac2ad8b1af6cb5a72d88439596ada1.zip
Load-balancing update_verifier worker threads.
Prior to this CL, the block verification works were assigned based on the pattern of the ranges, which could lead to unbalanced workloads. This CL adds RangeSet::Split() and moves update_verifier over. a) For the following care_map.txt on walleye: system 20,0,347,348,540,556,32770,33084,98306,98620,163842,164156,229378,229692,294914,295228,524289,524291,524292,524348,529059 vendor 8,0,120,135,32770,32831,94564,98304,98306 Measured the time costs prior to and with this CL with the following script. $ cat test_update_verifier.sh #!/bin/sh adb shell stop adb shell "cp /data/local/tmp/care_map.txt /data/ota_package/" for i in $(seq 1 50) do echo "Iteration: $i" adb shell "bootctl set-active-boot-slot 0" adb shell "echo 3 > /proc/sys/vm/drop_caches" adb shell "time /data/local/tmp/update_verifier" sleep 3 done Without this CL, the average time cost is 5.66s, while with the CL it's reduced to 3.2s. b) For the following care_map.txt, measured the performance on marlin: system 18,0,271,286,457,8350,32770,33022,98306,98558,163842,164094,196609,204800,229378,229630,294914,295166,501547 vendor 10,0,42,44,85,2408,32770,32806,32807,36902,74242 It takes 12.9s and 5.6s without and with the CL respectively. Fixes: 68553827 Test: recovery_unit_test Test: Flash new build and trigger update_verifier. Check the balanced block verification. Change-Id: I5fa4bf09a84e6b9b0975ee5f522724464181333f
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/rangeset_test.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/unit/rangeset_test.cpp b/tests/unit/rangeset_test.cpp
index 5141bb67..7ae193e1 100644
--- a/tests/unit/rangeset_test.cpp
+++ b/tests/unit/rangeset_test.cpp
@@ -123,6 +123,86 @@ TEST(RangeSetTest, Overlaps) {
123 ASSERT_FALSE(RangeSet::Parse("2,5,7").Overlaps(RangeSet::Parse("2,3,5"))); 123 ASSERT_FALSE(RangeSet::Parse("2,5,7").Overlaps(RangeSet::Parse("2,3,5")));
124} 124}
125 125
126TEST(RangeSetTest, Split) {
127 RangeSet rs1 = RangeSet::Parse("2,1,2");
128 ASSERT_TRUE(rs1);
129 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,1,2") }), rs1.Split(1));
130
131 RangeSet rs2 = RangeSet::Parse("2,5,10");
132 ASSERT_TRUE(rs2);
133 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,5,8"), RangeSet::Parse("2,8,10") }),
134 rs2.Split(2));
135
136 RangeSet rs3 = RangeSet::Parse("4,0,1,5,10");
137 ASSERT_TRUE(rs3);
138 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("4,0,1,5,7"), RangeSet::Parse("2,7,10") }),
139 rs3.Split(2));
140
141 RangeSet rs4 = RangeSet::Parse("6,1,3,3,4,4,5");
142 ASSERT_TRUE(rs4);
143 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,1,3"), RangeSet::Parse("2,3,4"),
144 RangeSet::Parse("2,4,5") }),
145 rs4.Split(3));
146
147 RangeSet rs5 = RangeSet::Parse("2,0,10");
148 ASSERT_TRUE(rs5);
149 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,0,3"), RangeSet::Parse("2,3,6"),
150 RangeSet::Parse("2,6,8"), RangeSet::Parse("2,8,10") }),
151 rs5.Split(4));
152
153 RangeSet rs6 = RangeSet::Parse(
154 "20,0,268,269,271,286,447,8350,32770,33022,98306,98558,163842,164094,196609,204800,229378,"
155 "229630,294914,295166,457564");
156 ASSERT_TRUE(rs6);
157 size_t rs6_blocks = rs6.blocks();
158 auto splits = rs6.Split(4);
159 ASSERT_EQ(
160 (std::vector<RangeSet>{
161 RangeSet::Parse("12,0,268,269,271,286,447,8350,32770,33022,98306,98558,118472"),
162 RangeSet::Parse("8,118472,163842,164094,196609,204800,229378,229630,237216"),
163 RangeSet::Parse("4,237216,294914,295166,347516"), RangeSet::Parse("2,347516,457564") }),
164 splits);
165 size_t sum = 0;
166 for (const auto& element : splits) {
167 sum += element.blocks();
168 }
169 ASSERT_EQ(rs6_blocks, sum);
170}
171
172TEST(RangeSetTest, Split_EdgeCases) {
173 // Empty RangeSet.
174 RangeSet rs1;
175 ASSERT_FALSE(rs1);
176 ASSERT_EQ((std::vector<RangeSet>{}), rs1.Split(2));
177 ASSERT_FALSE(rs1);
178
179 // Zero group.
180 RangeSet rs2 = RangeSet::Parse("2,1,5");
181 ASSERT_TRUE(rs2);
182 ASSERT_EQ((std::vector<RangeSet>{}), rs2.Split(0));
183
184 // The number of blocks equals to the number of groups.
185 RangeSet rs3 = RangeSet::Parse("2,1,5");
186 ASSERT_TRUE(rs3);
187 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,1,2"), RangeSet::Parse("2,2,3"),
188 RangeSet::Parse("2,3,4"), RangeSet::Parse("2,4,5") }),
189 rs3.Split(4));
190
191 // Less blocks than the number of groups.
192 RangeSet rs4 = RangeSet::Parse("2,1,5");
193 ASSERT_TRUE(rs4);
194 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,1,2"), RangeSet::Parse("2,2,3"),
195 RangeSet::Parse("2,3,4"), RangeSet::Parse("2,4,5") }),
196 rs4.Split(8));
197
198 // Less blocks than the number of groups.
199 RangeSet rs5 = RangeSet::Parse("2,0,3");
200 ASSERT_TRUE(rs5);
201 ASSERT_EQ((std::vector<RangeSet>{ RangeSet::Parse("2,0,1"), RangeSet::Parse("2,1,2"),
202 RangeSet::Parse("2,2,3") }),
203 rs5.Split(4));
204}
205
126TEST(RangeSetTest, GetBlockNumber) { 206TEST(RangeSetTest, GetBlockNumber) {
127 RangeSet rs = RangeSet::Parse("2,1,10"); 207 RangeSet rs = RangeSet::Parse("2,1,10");
128 ASSERT_EQ(static_cast<size_t>(1), rs.GetBlockNumber(0)); 208 ASSERT_EQ(static_cast<size_t>(1), rs.GetBlockNumber(0));