From 7b5eace47594ba81eaf96658fd98b10a52c49376 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 14 May 2013 12:27:04 -0700 Subject: [PATCH] volunteer data archival simulator: a few tweaks --- vda/Makefile.am | 2 +- vda/des.h | 3 +++ vda/ssim.cpp | 23 ++++++++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/vda/Makefile.am b/vda/Makefile.am index 473e53fa64..f5f9283d48 100644 --- a/vda/Makefile.am +++ b/vda/Makefile.am @@ -11,5 +11,5 @@ vda_LDADD = $(SERVERLIBS) vdad_SOURCES = vdad.cpp vda_lib.cpp vda_lib2.cpp vda_policy.cpp stats.cpp vdad_LDADD = $(SERVERLIBS) -ssim_SOURCES = ssim.cpp vda_lib.cpp vda_policy.cpp stats.cpp +ssim_SOURCES = ssim.cpp vda_lib.cpp vda_policy.cpp stats.cpp des.h ssim_LDADD = $(SERVERLIBS) diff --git a/vda/des.h b/vda/des.h index 61373b93ae..921567837b 100644 --- a/vda/des.h +++ b/vda/des.h @@ -42,6 +42,7 @@ inline bool compare(EVENT* e1, EVENT* e2) { struct SIMULATOR { vector events; double now; + bool done; // add an event // @@ -70,6 +71,7 @@ struct SIMULATOR { // run the simulator for the given time period // void simulate(double dur) { + done = false; while (events.size()) { EVENT* e = events.front(); pop_heap(events.begin(), events.end(), compare); @@ -77,6 +79,7 @@ struct SIMULATOR { now = e->t; if (now > dur) break; e->handle(); + if (done) break; } } }; diff --git a/vda/ssim.cpp b/vda/ssim.cpp index 06cc0b3eb5..404302285d 100644 --- a/vda/ssim.cpp +++ b/vda/ssim.cpp @@ -59,6 +59,9 @@ using std::set; bool log_actions = false; +double min_failures_time[100]; +int min_min_failures = 100; + // We simulate policies based on coding and replication. // // Coding means that data is divided into M = N+K units, @@ -245,7 +248,10 @@ struct SIM_FILE : VDA_FILE_AUX, EVENT { meta_chunk->recovery_plan(); if (meta_chunk->status == UNRECOVERABLE) { printf("FILE IS LOST!!\n"); - exit(0); + sim.done = true; + min_min_failures = 0; + min_failures_time[0] = sim.now; + return; } if (debug_status) { printf("decide_reconstruct():\n"); @@ -260,10 +266,15 @@ struct SIM_FILE : VDA_FILE_AUX, EVENT { } meta_chunk->recovery_action(sim.now); meta_chunk->compute_min_failures(); - printf(" Min failures: %d\n", meta_chunk->min_failures); + int mf = meta_chunk->min_failures; + printf(" Min failures: %d\n", mf); fault_tolerance.sample( - meta_chunk->min_failures-1, collecting_stats(), sim.now + mf-1, collecting_stats(), sim.now ); + while (mf < min_min_failures) { + min_min_failures--; + min_failures_time[min_min_failures] = sim.now; + } } void print_stats(double now) { @@ -628,4 +639,10 @@ int main(int argc, char** argv) { printf("%s: simulation finished\n", now_str()); dfile->print_stats(sim.now); + + FILE* f = fopen("mft.dat", "w"); + for (int i=0; i<=policy.max_ft; i++) { + fprintf(f, "%d %f\n", i, min_failures_time[i]); + } + fclose(f); }