浏览代码

Some code to track heap usage

Ian Goldberg 1 年之前
父节点
当前提交
17400d15bc
共有 3 个文件被更改,包括 47 次插入3 次删除
  1. 15 3
      Enclave/config.cpp
  2. 6 0
      Enclave/config.hpp
  3. 26 0
      Enclave/route.cpp

+ 15 - 3
Enclave/config.cpp

@@ -54,12 +54,14 @@ static int generateMasterKeys(sgx_aes_gcm_128bit_key_t master_secret,
     return 1;
 }
 
-
 bool ecall_config_load(threadid_t nthreads,
     EnclaveAPIParams *apiparams,
     EnclaveAPINodeConfig *apinodeconfigs,
     nodenum_t num_nodes, nodenum_t my_node_num)
 {
+#ifdef TRACK_HEAP_USAGE
+    printf("ecall_config_load begin heap %u\n", g_peak_heap_used);
+#endif
     g_teems_config.nthreads = nthreads;
     g_teems_config.num_nodes = num_nodes;
     g_teems_config.num_ingestion_nodes = 0;
@@ -171,11 +173,21 @@ bool ecall_config_load(threadid_t nthreads,
     ingestion_epoch = 0;
     storage_epoch = 0;
 
+#ifdef TRACK_HEAP_USAGE
+    printf("ecall_config_load H1 heap %u\n", g_peak_heap_used);
+#endif
     if (!route_init()) {
         return false;
     }
-
-    return comms_init_nodestate(apinodeconfigs, num_nodes, my_node_num);
+#ifdef TRACK_HEAP_USAGE
+    printf("ecall_config_load H2 heap %u\n", g_peak_heap_used);
+#endif
+
+    bool ret = comms_init_nodestate(apinodeconfigs, num_nodes, my_node_num);
+#ifdef TRACK_HEAP_USAGE
+    printf("ecall_config_load end heap %u\n", g_peak_heap_used);
+#endif
+    return ret;
 }
 
 void ecall_close()

+ 6 - 0
Enclave/config.hpp

@@ -52,4 +52,10 @@ extern Config g_teems_config;
 extern unsigned long ingestion_epoch;
 extern unsigned long storage_epoch;
 
+// #define TRACK_HEAP_USAGE
+
+#ifdef TRACK_HEAP_USAGE
+extern unsigned long g_peak_heap_used;
+#endif
+
 #endif

+ 26 - 0
Enclave/route.cpp

@@ -125,14 +125,25 @@ bool route_init()
     printf("users_per_ing=%u, tot_msg_per_ing=%u, max_msg_from_each_ing=%u, max_round1_msgs=%u, users_per_stg=%u, tot_msg_per_stg=%u, max_msg_to_each_stg=%u, max_round2_msgs=%u, max_stg_msgs=%u\n", users_per_ing, tot_msg_per_ing, max_msg_from_each_ing, max_round1_msgs, users_per_stg, tot_msg_per_stg, max_msg_to_each_stg, max_round2_msgs, max_stg_msgs);
     */
 
+#ifdef TRACK_HEAP_USAGE
+    printf("route_init H1 heap %u\n", g_peak_heap_used);
+#endif
     // Create the route state
     uint8_t my_roles = g_teems_config.roles[g_teems_config.my_node_num];
     try {
         if (my_roles & ROLE_INGESTION) {
             route_state.ingbuf.alloc(tot_msg_per_ing);
         }
+#ifdef TRACK_HEAP_USAGE
+        printf("route_init alloc %u msgs\n", tot_msg_per_ing);
+        printf("route_init H2 heap %u\n", g_peak_heap_used);
+#endif
         if (my_roles & ROLE_ROUTING) {
             route_state.round1.alloc(max_round2_msgs);
+#ifdef TRACK_HEAP_USAGE
+            printf("route_init alloc %u msgs\n", max_round2_msgs);
+            printf("route_init H3 heap %u\n", g_peak_heap_used);
+#endif
             if (!g_teems_config.private_routing) {
                 route_state.round1a.alloc(max_round1a_msgs);
                 route_state.round1a_sorted.alloc(max_round1a_msgs);
@@ -140,10 +151,22 @@ bool route_init()
                 route_state.round1b_prev.alloc(2*max_round1b_msgs_to_adj_rtr);
                 route_state.round1b_next.alloc(2*max_round1b_msgs_to_adj_rtr);
                 route_state.round1c.alloc(max_round1c_msgs);
+#ifdef TRACK_HEAP_USAGE
+                printf("route_init alloc %u msgs\n", max_round1a_msgs);
+                printf("route_init alloc %u msgs\n", max_round1a_msgs);
+                printf("route_init alloc %u msgs\n", 2*max_round1b_msgs_to_adj_rtr);
+                printf("route_init alloc %u msgs\n", 2*max_round1b_msgs_to_adj_rtr);
+                printf("route_init alloc %u msgs\n", max_round1c_msgs);
+                printf("route_init H4 heap %u\n", g_peak_heap_used);
+#endif
             }
         }
         if (my_roles & ROLE_STORAGE) {
             route_state.round2.alloc(max_stg_msgs);
+#ifdef TRACK_HEAP_USAGE
+                printf("route_init alloc %u msgs\n", max_stg_msgs);
+                printf("route_init H5 heap %u\n", g_peak_heap_used);
+#endif
             if (!storage_init(users_per_stg, max_stg_msgs)) {
                 return false;
             }
@@ -182,6 +205,9 @@ bool route_init()
     }
 #ifdef PROFILE_ROUTING
     printf_with_rtclock_diff(start, "end precompute evalplans\n");
+#endif
+#ifdef TRACK_HEAP_USAGE
+    printf("route_init end heap %u\n", g_peak_heap_used);
 #endif
     return true;
 }