Abort long-running benchmarks, report progress.

A typical storage device finishes the benchmark in under 10 seconds,
but some extremely slow devices can take minutes, resulting in a
confusing UX that looks like we've frozen.  Even worse, we keep
churning through all that I/O even though we know the device will
blow past our user-warning threshold.

So periodically check if we've timed out, and also use that to report
progress up into the Settings UI.

Test: manual
Bug: 62201209, 65639764, 67055204
Change-Id: I321397bcff230976f034cede0947d4a5a1f3e8a7
gugelfrei
Jeff Sharkey 7 years ago
parent b64933a502
commit cbcb2926b2

@ -18,8 +18,10 @@
#include "BenchmarkGen.h"
#include "VolumeManager.h"
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <cutils/iosched_policy.h>
#include <hardware_legacy/power.h>
#include <private/android_filesystem_config.h>
@ -30,18 +32,65 @@
#include <sys/resource.h>
#include <unistd.h>
#define ENABLE_DROP_CACHES 1
using android::base::ReadFileToString;
using android::base::WriteStringToFile;
namespace android {
namespace vold {
// Benchmark currently uses chdir(), which means we can only
// safely run one at a time.
static std::mutex kBenchmarkLock;
static const char* kWakeLock = "Benchmark";
// Reasonable cards are able to complete the create/run stages
// in under 20 seconds.
constexpr auto kTimeout = 20s;
// RAII class for boosting device performance during benchmarks.
class PerformanceBoost {
private:
int orig_prio;
int orig_ioprio;
IoSchedClass orig_clazz;
public:
PerformanceBoost() {
errno = 0;
orig_prio = getpriority(PRIO_PROCESS, 0);
if (errno != 0) {
PLOG(WARNING) << "Failed to getpriority";
orig_prio = 0;
}
if (setpriority(PRIO_PROCESS, 0, -10) != 0) {
PLOG(WARNING) << "Failed to setpriority";
}
if (android_get_ioprio(0, &orig_clazz, &orig_ioprio)) {
PLOG(WARNING) << "Failed to android_get_ioprio";
orig_ioprio = 0;
orig_clazz = IoSchedClass_NONE;
}
if (android_set_ioprio(0, IoSchedClass_RT, 0)) {
PLOG(WARNING) << "Failed to android_set_ioprio";
}
}
~PerformanceBoost() {
if (android_set_ioprio(0, orig_clazz, orig_ioprio)) {
PLOG(WARNING) << "Failed to android_set_ioprio";
}
if (setpriority(PRIO_PROCESS, 0, orig_prio) != 0) {
PLOG(WARNING) << "Failed to setpriority";
}
}
};
static status_t benchmarkInternal(const std::string& rootPath,
const android::sp<android::os::IVoldTaskListener>& listener,
android::os::PersistableBundle* extras) {
status_t res = 0;
auto path = rootPath;
path += "/misc";
if (android::vold::PrepareDir(path, 01771, AID_SYSTEM, AID_MISC)) {
@ -56,28 +105,6 @@ static status_t benchmarkInternal(const std::string& rootPath,
return -1;
}
errno = 0;
int orig_prio = getpriority(PRIO_PROCESS, 0);
if (errno != 0) {
PLOG(ERROR) << "Failed to getpriority";
return -1;
}
if (setpriority(PRIO_PROCESS, 0, -10) != 0) {
PLOG(ERROR) << "Failed to setpriority";
return -1;
}
IoSchedClass orig_clazz = IoSchedClass_NONE;
int orig_ioprio = 0;
if (android_get_ioprio(0, &orig_clazz, &orig_ioprio)) {
PLOG(ERROR) << "Failed to android_get_ioprio";
return -1;
}
if (android_set_ioprio(0, IoSchedClass_RT, 0)) {
PLOG(ERROR) << "Failed to android_set_ioprio";
return -1;
}
char orig_cwd[PATH_MAX];
if (getcwd(orig_cwd, PATH_MAX) == NULL) {
PLOG(ERROR) << "Failed getcwd";
@ -90,66 +117,76 @@ static status_t benchmarkInternal(const std::string& rootPath,
sync();
LOG(INFO) << "Benchmarking " << path;
nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
extras->putString(String16("path"), String16(path.c_str()));
extras->putString(String16("ident"), String16(BenchmarkIdent().c_str()));
BenchmarkCreate();
// Always create
{
android::base::Timer timer;
LOG(INFO) << "Creating " << path;
res |= BenchmarkCreate([&](int progress) -> bool {
if (listener) {
listener->onStatus(progress, *extras);
}
return (timer.duration() < kTimeout);
});
sync();
nsecs_t create = systemTime(SYSTEM_TIME_BOOTTIME);
if (res == OK) extras->putLong(String16("create"), timer.duration().count());
}
#if ENABLE_DROP_CACHES
// Only drop when we haven't aborted
if (res == OK) {
android::base::Timer timer;
LOG(VERBOSE) << "Before drop_caches";
if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
PLOG(ERROR) << "Failed to drop_caches";
res = -1;
}
LOG(VERBOSE) << "After drop_caches";
#endif
nsecs_t drop = systemTime(SYSTEM_TIME_BOOTTIME);
sync();
if (res == OK) extras->putLong(String16("drop"), timer.duration().count());
}
BenchmarkRun();
// Only run when we haven't aborted
if (res == OK) {
android::base::Timer timer;
LOG(INFO) << "Running " << path;
res |= BenchmarkRun([&](int progress) -> bool {
if (listener) {
listener->onStatus(progress, *extras);
}
return (timer.duration() < kTimeout);
});
sync();
nsecs_t run = systemTime(SYSTEM_TIME_BOOTTIME);
if (res == OK) extras->putLong(String16("run"), timer.duration().count());
}
BenchmarkDestroy();
// Always destroy
{
android::base::Timer timer;
LOG(INFO) << "Destroying " << path;
res |= BenchmarkDestroy();
sync();
nsecs_t destroy = systemTime(SYSTEM_TIME_BOOTTIME);
if (res == OK) extras->putLong(String16("destroy"), timer.duration().count());
}
if (chdir(orig_cwd) != 0) {
PLOG(ERROR) << "Failed to chdir";
return -1;
}
if (android_set_ioprio(0, orig_clazz, orig_ioprio)) {
PLOG(ERROR) << "Failed to android_set_ioprio";
}
if (setpriority(PRIO_PROCESS, 0, orig_prio) != 0) {
PLOG(ERROR) << "Failed to setpriority";
}
nsecs_t create_d = create - start;
nsecs_t drop_d = drop - create;
nsecs_t run_d = run - drop;
nsecs_t destroy_d = destroy - run;
LOG(INFO) << "create took " << nanoseconds_to_milliseconds(create_d) << "ms";
LOG(INFO) << "drop took " << nanoseconds_to_milliseconds(drop_d) << "ms";
LOG(INFO) << "run took " << nanoseconds_to_milliseconds(run_d) << "ms";
LOG(INFO) << "destroy took " << nanoseconds_to_milliseconds(destroy_d) << "ms";
extras->putString(String16("path"), String16(path.c_str()));
extras->putString(String16("ident"), String16(BenchmarkIdent().c_str()));
extras->putLong(String16("create"), create_d);
extras->putLong(String16("drop"), drop_d);
extras->putLong(String16("run"), run_d);
extras->putLong(String16("destroy"), destroy_d);
return 0;
return res;
}
void Benchmark(const std::string& path,
const android::sp<android::os::IVoldTaskListener>& listener) {
std::lock_guard<std::mutex> lock(kBenchmarkLock);
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
PerformanceBoost boost;
android::os::PersistableBundle extras;
status_t res = benchmarkInternal(path, &extras);
status_t res = benchmarkInternal(path, listener, &extras);
if (listener) {
listener->onFinished(res, extras);
}

@ -29,6 +29,7 @@
#include <fcntl.h>
#include <algorithm>
#include <functional>
#include <string>
#include <Utils.h>
@ -36,7 +37,8 @@
namespace android {
namespace vold {
static status_t BenchmarkRun() {
static status_t BenchmarkRun(std::function<bool(int)> checkpoint) {
char* buf = (char*) malloc(1048576);
int t3433f17 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
@ -277,6 +279,7 @@ TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4096, 57012224)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f18, buf, 1048576, 0)); // mmap2
close(t3455f18);
t3455f18 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
if (!checkpoint(52)) return -1;
TEMP_FAILURE_RETRY(read(t3455f18, buf, 4));
TEMP_FAILURE_RETRY(lseek(t3455f18, 0, SEEK_SET));
TEMP_FAILURE_RETRY(lseek(t3455f18, 0, SEEK_END));
@ -533,6 +536,7 @@ TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 184320));
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 69632));
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 81920));
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 90112));
if (!checkpoint(55)) return -1;
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 102400));
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 114688));
TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 131072));
@ -776,6 +780,7 @@ TEMP_FAILURE_RETRY(pread(t3455f17, buf, 31, 32760741));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2073, 32759808)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32273035));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 37, 32273065));
if (!checkpoint(58)) return -1;
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1692, 32272384)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34612102));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 38, 34612132));
@ -1001,6 +1006,7 @@ TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35474138));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 43, 35474168));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3682, 35471360)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34394223));
if (!checkpoint(61)) return -1;
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 41, 34394253));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 481, 34394112)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32648704));
@ -1223,6 +1229,7 @@ TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 8724));
TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 12820));
TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 12824));
TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 12828));
if (!checkpoint(64)) return -1;
TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 16924));
TEMP_FAILURE_RETRY(pread(t3499f40, buf, 8, 17408));
TEMP_FAILURE_RETRY(fdatasync(t3499f40));
@ -1452,6 +1459,7 @@ t3455f50 = TEMP_FAILURE_RETRY(open("file36", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
TEMP_FAILURE_RETRY(pread(t3455f50, buf, 52, 0));
TEMP_FAILURE_RETRY(pread(t3455f50, buf, 4096, 0)); // mmap2
TEMP_FAILURE_RETRY(pread(t3455f50, buf, 187587, 0)); // mmap2
if (!checkpoint(67)) return -1;
TEMP_FAILURE_RETRY(pread(t3455f50, buf, 4128, 188416)); // mmap2
close(t3455f50);
t3455f50 = TEMP_FAILURE_RETRY(open("file24", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@ -1696,6 +1704,7 @@ TEMP_FAILURE_RETRY(read(t3532f53, buf, 16384));
close(t3519f43);
close(t3532f53);
int t3492f57 = TEMP_FAILURE_RETRY(open("file54", O_RDONLY|O_LARGEFILE));
if (!checkpoint(70)) return -1;
TEMP_FAILURE_RETRY(read(t3492f57, buf, 39938));
close(t3492f57);
int t3492f61 = TEMP_FAILURE_RETRY(open("file55", O_RDONLY|O_LARGEFILE));
@ -1928,6 +1937,7 @@ TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 4612));
if (!checkpoint(73)) return -1;
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 4616));
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 4620));
TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 8716));
@ -2159,6 +2169,7 @@ TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34267550));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 49, 34267580));
close(t3499f73);
TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 12, 0));
if (!checkpoint(76)) return -1;
close(t3532f68);
TEMP_FAILURE_RETRY(fdatasync(t3499f66));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 722, 34267136)); // mmap2
@ -2396,6 +2407,7 @@ close(t3519f67);
t3519f67 = TEMP_FAILURE_RETRY(open("file123", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
close(t3519f67);
t3519f67 = TEMP_FAILURE_RETRY(open("file124", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
if (!checkpoint(79)) return -1;
close(t3519f67);
t3519f67 = TEMP_FAILURE_RETRY(open("file125", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
close(t3519f67);
@ -2620,6 +2632,7 @@ TEMP_FAILURE_RETRY(fdatasync(t3499f90));
TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 28, 0));
TEMP_FAILURE_RETRY(fdatasync(t3499f90));
close(t3499f90);
if (!checkpoint(82)) return -1;
t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
close(t3499f90);
@ -2838,6 +2851,7 @@ TEMP_FAILURE_RETRY(pread(t3505f66, buf, 1, 0));
close(t3505f66);
t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 512, 0));
if (!checkpoint(85)) return -1;
TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 512));
TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4096, 516));
TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 4612));
@ -3066,6 +3080,7 @@ TEMP_FAILURE_RETRY(pread(t3505f96, buf, 16, 24));
t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
close(t3499f90);
if (!checkpoint(88)) return -1;
t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
@ -3278,6 +3293,7 @@ TEMP_FAILURE_RETRY(fdatasync(t3499f100));
close(t3499f100);
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35636928));
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 60, 35636958));
if (!checkpoint(91)) return -1;
TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2062, 35635200)); // mmap2
t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
TEMP_FAILURE_RETRY(pread(t3499f84, buf, 1, 0));
@ -3514,6 +3530,7 @@ TEMP_FAILURE_RETRY(pread(t3499f26, buf, 8, 13312));
TEMP_FAILURE_RETRY(fdatasync(t3499f26));
t3499f97 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
TEMP_FAILURE_RETRY(fdatasync(t3499f97));
if (!checkpoint(93)) return -1;
close(t3499f97);
TEMP_FAILURE_RETRY(pwrite(t3499f26, buf, 12, 0));
TEMP_FAILURE_RETRY(fdatasync(t3499f26));
@ -3760,6 +3777,7 @@ close(t3533f90);
t3526f90 = TEMP_FAILURE_RETRY(open("file162", O_RDONLY|O_LARGEFILE));
TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
if (!checkpoint(96)) return -1;
close(t3526f90);
t3526f90 = TEMP_FAILURE_RETRY(open("file163", O_RDONLY|O_LARGEFILE));
TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
@ -3994,6 +4012,7 @@ TEMP_FAILURE_RETRY(pread(t3597f110, buf, 1, 0));
close(t3597f110);
TEMP_FAILURE_RETRY(pread(t3597f108, buf, 16, 24));
close(t3540f109);
if (!checkpoint(99)) return -1;
TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 16384));
TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 12288));
t3597f109 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@ -4054,7 +4073,7 @@ static status_t CreateFile(const char* name, int len) {
return OK;
}
static status_t BenchmarkCreate() {
static status_t BenchmarkCreate(std::function<bool(int)> checkpoint) {
status_t res = 0;
res |= CreateFile("stub", 0);
@ -4069,6 +4088,7 @@ res |= CreateFile("file175", 9);
res |= CreateFile("file76", 0);
res |= CreateFile("file140", 4042);
res |= CreateFile("file80", 0);
if (!checkpoint(3)) return -1;
res |= CreateFile("file139", 49152);
res |= CreateFile("file50", 32768);
res |= CreateFile("file179", 4000);
@ -4081,6 +4101,7 @@ res |= CreateFile("file53", 32768);
res |= CreateFile("file72", 0);
res |= CreateFile("file55", 16384);
res |= CreateFile("file54", 39938);
if (!checkpoint(6)) return -1;
res |= CreateFile("file129", 3974);
res |= CreateFile("file107", 0);
res |= CreateFile("file95", 0);
@ -4093,6 +4114,7 @@ res |= CreateFile("file89", 0);
res |= CreateFile("file40", 4172);
res |= CreateFile("file20", 1);
res |= CreateFile("file151", 499712);
if (!checkpoint(10)) return -1;
res |= CreateFile("file106", 0);
res |= CreateFile("file159", 9);
res |= CreateFile("file47", 32768);
@ -4105,6 +4127,7 @@ res |= CreateFile("file172", 9);
res |= CreateFile("file148", 3461);
res |= CreateFile("file7", 794976);
res |= CreateFile("file68", 32768);
if (!checkpoint(13)) return -1;
res |= CreateFile("file109", 0);
res |= CreateFile("file142", 5057);
res |= CreateFile("file147", 3834);
@ -4117,6 +4140,7 @@ res |= CreateFile("file105", 0);
res |= CreateFile("file79", 0);
res |= CreateFile("file65", 32768);
res |= CreateFile("file135", 21257);
if (!checkpoint(16)) return -1;
res |= CreateFile("file124", 0);
res |= CreateFile("file87", 0);
res |= CreateFile("file64", 49152);
@ -4129,6 +4153,7 @@ res |= CreateFile("file178", 1);
res |= CreateFile("file163", 32768);
res |= CreateFile("file67", 32768);
res |= CreateFile("file155", 21512);
if (!checkpoint(20)) return -1;
res |= CreateFile("file156", 9);
res |= CreateFile("file23", 28700);
res |= CreateFile("file61", 32768);
@ -4141,6 +4166,7 @@ res |= CreateFile("file24", 94220);
res |= CreateFile("file57", 32768);
res |= CreateFile("file104", 0);
res |= CreateFile("file113", 0);
if (!checkpoint(23)) return -1;
res |= CreateFile("file99", 0);
res |= CreateFile("file120", 0);
res |= CreateFile("file154", 73728);
@ -4153,6 +4179,7 @@ res |= CreateFile("file96", 0);
res |= CreateFile("file91", 0);
res |= CreateFile("file158", 1);
res |= CreateFile("file174", 1);
if (!checkpoint(26)) return -1;
res |= CreateFile("file48", 32768);
res |= CreateFile("file33", 32566);
res |= CreateFile("file83", 0);
@ -4165,6 +4192,7 @@ res |= CreateFile("file16", 31392);
res |= CreateFile("file164", 32768);
res |= CreateFile("file36", 192544);
res |= CreateFile("file6", 4636);
if (!checkpoint(30)) return -1;
res |= CreateFile("file10", 16484);
res |= CreateFile("file150", 10056);
res |= CreateFile("file62", 32768);
@ -4177,6 +4205,7 @@ res |= CreateFile("file100", 0);
res |= CreateFile("file103", 0);
res |= CreateFile("file26", 28676);
res |= CreateFile("file46", 32768);
if (!checkpoint(33)) return -1;
res |= CreateFile("file60", 32768);
res |= CreateFile("file162", 32768);
res |= CreateFile("file25", 32872);
@ -4189,6 +4218,7 @@ res |= CreateFile("file51", 32768);
res |= CreateFile("file37", 159752);
res |= CreateFile("file73", 0);
res |= CreateFile("file71", 32768);
if (!checkpoint(36)) return -1;
res |= CreateFile("file98", 0);
res |= CreateFile("file74", 0);
res |= CreateFile("file93", 0);
@ -4201,6 +4231,7 @@ res |= CreateFile("file136", 4199);
res |= CreateFile("file132", 23233);
res |= CreateFile("file92", 0);
res |= CreateFile("file11", 0);
if (!checkpoint(40)) return -1;
res |= CreateFile("file86", 0);
res |= CreateFile("file22", 0);
res |= CreateFile("file56", 16384);
@ -4213,6 +4244,7 @@ res |= CreateFile("file63", 49152);
res |= CreateFile("file116", 0);
res |= CreateFile("file29", 1035);
res |= CreateFile("file35", 118788);
if (!checkpoint(43)) return -1;
res |= CreateFile("file170", 24576);
res |= CreateFile("file30", 98304);
res |= CreateFile("file14", 0);
@ -4225,6 +4257,7 @@ res |= CreateFile("file18", 17416);
res |= CreateFile("file134", 15056);
res |= CreateFile("file31", 25608);
res |= CreateFile("file97", 0);
if (!checkpoint(46)) return -1;
res |= CreateFile("file84", 0);
res |= CreateFile("file114", 0);
res |= CreateFile("file88", 0);
@ -4237,6 +4270,7 @@ res |= CreateFile("file133", 13332);
res |= CreateFile("file169", 11354);
res |= CreateFile("file166", 0);
res |= CreateFile("file49", 32768);
if (!checkpoint(50)) return -1;
res |= CreateFile("file177", 61440);
return res;

@ -157,6 +157,7 @@ with open("BenchmarkGen.h", 'w') as bench:
#include <fcntl.h>
#include <algorithm>
#include <functional>
#include <string>
#include <Utils.h>
@ -164,7 +165,8 @@ with open("BenchmarkGen.h", 'w') as bench:
namespace android {
namespace vold {
static status_t BenchmarkRun() {
static status_t BenchmarkRun(std::function<bool(int)> checkpoint) {
"""
print >>bench, "char* buf = (char*) malloc(%d);" % (bufsize)
@ -175,7 +177,13 @@ static status_t BenchmarkRun() {
events = sorted(events, key=lambda e: e.time)
active = set()
defined = set()
i = 0
total = len(events)
for e in events:
i += 1
if i % 256 == 0:
print >>bench, "if (!checkpoint(%d)) return -1;" % (50 + ((i * 50) / total))
if e.call == "openat":
fd, f, handle = extract_file(e, e.ret)
if f:
@ -297,11 +305,17 @@ static status_t CreateFile(const char* name, int len) {
return OK;
}
static status_t BenchmarkCreate() {
static status_t BenchmarkCreate(std::function<bool(int)> checkpoint) {
status_t res = 0;
res |= CreateFile("stub", 0);
"""
i = 0
total = len(files.values())
for f in files.values():
i += 1
if i % 12 == 0:
print >>bench, "if (!checkpoint(%d)) return -1;" % ((i * 50) / total)
print >>bench, 'res |= CreateFile("file%s", %d);' % (f.ident, f.size)
print >>bench, """

Loading…
Cancel
Save