AU: improve progress logging during updates

We currently emit a log message for operations at fixed index increments
of 1000. This is fairly useful in keeping the number of log messages
small, but otherwise quite arbitrary and useless in giving an actual
sense of progress, throughput, etc for updates of varying number of
operations in them and subject to network latencies.  Further, this
progress report does not take into the account the download progress,
which appears to be the completion metric used toward the UI.

This CL proposes a simple mechanism for computing an "overall update
progress" and an adaptive method for emitting a progress log message in
reasonable intervals. The raw metrics currently used include (i) the
number of bytes downloaded out of the expected total; (ii) the number of
operations successfully applied out of the expected total.  These are
weighed into a single percentage counter based on a prefixed set of
weights.  Logging occurs based on either (i) completion of update
"chunks" of some predetermined number; or (ii) having enough time
elapsed since the last log message.  This guarantees that we'll see
enough progress messages at regular intervals, but not too many of them.

We're also similarly logging the relative position in a resumed update
right before we start applying from the point we left it.

Note that the max number of regular log intervals, as well as the
timeout to force a progress log, can be easily tweaked by changing
compile-time constants.  They are currently set to 10 (or every 10%) and
30 (for 30 seconds since the last progress log), respectively, which
appear to be a reasonable choices.

Here's an example from an actual update log:

[0118/145759:INFO:delta_performer.cc(451)] Starting to apply update payload operations
[0118/145821:INFO:delta_performer.cc(150)] Completed 100/1040 operations (9%), 38363576/319659860 bytes downloaded (12%), overall progress 10%
[0118/145835:INFO:delta_performer.cc(150)] Completed 213/1040 operations (20%), 63939000/319659860 bytes downloaded (20%), overall progress 20%
[0118/145857:INFO:delta_performer.cc(150)] Completed 298/1040 operations (28%), 102293944/319659860 bytes downloaded (32%), overall progress 30%
[0118/145912:INFO:delta_performer.cc(150)] Completed 421/1040 operations (40%), 127869368/319659860 bytes downloaded (40%), overall progress 40%
[0118/145935:INFO:delta_performer.cc(150)] Completed 507/1040 operations (48%), 166224312/319659860 bytes downloaded (52%), overall progress 50%

(update interrupted and resumed)

[0118/150058:INFO:delta_performer.cc(150)] Resuming after 582/1040 operations (55%), 195577374/319659860 bytes downloaded (61%), overall progress 57%
[0118/150058:INFO:delta_performer.cc(451)] Starting to apply update payload operations
...
[0118/150102:INFO:delta_performer.cc(150)] Completed 604/1040 operations (58%), 200934046/319659860 bytes downloaded (62%), overall progress 60%
[0118/150116:INFO:delta_performer.cc(150)] Completed 749/1040 operations (72%), 221543046/319659860 bytes downloaded (69%), overall progress 70%
[0118/150134:INFO:delta_performer.cc(150)] Completed 840/1040 operations (80%), 255736454/319659860 bytes downloaded (80%), overall progress 80%
[0118/150154:INFO:delta_performer.cc(150)] Completed 936/1040 operations (90%), 289225350/319659860 bytes downloaded (90%), overall progress 90%
[0118/150212:INFO:delta_performer.cc(150)] Completed 1040/1040 operations (100%), 319659860/319659860 bytes downloaded (100%), overall progress 100%

BUG=chromium-os:37910
TEST=Passes unit tests
TEST=Update works, progress logged as expected on x86-alex

