AU: reuse scratch blocks in delta generation, tolerate insufficient scratch.

Changes the delta generator cycle cutting algorithm. The old algorithm
looked for scratch space on the disk, then allocated that scratch
sequentially to operations that needed it, bailing if it ran out of
scratch.

The new algorithm first allocates non-existent blocks (those at
kTempBlockStart and higher) at first to break cycles. It then comes up
with a valid topological order for all nodes. It then tries to find
real blocks for all the non-existent temp blocks allocated. For each
cut edge ( A->B => A->N<-B ), there are 3 nodes of importance: the old
source (A) the old dst (B) and the new node (N). N writes to temp
blocks, then B reads from those temp blocks. The new algorithm starts
at node B and scans the topological order up, knowing that any
dependency from a found node to B would be valid, as it doesn't
require a change in the topo order. If a node is found, which has
blocks written, and these blocks aren't in a read-before dependence
from the found node to another node, we use those blocks as temp
space.  Notice that after we find temp blocks for a cut, a future cut
could use the blocks written by N of this cut, thus allowing temp
blocks to be reused.

Another change this algorithm makes is that if no node is found for
supplying temp blocks, the cut is resolved by making the old dst node
(B) a full operation, and moving it to the end of the topological
order (so it may supply temp blocks to other cuts).

Thus, if there is insufficient scratch, we lose compression ratio
rather than failing.

In a resent image that used a lot of scratch, I found this new algo
didn't have to convert any ops to full, as reuing scratch was enough.

This CL does perform a regression. Our filesystems do not take up the
full space in the partition. The existing delta generator makes use of
that extra space for scratch, but this new algo doesn't. We could fix
this new algorithm by creating a dummy node that writes to this extra
space at the end of the partition, then removing it from the update
file so the client doesn't actually do that write. If the reviewer is
okay with it, I'll file an Issue for this.

BUG=None
TEST=Attached unittests, create/perform delta w/ new algo

Review URL: http://codereview.chromium.org/3597014
3 files changed
tree: 591b39bdc3910160f9358c6ed033cbd8d51bc624
  1. certs/
  2. .gitignore
  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. buffered_file_writer.cc
  13. buffered_file_writer.h
  14. buffered_file_writer_unittest.cc
  15. bzip.cc
  16. bzip.h
  17. bzip_extent_writer.cc
  18. bzip_extent_writer.h
  19. bzip_extent_writer_unittest.cc
  20. cycle_breaker.cc
  21. cycle_breaker.h
  22. cycle_breaker_unittest.cc
  23. dbus_constants.h
  24. dbus_service.cc
  25. dbus_service.h
  26. decompressing_file_writer.cc
  27. decompressing_file_writer.h
  28. decompressing_file_writer_unittest.cc
  29. delta_diff_generator.cc
  30. delta_diff_generator.h
  31. delta_diff_generator_unittest.cc
  32. delta_performer.cc
  33. delta_performer.h
  34. delta_performer_unittest.cc
  35. download_action.cc
  36. download_action.h
  37. download_action_unittest.cc
  38. extent_mapper.cc
  39. extent_mapper.h
  40. extent_mapper_unittest.cc
  41. extent_ranges.cc
  42. extent_ranges.h
  43. extent_ranges_unittest.cc
  44. extent_writer.cc
  45. extent_writer.h
  46. extent_writer_unittest.cc
  47. file_writer.cc
  48. file_writer.h
  49. file_writer_mock.h
  50. file_writer_unittest.cc
  51. filesystem_copier_action.cc
  52. filesystem_copier_action.h
  53. filesystem_copier_action_unittest.cc
  54. filesystem_iterator.cc
  55. filesystem_iterator.h
  56. filesystem_iterator_unittest.cc
  57. gen_coverage_html.sh
  58. generate_delta_main.cc
  59. graph_types.h
  60. graph_utils.cc
  61. graph_utils.h
  62. graph_utils_unittest.cc
  63. gzip.cc
  64. gzip.h
  65. http_fetcher.h
  66. http_fetcher_unittest.cc
  67. inherit-review-settings-ok
  68. install_plan.h
  69. integration_unittest.cc
  70. libcurl_http_fetcher.cc
  71. libcurl_http_fetcher.h
  72. LICENSE
  73. local_coverage_rate.sh
  74. main.cc
  75. marshal.list
  76. mock_file_writer.h
  77. mock_http_fetcher.cc
  78. mock_http_fetcher.h
  79. omaha_hash_calculator.cc
  80. omaha_hash_calculator.h
  81. omaha_hash_calculator_unittest.cc
  82. omaha_request_action.cc
  83. omaha_request_action.h
  84. omaha_request_action_unittest.cc
  85. omaha_request_params.cc
  86. omaha_request_params.h
  87. omaha_request_params_unittest.cc
  88. omaha_response_handler_action.cc
  89. omaha_response_handler_action.h
  90. omaha_response_handler_action_unittest.cc
  91. org.chromium.UpdateEngine.service
  92. payload_signer.cc
  93. payload_signer.h
  94. payload_signer_unittest.cc
  95. postinstall_runner_action.cc
  96. postinstall_runner_action.h
  97. postinstall_runner_action_unittest.cc
  98. prefs.cc
  99. prefs.h
  100. prefs_interface.h
  101. prefs_mock.h
  102. prefs_unittest.cc
  103. SConstruct
  104. set_bootable_flag_action.cc
  105. set_bootable_flag_action.h
  106. set_bootable_flag_action_unittest.cc
  107. setup_dev_packages
  108. simple_key_value_store.cc
  109. simple_key_value_store.h
  110. simple_key_value_store_unittest.cc
  111. split_file_writer.cc
  112. split_file_writer.h
  113. split_file_writer_unittest.cc
  114. subprocess.cc
  115. subprocess.h
  116. subprocess_unittest.cc
  117. tarjan.cc
  118. tarjan.h
  119. tarjan_unittest.cc
  120. test_http_server.cc
  121. test_http_server.py
  122. test_utils.cc
  123. test_utils.h
  124. testrunner.cc
  125. topological_sort.cc
  126. topological_sort.h
  127. topological_sort_unittest.cc
  128. unittest_key.pem
  129. update_attempter.cc
  130. update_attempter.h
  131. update_attempter_mock.h
  132. update_attempter_unittest.cc
  133. update_check_scheduler.cc
  134. update_check_scheduler.h
  135. update_check_scheduler_unittest.cc
  136. update_engine.xml
  137. update_engine_client.cc
  138. update_metadata.proto
  139. UpdateEngine.conf
  140. utils.cc
  141. utils.h
  142. utils_unittest.cc
  143. WATCHLISTS
  144. zip_unittest.cc