update_engine: Implement soft/hard chunk size limits.

The current approach uses a single chunk_size value, that defaults to
-1 (or "whole files") for delta payloads. The "whole files" default is
the preferred value since BSDIFF and SOURCE_BSDIFF operations (the most
common operations in real delta payloads) will benefit from having
access to the whole file in the old and new partition, in particular in
cases like the chrome binary (~120 MiB in size).

On the other hand, very big chunks have a big memory footprint in most
cases. Current implementations of BSDIFF, REPLACE_BZ and REPLACE will
require as much private memory as the destination chunk_size or more.
Because of this and due to the lack of old data, a  small chunk_size
(1 MiB) is used for full payloads.

To break this tension between having a big chunk_size for operations
that will benefit from it versus having a small chunk_size for cases
where it doesn't change anything, this patch introduces two chunk
size values: a hard and soft limit.

The hard_chunk_size has the same meaning as the old chunk_size: no
operation should have a destination bigger than the provided hard
limit. The soft_chunk_size is the preferred chunk size for an
operation when a bigger chunk will not benefit significantly the
final payload size. Having a small chunk size for operations like
REPLACE_BZ, REPLACE, SOURCE_COPY and MOVE is important to keep the
memory footprint low when it the extra memory is not required.

The new soft_chunk_size limit is used when merging operations
(previously hard-coded to 1 MiB) and when generating new
operations for zeroed and moved blocks.

BUG=chromium:485397
TEST=Run cros_generate_update_payload for full and delta payloads.
Inspected the chunk size in the resulting payloads.

Change-Id: I370048a81913ad23a151cfef6690627b7fff7277
Reviewed-on: https://chromium-review.googlesource.com/286568
Reviewed-by: Gilad Arnold <[email protected]>
Tested-by: Alex Deymo <[email protected]>
Trybot-Ready: Alex Deymo <[email protected]>
Commit-Queue: Alex Deymo <[email protected]>
16 files changed
tree: c06e70c4b7a7c2e4b545ba84559a64534f544012
  1. dbus_bindings/
  2. init/
  3. payload_generator/
  4. sample_images/
  5. update_manager/
  6. .gitignore
  7. action.h
  8. action_pipe.h
  9. action_pipe_unittest.cc
  10. action_processor.cc
  11. action_processor.h
  12. action_processor_unittest.cc
  13. action_unittest.cc
  14. bzip.cc
  15. bzip.h
  16. bzip_extent_writer.cc
  17. bzip_extent_writer.h
  18. bzip_extent_writer_unittest.cc
  19. certificate_checker.cc
  20. certificate_checker.h
  21. certificate_checker_unittest.cc
  22. chrome_browser_proxy_resolver.cc
  23. chrome_browser_proxy_resolver.h
  24. chrome_browser_proxy_resolver_unittest.cc
  25. clock.cc
  26. clock.h
  27. clock_interface.h
  28. connection_manager.cc
  29. connection_manager.h
  30. connection_manager_unittest.cc
  31. constants.cc
  32. constants.h
  33. dbus_constants.h
  34. dbus_service.cc
  35. dbus_service.h
  36. dbus_wrapper_interface.h
  37. delta_performer.cc
  38. delta_performer.h
  39. delta_performer_unittest.cc
  40. download_action.cc
  41. download_action.h
  42. download_action_unittest.cc
  43. error_code.h
  44. extent_writer.cc
  45. extent_writer.h
  46. extent_writer_unittest.cc
  47. fake_clock.h
  48. fake_file_writer.h
  49. fake_hardware.h
  50. fake_p2p_manager.h
  51. fake_p2p_manager_configuration.h
  52. fake_prefs.cc
  53. fake_prefs.h
  54. fake_system_state.cc
  55. fake_system_state.h
  56. file_descriptor.cc
  57. file_descriptor.h
  58. file_writer.cc
  59. file_writer.h
  60. file_writer_unittest.cc
  61. filesystem_verifier_action.cc
  62. filesystem_verifier_action.h
  63. filesystem_verifier_action_unittest.cc
  64. generate_image.gypi
  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.conf
  161. update_engine.gyp
  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