Переглянути джерело

Tweaks to correct background/foreground mode split. Increased epoch durations m=2

Sajin 1 рік тому
батько
коміт
e9ffbac9c0
2 змінених файлів з 71 додано та 30 видалено
  1. 63 24
      App/start.cpp
  2. 8 6
      run_experiments.py

+ 63 - 24
App/start.cpp

@@ -17,16 +17,34 @@ bool FOREGROUND_PRECOMPUTE = true;
 
 #define CEILDIV(x,y) (((x)+(y)-1)/(y))
 
+// #define DEBUG_PUB_TIMES
+
 class Epoch {
     NetIO &netio;
     uint32_t epoch_num;
     std::mutex m;
     std::condition_variable cv;
     bool epoch_complete;
+    #ifdef DEBUG_PUB_TIMES
+    unsigned long lt = 0;
+    #endif
 
     void round_cb(uint32_t round_num) {
         if (round_num) {
             printf("Round %u complete\n", round_num);
+
+            #ifdef DEBUG_PUB_TIMES
+            struct timespec tp;
+            clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+            unsigned long time = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+            if(lt == 0) {
+                printf("Time now = %lu\n", time);
+                lt = time;
+            } else {
+                printf("Time since last round_cb = %lu.%lu\n", (time-lt)/1000000, (time-lt)%1000000);
+            }
+            #endif
+
             boost::asio::post(netio.io_context(), [this]{
                 proceed();
             });
@@ -37,6 +55,15 @@ class Epoch {
                 epoch_complete = true;
             }
 
+
+            #ifdef DEBUG_PUB_TIMES
+                struct timespec tp;
+                clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+                unsigned long time = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+                printf("Epoch end. Time since last round_cb = %lu.%lu\n", (time-lt)/1000000, (time-lt)%1000000);
+                lt = 0;
+            #endif
+
             const NodeConfig &my_conf = netio.myconfig();
             if(my_conf.roles & ROLE_STORAGE) {
                 boost::asio::post(netio.io_context(), [this]{
@@ -130,12 +157,35 @@ static void epoch(NetIO &netio, char **args) {
     // Launch threads to refill the precomputed Waksman networks we
     // used, but just let them run in the background.
     size_t num_sizes = ecall_precompute_sort(-1);
+    for (int i=0;i<int(num_sizes);++i) {
+        boost::thread t([i] {
+            ecall_precompute_sort(i);
+        });
+        t.detach();
+    }
+    ++epoch_num;
+}
+
+static unsigned long epoch_clients(NetIO &netio) {
+    static uint32_t epoch_num = 1;
+    Epoch epoch(netio, epoch_num);
+    epoch.proceed();
+    epoch.wait();
+
+    struct timespec tp;
+    clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+    unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+    printf("Epoch end time = %lu\n", end);
+
+    // Launch threads to refill the precomputed Waksman networks we used.
+    size_t num_sizes = ecall_precompute_sort(-1);
     std::vector<boost::thread> ts;
     for (int i=0;i<int(num_sizes);++i) {
         if(!FOREGROUND_PRECOMPUTE) {
             boost::thread t([i] {
                 ecall_precompute_sort(i);
             });
+            t.detach();
         }
         else {
             ts.emplace_back([i] {
@@ -149,33 +199,15 @@ static void epoch(NetIO &netio, char **args) {
         }
     }
     ++epoch_num;
-}
-
-static void epoch_clients(NetIO &netio) {
-    static uint32_t epoch_num = 1;
-    Epoch epoch(netio, epoch_num);
-    epoch.proceed();
-    epoch.wait();
-    // Launch threads to refill the precomputed Waksman networks we
-    // used, but just let them run in the background.
-    size_t num_sizes = ecall_precompute_sort(-1);
-    for (int i=0;i<int(num_sizes);++i) {
-        boost::thread t([i] {
-            ecall_precompute_sort(i);
-        });
-        t.detach();
-    }
-    ++epoch_num;
+    return end;
 }
 
 static void route_clients_test(NetIO &netio)
 {
 
     // Default epoch_interval is 5 sec
-    size_t epoch_interval = epoch_duration * 1000000;
+    unsigned long epoch_interval = epoch_duration * 1000000;
     printf("Epoch duration = %d\n", epoch_duration);
-    // Sleep one epoch_interval for clients to connect
-    usleep(epoch_interval);
 
     // Precompute some WaksmanNetworks
     size_t num_sizes = ecall_precompute_sort(-2);
@@ -198,25 +230,32 @@ static void route_clients_test(NetIO &netio)
         t.join();
     }
 
+    // Sleep one epoch_interval for clients to connect
+    usleep((useconds_t) epoch_interval);
+
     // Run epoch
     for (int i=1; i<=num_epochs; ++i) {
         struct timespec tp;
         clock_gettime(CLOCK_REALTIME_COARSE, &tp);
         unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+        printf("Epoch start time = %lu\n", start);
 
-        epoch_clients(netio);
+        unsigned long end = epoch_clients(netio);
 
         clock_gettime(CLOCK_REALTIME_COARSE, &tp);
-        unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
-        unsigned long diff = end - start;
+        //unsigned long end_post_pc = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+        //unsigned long diff_post_pc = end_post_pc - start;
+        //printf("Epoch end_post_pc time = %lu\n", end_post_pc);
+        //printf("Epoch diff_post_pc time = %lu\n", diff_post_pc);
 
+        unsigned long diff = end - start;
         printf("client_count = %ld\n", client_count);
         printf("bytes_sent = %ld\n", netio.reset_bytes_sent());
         printf("Epoch %d time: %lu.%06lu s\n", i, diff/1000000, diff%1000000);
 
         // Sleep for the rest of the epoch interval
         if (diff < epoch_interval) {
-            usleep(epoch_interval - (useconds_t) diff);
+            usleep((useconds_t) epoch_interval - (useconds_t) diff);
         }
 
     }

+ 8 - 6
run_experiments.py

@@ -25,9 +25,9 @@ from logs_to_csv import parse_output_logs
 # CONFIGS TO SET:
 
 MANIFEST_FILE = "App/manifest.yaml"
-LOG_FOLDER = "190824_Fig8/"
+LOG_FOLDER = "Test/"
 
-NUM_EPOCHS = 5
+NUM_EPOCHS = 10
 PRIVATE_ROUTE = False
 PRIV_OUT = 1
 PRIV_IN = 1
@@ -83,7 +83,9 @@ def epoch_time_estimate(n, m, t, b):
 
     # Client time:
     # Takes about 30 sec for handling 2^20 clients
-    etime_client = 3 * math.ceil(clients_per_server/100000)
+    etime_client = 3 * math.ceil(clients_per_server/50000)
+    if(m==2):
+        etime_client += 60
 
     etime = etime_base + etime_precompute + etime_route_compute + etime_client
     return int(etime)
@@ -94,9 +96,9 @@ if __name__ == "__main__":
     if not os.path.exists(LOG_FOLDER):
         os.mkdir(LOG_FOLDER)
 
-    DIAGNOSTIC_FOLDER = LOG_FOLDER + "diagnostic/"
-    if not os.path.exists(DIAGNOSTIC_FOLDER):
-        os.mkdir(DIAGNOSTIC_FOLDER)
+    #DIAGNOSTIC_FOLDER = LOG_FOLDER + "diagnostic/"
+    #if not os.path.exists(DIAGNOSTIC_FOLDER):
+    #    os.mkdir(DIAGNOSTIC_FOLDER)
 
     for t in T:
         b = B