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

Commit 07b38fe4 authored by Piyush Mehrotra's avatar Piyush Mehrotra Committed by Android (Google) Code Review
Browse files

Merge "Set buffer size to match Linux pipe internal buffer when...

Merge "Set buffer size to match Linux pipe internal buffer when reading/writing from/to pipes in Backup/Restore flow." into main
parents f3024bbc a10db39e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ public class FullBackup {
                Log.e(TAG, "Unable to create/open file " + outFile.getPath(), e);
            }

            byte[] buffer = new byte[32 * 1024];
            byte[] buffer = new byte[64 * 1024];
            final long origSize = size;
            FileInputStream in = new FileInputStream(data.getFileDescriptor());
            while (size > 0) {
+10 −1
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@ license {
    ],
}

cc_aconfig_library {
    name: "backup_flags_cc_lib",
    host_supported: true,
    aconfig_declarations: "backup_flags",
}

cc_defaults {
    name: "libandroidfw_defaults",
    cpp_std: "gnu++2b",
@@ -115,7 +121,10 @@ cc_library {
                "libutils",
                "libz",
            ],
            static_libs: ["libziparchive_for_incfs"],
            static_libs: [
                "libziparchive_for_incfs",
                "backup_flags_cc_lib",
            ],
            static: {
                enabled: false,
            },
+7 −3
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@
#include <utils/KeyedVector.h>
#include <utils/String8.h>

#include <com_android_server_backup.h>
namespace backup_flags = com::android::server::backup;

namespace android {

#define MAGIC0 0x70616e53 // Snap
@@ -214,7 +217,7 @@ write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8&
{
    LOGP("write_update_file %s (%s) : mode 0%o\n", realFilename, key.c_str(), mode);

    const int bufsize = 4*1024;
    const int bufsize = backup_flags::enable_max_size_writes_to_pipes() ? (64*1024) : (4*1024);
    int err;
    int amt;
    int fileSize;
@@ -550,7 +553,8 @@ int write_tarfile(const String8& packageName, const String8& domain,
    }

    // read/write up to this much at a time.
    const size_t BUFSIZE = 32 * 1024;
    const size_t BUFSIZE = backup_flags::enable_max_size_writes_to_pipes() ? (64*1024) : (32*1024);

    char* buf = (char *)calloc(1,BUFSIZE);
    const size_t PAXHEADER_OFFSET = 512;
    const size_t PAXHEADER_SIZE = 512;
@@ -726,7 +730,7 @@ done:



#define RESTORE_BUF_SIZE (8*1024)
const size_t RESTORE_BUF_SIZE = backup_flags::enable_max_size_writes_to_pipes() ? 64*1024 : 8*1024;

RestoreHelperBase::RestoreHelperBase()
{
+8 −0
Original line number Diff line number Diff line
@@ -8,3 +8,11 @@ flag {
    bug: "308401499"
    is_fixed_read_only: true
}

flag {
    name: "enable_max_size_writes_to_pipes"
    namespace: "onboarding"
    description: "Enables the write buffer to pipes to be of maximum size."
    bug: "265976737"
    is_fixed_read_only: true
}
 No newline at end of file
+6 −3
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ import android.util.Slog;

import com.android.server.EventLogTags;
import com.android.server.backup.BackupAgentTimeoutParameters;
import com.android.server.backup.BackupAndRestoreFeatureFlags;
import com.android.server.backup.BackupRestoreTask;
import com.android.server.backup.Flags;
import com.android.server.backup.FullBackupJob;
import com.android.server.backup.OperationStorage;
import com.android.server.backup.OperationStorage.OpState;
@@ -390,8 +390,11 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba

            // Set up to send data to the transport
            final int N = mPackages.size();
            final int chunkSizeInBytes =
                    BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes();
            int chunkSizeInBytes = 8 * 1024; // 8KB
            if (Flags.enableMaxSizeWritesToPipes()) {
                // Linux pipe capacity (buffer size) is 16 pages where each page is 4KB
                chunkSizeInBytes = 64 * 1024; // 64KB
            }
            final byte[] buffer = new byte[chunkSizeInBytes];
            for (int i = 0; i < N; i++) {
                mBackupRunner = null;
Loading