Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 404208a5 authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

snapuserd: use fadvise to invalidate pages for merge threads



Performance numbers measured on pixel watch:

Monitoring vmstat output during the window of snapshot merge for 280 seconds.

With patch:

pgsteal_kswapd  342144
pgsteal_file  386977

Without patch (baseline):

pgsteal_kswapd 1878334
pgsteal_file 1854342

Clearly kswapd activity is reduced. Additionally no direct reclaim observed from vmstat output.

Bug: 425765067
Test: Incremental OTA on Pixel watch
Change-Id: I4455973fdc81ab2b38671e34b60c1cf3ce6eff19
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
parent a77941b5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ bool MergeWorker::MergeReplaceZeroOps() {
                return false;
            }

            posix_fadvise(base_path_merge_fd_.get(), 0, 0, POSIX_FADV_DONTNEED);

            num_ops_merged = 0;
        }

@@ -387,6 +389,9 @@ bool MergeWorker::MergeOrderedOpsAsync() {
            return false;
        }

        // Invalidate page-cache pages
        posix_fadvise(base_path_merge_fd_.get(), 0, 0, POSIX_FADV_DONTNEED);

        SNAP_LOG(DEBUG) << "Block commit of size: " << snapuserd_->GetTotalBlocksToMerge();

        // Mark the block as merge complete
@@ -481,6 +486,9 @@ bool MergeWorker::MergeOrderedOps() {
            return false;
        }

        // Invalidate page-cache pages
        posix_fadvise(base_path_merge_fd_.get(), 0, 0, POSIX_FADV_DONTNEED);

        SNAP_LOG(DEBUG) << "Block commit of size: " << snapuserd_->GetTotalBlocksToMerge();
        // Mark the block as merge complete
        snapuserd_->SetMergeCompleted(ra_block_index_);
+3 −0
Original line number Diff line number Diff line
@@ -698,6 +698,9 @@ bool ReadAhead::ReadAheadIOStart() {

    SNAP_LOG(DEBUG) << "Read-ahead: total_ra_blocks_merged: " << total_ra_blocks_completed_;

    // Invalidate page-cache pages.
    posix_fadvise(backing_store_fd_.get(), 0, 0, POSIX_FADV_DONTNEED);

    // Wait for the merge to finish for the previous RA window. We shouldn't
    // be touching the scratch space until merge is complete of previous RA
    // window. If there is a crash during this time frame, merge should resume