From a70049022b53abca4e1b94a0fa0da140436f31ee Mon Sep 17 00:00:00 2001 From: Akilesh Kailash Date: Mon, 25 Jul 2022 19:08:46 +0000 Subject: [PATCH] Flush after every 2MB merge of replace ops. This will be in sync with incremental OTA's where the sync is done every 2MB. This improves performance on devices with low memory. Merge times for full OTA may increase by couple of seconds but that is ok given it decreases the memory footprint. Bug: 237490659 Test: OTA Ignore-AOSP-First: cherry-pick from aosp Signed-off-by: Akilesh Kailash Change-Id: Ic2c8d2ffdbdb677e0c4d44e5de68ce8ccf86df34 --- .../user-space-merge/snapuserd_merge.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_merge.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_merge.cpp index 17f3c4fe5..63f47d6f0 100644 --- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_merge.cpp +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_merge.cpp @@ -71,16 +71,16 @@ int Worker::PrepareMerge(uint64_t* source_offset, int* pending_ops, } bool Worker::MergeReplaceZeroOps() { - // Flush every 8192 ops. Since all ops are independent and there is no + // Flush after merging 2MB. Since all ops are independent and there is no // dependency between COW ops, we will flush the data and the number - // of ops merged in COW file for every 8192 ops. If there is a crash, - // we will end up replaying some of the COW ops which were already merged. - // That is ok. + // of ops merged in COW block device. If there is a crash, we will + // end up replaying some of the COW ops which were already merged. That is + // ok. // - // Why 8192 ops ? Increasing this may improve merge time 3-4 seconds but - // we need to make sure that we checkpoint; 8k ops seems optimal. In-case - // if there is a crash merge should always make forward progress. - int total_ops_merged_per_commit = (PAYLOAD_BUFFER_SZ / BLOCK_SZ) * 32; + // Although increasing this greater than 2MB may help in improving merge + // times; however, on devices with low memory, this can be problematic + // when there are multiple merge threads in parallel. + int total_ops_merged_per_commit = (PAYLOAD_BUFFER_SZ / BLOCK_SZ) * 2; int num_ops_merged = 0; SNAP_LOG(INFO) << "MergeReplaceZeroOps started....";