platform_system_core/fs_mgr/libsnapshot
Akilesh Kailash 9df7c07e5a Tune snapshot-merge performance
Currently, there is one thread per partition
for snapshot merge. When all these threads are
run in parallel, this may stress the system
as the merge threads are both CPU and I/O bound.

Allow only two merge threads to be in-flight
at any point in time. This will ensure that there
is forward progress done with respect to snapshot-merge
and only two cores are used as against using
5-6 cores.

Additionally, system and prodcut partitions are merged
first. This is primarily because /root is mounted
of system partition and faster the merge completes
on /system partition, we can switch the dm tables
immediately. There is no change in the merge phase
from libsnapshot perspective. This prioritization
is based on each merge phase. If the system partition
merge is in second phase, then it takes priority
in that phase.

As a side benefit, this should also
reduce the memory usage when merge is in-flight
given that we now limit the threads.

There is slight delay in overall merge time as
we now throttle the merge.

No boot time regressions observed.

Full OTA:

Merge time (Without this patch): 42 seconds
Merge time (With this patch): 46 seconds

Incremental OTA:

Merge time (Without this patch): 52 seconds
Merge time (With this patch): 57 seconds

system partition merge completes in the first ~12-16 seconds.

App-launch (COLD) on Pixel:

Baseline (After snapshot-merge is completed when there is no daemon):
==========================

Chrome: 250
youtube: 631
camera: 230

==========================

Without this patch when snapshot-merge is in-progress (in ms):

Full - OTA

Chrome: 1729
youtube: 3126
camera: 1525

==========================

With this patch when snapshot-merge is in-progress (in ms):


Full - OTA

Chrome:  1061
youtube: 820
camera: 1378

Incremental - OTA (350M)

Chrome: 495
youtube: 1442
camera: 641
=====================

