Only enable zucchini on a subset of files
We can try zucchini on all files, but that will give a terrible runtime.
Instead, since zucchini works the best on executables, only run zucchini
on supported binary formats(such as ELF binary, jar, etc)
Test: th
Change-Id: If12759a80d731a7ac5aae1a397c32386d0f49111
diff --git a/payload_consumer/install_operation_executor_unittest.cc b/payload_consumer/install_operation_executor_unittest.cc
index a7ab7e9..5b4bd6b 100644
--- a/payload_consumer/install_operation_executor_unittest.cc
+++ b/payload_consumer/install_operation_executor_unittest.cc
@@ -240,6 +240,8 @@
source_data_, target_data_, src_extents, dst_extents, {}, {}, config);
std::vector<uint8_t> patch_data = target_data_; // Fake the full operation
AnnotatedOperation aop;
+ // Zucchini is enabled only on files with certain extensions
+ aop.name = "test.so";
ASSERT_TRUE(best_diff_generator.GenerateBestDiffOperation(
{{InstallOperation::ZUCCHINI, 1024 * BLOCK_SIZE}}, &aop, &patch_data));
ASSERT_EQ(InstallOperation::ZUCCHINI, aop.op.type());
diff --git a/payload_generator/deflate_utils.cc b/payload_generator/deflate_utils.cc
index 68d44d7..febc1c3 100644
--- a/payload_generator/deflate_utils.cc
+++ b/payload_generator/deflate_utils.cc
@@ -113,6 +113,9 @@
// Returns whether the given file |name| has an extension listed in
// |extensions|.
+
+} // namespace
+
bool IsFileExtensions(const string& name,
const std::initializer_list<string>& extensions) {
return any_of(extensions.begin(), extensions.end(), [&name](const auto& ext) {
@@ -120,8 +123,6 @@
});
}
-} // namespace
-
ByteExtent ExpandToByteExtent(const BitExtent& extent) {
uint64_t offset = extent.offset / 8;
uint64_t length = ((extent.offset + extent.length + 7) / 8) - offset;
diff --git a/payload_generator/deflate_utils.h b/payload_generator/deflate_utils.h
index 752bd9f..c055876 100644
--- a/payload_generator/deflate_utils.h
+++ b/payload_generator/deflate_utils.h
@@ -93,6 +93,9 @@
// Expands a BitExtents to a ByteExtent.
puffin::ByteExtent ExpandToByteExtent(const puffin::BitExtent& extent);
+bool IsFileExtensions(const std::string& name,
+ const std::initializer_list<std::string>& extensions);
+
} // namespace deflate_utils
} // namespace chromeos_update_engine
#endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_DEFLATE_UTILS_H_
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index 5db3f42..5ccdf0b 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -346,6 +346,17 @@
bool BestDiffGenerator::TryZucchiniAndUpdateOperation(AnnotatedOperation* aop,
brillo::Blob* data_blob) {
+ // zip files are ignored for now. We expect puffin to perform better on those.
+ // Investigate whether puffin over zucchini yields better results on those.
+ if (!deflate_utils::IsFileExtensions(
+ aop->name,
+ {".ko",
+ ".so",
+ ".art",
+ ".odex",
+ ".vdex" /*, ".capex",".jar", ".apk", ".apex"*/})) {
+ return true;
+ }
zucchini::ConstBufferView src_bytes(old_data_.data(), old_data_.size());
zucchini::ConstBufferView dst_bytes(new_data_.data(), new_data_.size());
diff --git a/payload_generator/delta_diff_utils_unittest.cc b/payload_generator/delta_diff_utils_unittest.cc
index ede6408..0c7e690 100644
--- a/payload_generator/delta_diff_utils_unittest.cc
+++ b/payload_generator/delta_diff_utils_unittest.cc
@@ -362,6 +362,8 @@
brillo::Blob data = dst_data_blob; // Fake the full operation
AnnotatedOperation aop;
+ // Zucchini is only enabled on files with certain extensions
+ aop.name = "data.so";
diff_utils::BestDiffGenerator best_diff_generator(
src_data_blob,