update_engine: Fix delta generator mishandling of unchanged blocks.

In a previous CL:181515 I made the delta generator filter out blocks
that were being MOVEed onto themselves, subsequently discarding empty
MOVE operations entirely. This resulted in unchanged blocks being
considered "unwritten". However, I did not realize that the delta
generator was scanning and packing all these blocks into one large
REPLACE_BZ at the end, without even checking whether any of them has
changed in the new image relative to the old image. Recently, we
realized that this causes deltas between largely similar (or worse,
identical) images to bloat.

It should be noted that this inefficiency existed before the
aforementioned feature was introduced, although it only applied to truly
unused filesystem blocks. However, such blocks being mostly zero, they
compressed well and likely did not affect the size of the delta much.

This CL fixes the problem by addressing the general problem: we do not
overwrite the content of previously unwritten blocks if they are
identical to the ones in the old image. Furthermore, if none of the
unwritten blocks has changed, we omit the said REPLACE_BZ operation
entirely. In the case of a delta between identical image, the result is
a payload with no operations at all (a good thing).  In the particular
case of the failing panther_moblab build (see bug) this successfully
reduces the delta size from 625 MB to 331 bytes (!).

CQ-DEPEND=CL:246673
BUG=chromium:453659
TEST=Unit tests
TEST=Generated delta payload for previously failing panther_moblab build
TEST=Generated and tested two deltas for link (trivial N-to-N, real N-1)

Change-Id: I1c4e33d7cca5d59ba6725322970a329c1a3f7688
Reviewed-on: https://chromium-review.googlesource.com/246670
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
2 files changed
tree: ea46a68b0cbb73a9c802ea1d2f0bce67a997309b
  1. init/
  2. payload_generator/
  3. update_manager/
  4. .gitignore
  5. action.h
  6. action_pipe.h
  7. action_pipe_unittest.cc
  8. action_processor.cc
  9. action_processor.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. bzip.cc
  13. bzip.h
  14. bzip_extent_writer.cc
  15. bzip_extent_writer.h
  16. bzip_extent_writer_unittest.cc
  17. certificate_checker.cc
  18. certificate_checker.h
  19. certificate_checker_unittest.cc
  20. chrome_browser_proxy_resolver.cc
  21. chrome_browser_proxy_resolver.h
  22. chrome_browser_proxy_resolver_unittest.cc
  23. clock.cc
  24. clock.h
  25. clock_interface.h
  26. connection_manager.cc
  27. connection_manager.h
  28. connection_manager_unittest.cc
  29. constants.cc
  30. constants.h
  31. dbus_constants.h
  32. dbus_service.cc
  33. dbus_service.h
  34. dbus_wrapper_interface.h
  35. delta_performer.cc
  36. delta_performer.h
  37. delta_performer_unittest.cc
  38. download_action.cc
  39. download_action.h
  40. download_action_unittest.cc
  41. error_code.h
  42. extent_ranges.cc
  43. extent_ranges.h
  44. extent_ranges_unittest.cc
  45. extent_writer.cc
  46. extent_writer.h
  47. extent_writer_unittest.cc
  48. fake_clock.h
  49. fake_file_writer.h
  50. fake_hardware.h
  51. fake_p2p_manager.h
  52. fake_p2p_manager_configuration.h
  53. fake_prefs.cc
  54. fake_prefs.h
  55. fake_system_state.cc
  56. fake_system_state.h
  57. file_descriptor.cc
  58. file_descriptor.h
  59. file_writer.cc
  60. file_writer.h
  61. file_writer_unittest.cc
  62. filesystem_copier_action.cc
  63. filesystem_copier_action.h
  64. filesystem_copier_action_unittest.cc
  65. glib_utils.cc
  66. glib_utils.h
  67. hardware.cc
  68. hardware.h
  69. hardware_interface.h
  70. http_common.cc
  71. http_common.h
  72. http_fetcher.cc
  73. http_fetcher.h
  74. http_fetcher_unittest.cc
  75. hwid_override.cc
  76. hwid_override.h
  77. hwid_override_unittest.cc
  78. install_plan.cc
  79. install_plan.h
  80. libcurl_http_fetcher.cc
  81. libcurl_http_fetcher.h
  82. local_coverage_rate
  83. main.cc
  84. metrics.cc
  85. metrics.h
  86. mock_action.h
  87. mock_action_processor.h
  88. mock_certificate_checker.h
  89. mock_connection_manager.h
  90. mock_dbus_wrapper.h
  91. mock_file_writer.h
  92. mock_hardware.h
  93. mock_http_fetcher.cc
  94. mock_http_fetcher.h
  95. mock_omaha_request_params.h
  96. mock_p2p_manager.h
  97. mock_payload_state.h
  98. mock_prefs.h
  99. mock_update_attempter.h
  100. mtd_file_descriptor.cc
  101. mtd_file_descriptor.h
  102. multi_range_http_fetcher.cc
  103. multi_range_http_fetcher.h
  104. omaha_hash_calculator.cc
  105. omaha_hash_calculator.h
  106. omaha_hash_calculator_unittest.cc
  107. omaha_request_action.cc
  108. omaha_request_action.h
  109. omaha_request_action_unittest.cc
  110. omaha_request_params.cc
  111. omaha_request_params.h
  112. omaha_request_params_unittest.cc
  113. omaha_response.h
  114. omaha_response_handler_action.cc
  115. omaha_response_handler_action.h
  116. omaha_response_handler_action_unittest.cc
  117. OWNERS
  118. p2p_manager.cc
  119. p2p_manager.h
  120. p2p_manager_unittest.cc
  121. payload_constants.cc
  122. payload_constants.h
  123. payload_state.cc
  124. payload_state.h
  125. payload_state_interface.h
  126. payload_state_unittest.cc
  127. payload_verifier.cc
  128. payload_verifier.h
  129. postinstall_runner_action.cc
  130. postinstall_runner_action.h
  131. postinstall_runner_action_unittest.cc
  132. prefs.cc
  133. prefs.h
  134. prefs_interface.h
  135. prefs_unittest.cc
  136. proxy_resolver.cc
  137. proxy_resolver.h
  138. real_dbus_wrapper.h
  139. real_system_state.cc
  140. real_system_state.h
  141. run_unittests
  142. sample_omaha_v3_response.xml
  143. subprocess.cc
  144. subprocess.h
  145. subprocess_unittest.cc
  146. system_state.h
  147. terminator.cc
  148. terminator.h
  149. terminator_unittest.cc
  150. test_http_server.cc
  151. test_utils.cc
  152. test_utils.h
  153. test_utils_unittest.cc
  154. testrunner.cc
  155. unittest_key.pem
  156. unittest_key2.pem
  157. update_attempter.cc
  158. update_attempter.h
  159. update_attempter_unittest.cc
  160. update_engine.gyp
  161. update_engine.xml
  162. update_engine_client.cc
  163. update_metadata.proto
  164. UpdateEngine.conf
  165. utils.cc
  166. utils.h
  167. utils_unittest.cc
  168. WATCHLISTS
  169. zip_unittest.cc