Bug: 237490659
Test: Full and incremental OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I887d5073dba88e9a8a85ac10c771e4ccee7c84ff
2022-07-01 19:05:09 +00:00
..
android/snapshot libsnapshot: Add more feature flags to SnapshotMergeReport. 2022-05-25 13:40:31 -07:00
corpus libsnapshot: Move ImageManager creation to DeviceInfo. 2021-05-13 11:33:38 -07:00
include/libsnapshot Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
include_test/libsnapshot Revert "libsnapshot: Fix libsnapshot_fuzzer_test." 2022-01-05 14:55:29 +00:00
scripts Add LOCAL_LICENSE_KINDS to system/core/fs_mgr 2021-09-15 10:57:11 -07:00
snapuserd Tune snapshot-merge performance 2022-07-01 19:05:09 +00:00
update_engine libsnapshot: Retrieve COW version from update engine manifest 2021-04-30 06:46:24 +00:00
Android.bp Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
cow_api_test.cpp libsnapshot: Add function to verify merge sequence 2021-09-24 16:03:17 -07:00
cow_decompress.cpp Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
cow_decompress.h Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
cow_format.cpp libsnapshot: Add function to verify merge sequence 2021-09-24 16:03:17 -07:00
cow_reader.cpp Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
cow_writer.cpp Add lz4 support for VABC 2022-06-29 13:10:55 -07:00
device_info.cpp Revert "libsnapshot: Fix libsnapshot_fuzzer_test." 2022-01-05 14:55:29 +00:00
device_info.h Revert "libsnapshot: Fix libsnapshot_fuzzer_test." 2022-01-05 14:55:29 +00:00
dm_snapshot_internals.h libsnapshot: Use std::unordered_set in DmSnapCowSizeCalculator. 2021-07-30 11:02:28 -07:00
estimate_cow_from_nonab_ota.cpp reland: Rename Flush to Finalize 2020-10-22 02:34:26 -07:00
fuzz.sh Rename native code coverage paths env. variable in libsnapshot's fuzz test. 2020-06-10 13:04:53 +01:00
fuzz_utils.cpp libsnapshot_fuzzer: use protobuf 2020-04-30 23:05:36 -07:00
fuzz_utils.h Reland "libsnapshot_fuzzer: Add tests" 2020-05-15 14:34:01 -07:00
inspect_cow.cpp inspect_cow: Print OTA ops for debugging 2022-02-28 22:05:21 +00:00
make_cow_from_ab_ota.cpp libsnapshot: Support cluster_ops in make_cow_from_ab_ota 2020-12-02 21:31:23 -08:00
OWNERS libsnapshot: Edit OWNERS file 2022-03-03 01:18:07 +00:00
partition_cow_creator.cpp Revert "libsnapshot: Fix checks for compression to work with new..." 2022-01-05 14:55:37 +00:00
partition_cow_creator.h Revert "libsnapshot: Fix checks for compression to work with new..." 2022-01-05 14:55:37 +00:00
partition_cow_creator_test.cpp libsnapshot: COW size is computed within the container capability 2021-02-16 11:08:21 +00:00
power_test.cpp libsnapshot: Add a simple script and gtest to simulate power failures during snapshot-merge. 2020-04-14 23:32:38 -07:00
PowerTest.md libsnapshot: Add a simple script and gtest to simulate power failures during snapshot-merge. 2020-04-14 23:32:38 -07:00
return.cpp libsnapshot: delete WaitForMerge. 2020-03-03 13:19:49 -08:00
run_power_test.sh libsnapshot: Add a simple script and gtest to simulate power failures during snapshot-merge. 2020-04-14 23:32:38 -07:00
run_snapshot_tests.sh libsnapshot: Unify vts_libsnapshot_test harness. 2021-12-05 22:39:50 -08:00
snapshot.cpp Tune snapshot-merge performance 2022-07-01 19:05:09 +00:00
snapshot_fuzz.cpp Use more inclusive language for #inclusivefixit 2020-07-23 11:13:37 -07:00
snapshot_fuzz_utils.cpp fs_mgr: remove crypt_footer argument from fs_mgr_do_format() 2021-11-09 22:44:50 -08:00
snapshot_fuzz_utils.h fastbootd: Remove all scratch partitions on update-super. 2022-02-17 04:16:53 +00:00
snapshot_metadata_updater.cpp Merge "libsnapshot: Properly set partial_update_" 2020-07-31 23:02:05 +00:00
snapshot_metadata_updater.h Update libsnapshot to handle partial update 2020-06-09 12:53:45 -07:00
snapshot_metadata_updater_test.cpp libsnapshot_test: skip global setup on non-VAB devices. 2020-08-06 17:21:50 -07:00
snapshot_reader.cpp snapuserd: Add support for Xor ops in snapuserd 2021-07-30 20:44:46 -07:00
snapshot_reader.h libsnapshot: Implement OpenReader for CompressedSnapshotWriter. 2020-10-26 22:30:21 -07:00
snapshot_reader_test.cpp libsnapshot: Fix crash in MakeXorBlockString test. 2021-12-02 23:51:39 -08:00
snapshot_stats.cpp libsnapshot: Add more feature flags to SnapshotMergeReport. 2022-05-25 13:40:31 -07:00
snapshot_stub.cpp libsnapshot: Add more feature flags to SnapshotMergeReport. 2022-05-25 13:40:31 -07:00
snapshot_test.cpp libsnapshot: Fix vts_libsnapshot_test for GRF with Vendor on S 2022-06-15 20:50:02 +00:00
snapshot_writer.cpp Add VerifyMergeOps to ISnapshotWriter 2021-09-29 10:04:11 -07:00
snapshot_writer_test.cpp Add a small testcase for snapshot writer. 2021-05-04 13:51:34 -04:00
snapshotctl.cpp Add helptext for snapshotctl map 2021-05-25 14:43:52 -04:00
test_helpers.cpp vts_libsnapshot_test: Fix free space calculation. 2022-03-17 20:39:47 -07:00
utility.cpp libsnapshot: Propagate io_uring enablement to daemon 2022-02-09 22:46:49 +00:00
utility.h libsnapshot: Propagate io_uring enablement to daemon 2022-02-09 22:46:49 +00:00
vts_ota_config_test.cpp Add a VTS test for Virtual A/B. 2022-02-18 14:16:44 -08:00