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

Commit 83f272a2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "qpr_patch_for_smart_idle" into tm-qpr-dev

* changes:
  Make target dirty segment ratio tunable
  Make minimum gc sleep time tunnable
  Make smart idle maint update write amount record every period
parents 592f8bf6 7b847f7c
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -370,6 +370,10 @@ class StorageManagerService extends IStorageManager.Stub
    private static final float DEFAULT_LOW_BATTERY_LEVEL = 20F;
    // Decide whether charging is required to turn on the feature
    private static final boolean DEFAULT_CHARGING_REQUIRED = true;
    // Minimum GC interval sleep time in ms
    private static final int DEFAULT_MIN_GC_SLEEPTIME = 10000;
    // Target dirty segment ratio to aim to
    private static final int DEFAULT_TARGET_DIRTY_RATIO = 80;

    private volatile int mLifetimePercentThreshold;
    private volatile int mMinSegmentsThreshold;
@@ -377,6 +381,8 @@ class StorageManagerService extends IStorageManager.Stub
    private volatile float mSegmentReclaimWeight;
    private volatile float mLowBatteryLevel;
    private volatile boolean mChargingRequired;
    private volatile int mMinGCSleepTime;
    private volatile int mTargetDirtyRatio;
    private volatile boolean mNeedGC;

    private volatile boolean mPassedLifetimeThresh;
@@ -2712,6 +2718,10 @@ class StorageManagerService extends IStorageManager.Stub
                "low_battery_level", DEFAULT_LOW_BATTERY_LEVEL);
            mChargingRequired = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                "charging_required", DEFAULT_CHARGING_REQUIRED);
            mMinGCSleepTime = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                "min_gc_sleeptime", DEFAULT_MIN_GC_SLEEPTIME);
            mTargetDirtyRatio = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
                "target_dirty_ratio", DEFAULT_TARGET_DIRTY_RATIO);

            // If we use the smart idle maintenance, we need to turn off GC in the traditional idle
            // maintenance to avoid the conflict
@@ -2829,13 +2839,6 @@ class StorageManagerService extends IStorageManager.Stub
        enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);

        try {
            // Block based checkpoint process runs fstrim. So, if checkpoint is in progress
            // (first boot after OTA), We skip the smart idle maintenance
            if (!needsCheckpoint() || !supportsBlockCheckpoint()) {
                if (!refreshLifetimeConstraint() || !checkChargeStatus()) {
                    return;
                }

            int latestWrite = mVold.getWriteAmount();
            if (latestWrite == -1) {
                Slog.w(TAG, "Failed to get storage write record");
@@ -2843,6 +2846,14 @@ class StorageManagerService extends IStorageManager.Stub
            }

            updateStorageWriteRecords(latestWrite);

            // Block based checkpoint process runs fstrim. So, if checkpoint is in progress
            // (first boot after OTA), We skip the smart idle maintenance
            if (!needsCheckpoint() || !supportsBlockCheckpoint()) {
                if (!refreshLifetimeConstraint() || !checkChargeStatus()) {
                    return;
                }

                int avgWriteAmount = getAverageWriteAmount();

                Slog.i(TAG, "Set smart idle maintenance: " + "latest write amount: " +
@@ -2850,9 +2861,12 @@ class StorageManagerService extends IStorageManager.Stub
                            ", min segment threshold: " + mMinSegmentsThreshold +
                            ", dirty reclaim rate: " + mDirtyReclaimRate +
                            ", segment reclaim weight: " + mSegmentReclaimWeight +
                            ", period: " + sSmartIdleMaintPeriod);
                            ", period(min): " + sSmartIdleMaintPeriod +
                            ", min gc sleep time(ms): " + mMinGCSleepTime +
                            ", target dirty ratio: " + mTargetDirtyRatio);
                mVold.setGCUrgentPace(avgWriteAmount, mMinSegmentsThreshold, mDirtyReclaimRate,
                                      mSegmentReclaimWeight, sSmartIdleMaintPeriod);
                                      mSegmentReclaimWeight, sSmartIdleMaintPeriod,
                                      mMinGCSleepTime, mTargetDirtyRatio);
            } else {
                Slog.i(TAG, "Skipping smart idle maintenance - block based checkpoint in progress");
            }