Move some SOURCE_COPY op processing out of Init() function
Currently, all COPY ops are processed upfront in
VABCPartitionWriter::Init() call. While update_engine is processing copy
ops, it can't respond to user actions such as pausing the OTA. To
improve UX, move some of the processing logic out of Init() function,
and spread the work through out the OTA install ops.
Before:
1. Write all COPY blocks through cow_writer
2. For blocks that gets converted to COW_REPLACE, compress them and
write to userspace snapshots using cow_writer
Item #2 take the most time, as compression + writing large blocks of
data to disk take a lot of time. This CL moves #2 to
VABCPartitionWriter::PerformSourceCopyOperation, so that the work is
done in chunks as we install the OTA.
Result:
Tested on O6, time spent on VABCPartitionWriter::Init() reduced from
177.6s to 2.3s
Test: Install oriole-UP1A.220930.002-to-UP1A.221007.001.zip
Bug: 248404111
Change-Id: I44737b7115e0ad7616ec49b8934fd6d70dc07447
diff --git a/common/cow_operation_convert.h b/common/cow_operation_convert.h
index 60c820f..a260a4a 100644
--- a/common/cow_operation_convert.h
+++ b/common/cow_operation_convert.h
@@ -29,7 +29,7 @@
CowCopy = android::snapshot::kCowCopyOp,
CowReplace = android::snapshot::kCowReplaceOp,
};
- Type op;
+ Type op{};
uint64_t src_block{};
uint64_t dst_block{};
uint64_t block_count{1};
@@ -53,5 +53,13 @@
::chromeos_update_engine::InstallOperation>& operations,
const ::google::protobuf::RepeatedPtrField<CowMergeOperation>&
merge_operations);
+
+constexpr bool IsConsecutive(const CowOperation& op1, const CowOperation& op2) {
+ return op1.op == op2.op && op1.dst_block + op1.block_count == op2.dst_block &&
+ op1.src_block + op1.block_count == op2.src_block;
+}
+
+void push_back(std::vector<CowOperation>* converted, const CowOperation& op);
+
} // namespace chromeos_update_engine
#endif