Change-Id: I2ec5511fc20df05a264e59651528c65133209132
Reviewed-on: https://gerrit.chromium.org/gerrit/41301
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
2 files changed
tree: 710d2a199a01f3240679d17489ca9b3f162bf0b0
  1. .gitignore
  2. 99-gpio-dutflag.rules
  3. action.h
  4. action_mock.h
  5. action_pipe.h
  6. action_pipe_unittest.cc
  7. action_processor.cc
  8. action_processor.h
  9. action_processor_mock.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. build
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_mock.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. chrome_proxy_resolver.cc
  26. chrome_proxy_resolver.h
  27. chrome_proxy_resolver_unittest.cc
  28. connection_manager.cc
  29. connection_manager.h
  30. connection_manager_unittest.cc
  31. cycle_breaker.cc
  32. cycle_breaker.h
  33. cycle_breaker_unittest.cc
  34. dbus_constants.h
  35. dbus_interface.h
  36. dbus_service.cc
  37. dbus_service.h
  38. delta_diff_generator.cc
  39. delta_diff_generator.h
  40. delta_diff_generator_unittest.cc
  41. delta_performer.cc
  42. delta_performer.h
  43. delta_performer_unittest.cc
  44. download_action.cc
  45. download_action.h
  46. download_action_unittest.cc
  47. extent_mapper.cc
  48. extent_mapper.h
  49. extent_mapper_unittest.cc
  50. extent_ranges.cc
  51. extent_ranges.h
  52. extent_ranges_unittest.cc
  53. extent_writer.cc
  54. extent_writer.h
  55. extent_writer_unittest.cc
  56. file_descriptor.cc
  57. file_descriptor.h
  58. file_writer.cc
  59. file_writer.h
  60. file_writer_mock.h
  61. file_writer_unittest.cc
  62. filesystem_copier_action.cc
  63. filesystem_copier_action.h
  64. filesystem_copier_action_unittest.cc
  65. filesystem_iterator.cc
  66. filesystem_iterator.h
  67. filesystem_iterator_unittest.cc
  68. full_update_generator.cc
  69. full_update_generator.h
  70. full_update_generator_unittest.cc
  71. gen_coverage_html
  72. generate_delta_main.cc
  73. gpio_handler.cc
  74. gpio_handler.h
  75. gpio_handler_unittest.cc
  76. gpio_handler_unittest.h
  77. gpio_mock_file_descriptor.cc
  78. gpio_mock_file_descriptor.h
  79. gpio_mock_udev_interface.cc
  80. gpio_mock_udev_interface.h
  81. graph_types.h
  82. graph_utils.cc
  83. graph_utils.h
  84. graph_utils_unittest.cc
  85. http_common.cc
  86. http_common.h
  87. http_fetcher.cc
  88. http_fetcher.h
  89. http_fetcher_unittest.cc
  90. http_fetcher_unittest.h
  91. inherit-review-settings-ok
  92. install_plan.h
  93. integration_unittest.cc
  94. libcurl_http_fetcher.cc
  95. libcurl_http_fetcher.h
  96. LICENSE
  97. local_coverage_rate
  98. main.cc
  99. marshal.list
  100. metadata.cc
  101. metadata.h
  102. metadata_unittest.cc
  103. mock_connection_manager.h
  104. mock_dbus_interface.h
  105. mock_file_writer.h
  106. mock_gpio_handler.h
  107. mock_http_fetcher.cc
  108. mock_http_fetcher.h
  109. mock_payload_state.h
  110. mock_system_state.cc
  111. mock_system_state.h
  112. multi_range_http_fetcher.cc
  113. multi_range_http_fetcher.h
  114. omaha_hash_calculator.cc
  115. omaha_hash_calculator.h
  116. omaha_hash_calculator_unittest.cc
  117. omaha_request_action.cc
  118. omaha_request_action.h
  119. omaha_request_action_unittest.cc
  120. omaha_request_params.cc
  121. omaha_request_params.h
  122. omaha_request_params_unittest.cc
  123. omaha_response.h
  124. omaha_response_handler_action.cc
  125. omaha_response_handler_action.h
  126. omaha_response_handler_action_unittest.cc
  127. org.chromium.UpdateEngine.service
  128. payload_signer.cc
  129. payload_signer.h
  130. payload_signer_unittest.cc
  131. payload_state.cc
  132. payload_state.h
  133. payload_state_interface.h
  134. payload_state_unittest.cc
  135. postinstall_runner_action.cc
  136. postinstall_runner_action.h
  137. postinstall_runner_action_unittest.cc
  138. prefs.cc
  139. prefs.h
  140. prefs_interface.h
  141. prefs_mock.h
  142. prefs_unittest.cc
  143. proxy_resolver.cc
  144. proxy_resolver.h
  145. real_system_state.h
  146. run_unittests
  147. sample_omaha_v3_response.xml
  148. SConstruct
  149. setup_dev_packages
  150. simple_key_value_store.cc
  151. simple_key_value_store.h
  152. simple_key_value_store_unittest.cc
  153. subprocess.cc
  154. subprocess.h
  155. subprocess_unittest.cc
  156. system_state.cc
  157. system_state.h
  158. tarjan.cc
  159. tarjan.h
  160. tarjan_unittest.cc
  161. terminator.cc
  162. terminator.h
  163. terminator_unittest.cc
  164. test_http_server.cc
  165. test_utils.cc
  166. test_utils.h
  167. testrunner.cc
  168. topological_sort.cc
  169. topological_sort.h
  170. topological_sort_unittest.cc
  171. udev_interface.h
  172. unittest_key.pem
  173. unittest_key2.pem
  174. update_attempter.cc
  175. update_attempter.h
  176. update_attempter_mock.h
  177. update_attempter_unittest.cc
  178. update_check_scheduler.cc
  179. update_check_scheduler.h
  180. update_check_scheduler_unittest.cc
  181. update_engine.xml
  182. update_engine_client.cc
  183. update_metadata.proto
  184. UpdateEngine.conf
  185. utils.cc
  186. utils.h
  187. utils_unittest.cc
  188. WATCHLISTS
  189. zip_unittest.cc