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

Commit 00e1b61b authored by Daniel Zheng's avatar Daniel Zheng
Browse files

reupload: libsnapshot: set thread priority

It looks like we can't use <uint> as type with specifying size

Read merge thread + worker thread priority from build configurations. In
the case of low memory devices, a lower priority will reduce CPU
utilization post OTA reboot.

Test: th
Change-Id: Ie895be32e3aea66b46503c5270939bb42f58494a
parent 35bd4d8f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -577,8 +577,10 @@ bool MergeWorker::Run() {
        SNAP_LOG(ERROR) << "Merge terminated early...";
        return true;
    }
    auto merge_thread_priority = android::base::GetUintProperty<uint32_t>(
            "ro.virtual_ab.merge_thread_priority", ANDROID_PRIORITY_BACKGROUND);

    if (!SetThreadPriority(ANDROID_PRIORITY_BACKGROUND)) {
    if (!SetThreadPriority(merge_thread_priority)) {
        SNAP_PLOG(ERROR) << "Failed to set thread priority";
    }

+5 −1
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
#include <libsnapshot/cow_format.h>
#include <pthread.h>

#include "android-base/properties.h"
#include "read_worker.h"
#include "snapuserd_core.h"
#include "user-space-merge/worker.h"
#include "utility.h"

namespace android {
@@ -259,8 +261,10 @@ bool ReadWorker::Run() {
    SNAP_LOG(INFO) << "Processing snapshot I/O requests....";

    pthread_setname_np(pthread_self(), "ReadWorker");
    auto worker_thread_priority = android::base::GetUintProperty<uint32_t>(
            "ro.virtual_ab.worker_thread_priority", ANDROID_PRIORITY_NORMAL);

    if (!SetThreadPriority(ANDROID_PRIORITY_NORMAL)) {
    if (!SetThreadPriority(worker_thread_priority)) {
        SNAP_PLOG(ERROR) << "Failed to set thread priority";
    }