Browse Source

More heap usage tracking in route.cpp

(if TRACK_HEAP_USAGE is #defined)
Ian Goldberg 9 months ago
parent
commit
f55843e15a
1 changed files with 41 additions and 0 deletions
  1. 41 0
      Enclave/route.cpp

+ 41 - 0
Enclave/route.cpp

@@ -180,6 +180,10 @@ bool route_init()
             if (!storage_init(users_per_stg, max_stg_msgs)) {
                 return false;
             }
+#ifdef TRACK_HEAP_USAGE
+                printf("storage_init(%u,%u)\n", users_per_stg, max_stg_msgs);
+                printf("route_init H6 heap %u\n", g_peak_heap_used);
+#endif
         }
     } catch (std::bad_alloc&) {
         printf("Memory allocation failed in route_init\n");
@@ -201,17 +205,45 @@ bool route_init()
     unsigned long start = printf_with_rtclock("begin precompute evalplans (%u,%hu) (%u,%hu)\n", tot_msg_per_ing, nthreads, max_round2_msgs, nthreads);
 #endif
     if (my_roles & ROLE_INGESTION) {
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) start heap %u\n", tot_msg_per_ing, g_peak_heap_used);
+#endif
         sort_precompute_evalplan(tot_msg_per_ing, nthreads);
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) end heap %u\n", tot_msg_per_ing, g_peak_heap_used);
+#endif
     }
     if (my_roles & ROLE_ROUTING) {
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) start heap %u\n", max_round2_msgs, g_peak_heap_used);
+#endif
         sort_precompute_evalplan(max_round2_msgs, nthreads);
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) end heap %u\n", max_round2_msgs, g_peak_heap_used);
+#endif
         if(!g_teems_config.token_channel) {
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) start heap %u\n", max_round1a_msgs, g_peak_heap_used);
+#endif
             sort_precompute_evalplan(max_round1a_msgs, nthreads);
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) end heap %u\n", max_round1a_msgs, g_peak_heap_used);
+        printf("sort_precompute_evalplan(%u) start heap %u\n", max_round1b_msgs_to_adj_rtr, g_peak_heap_used);
+#endif
             sort_precompute_evalplan(2*max_round1b_msgs_to_adj_rtr, nthreads);
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) end heap %u\n", max_round1b_msgs_to_adj_rtr, g_peak_heap_used);
+#endif
         }
     }
     if (my_roles & ROLE_STORAGE) {
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) start heap %u\n", max_stg_msgs, g_peak_heap_used);
+#endif
         sort_precompute_evalplan(max_stg_msgs, nthreads);
+#ifdef TRACK_HEAP_USAGE
+        printf("sort_precompute_evalplan(%u) end heap %u\n", max_stg_msgs, g_peak_heap_used);
+#endif
     }
 #ifdef PROFILE_ROUTING
     printf_with_rtclock_diff(start, "end precompute evalplans\n");
@@ -249,12 +281,18 @@ size_t ecall_precompute_sort(int sizeidx)
         ret = used_sizes.size();
     } else if (sizeidx >= 0 && sizeidx < used_sizes.size()) {
         uint32_t size = used_sizes[sizeidx];
+#ifdef TRACK_HEAP_USAGE
+        printf("ecall_precompute_sort start heap %u\n", g_peak_heap_used);
+#endif
 #ifdef PROFILE_ROUTING
         unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", size);
 #endif
         ret = sort_precompute(size);
 #ifdef PROFILE_ROUTING
         printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", size);
+#endif
+#ifdef TRACK_HEAP_USAGE
+        printf("ecall_precompute_sort end heap %u\n", g_peak_heap_used);
 #endif
     } else {
         uint8_t my_roles = g_teems_config.roles[g_teems_config.my_node_num];
@@ -1527,4 +1565,7 @@ void ecall_routing_proceed(void *cbpointer)
             ocall_routing_round_complete(cbpointer, 0);
         }
     }
+#ifdef TRACK_HEAP_USAGE
+    printf("ecall_routing_proceed end heap %u\n", g_peak_heap_used);
+#endif
 }