浏览代码

Profiling time taken to send client mailboxes

Sajin 1 年之前
父节点
当前提交
536f8f14d5
共有 2 个文件被更改,包括 20 次插入1 次删除
  1. 19 1
      App/net.cpp
  2. 1 0
      App/net.hpp

+ 19 - 1
App/net.cpp

@@ -205,6 +205,7 @@ uint64_t NetIO::reset_bytes_sent()
 
 void NetIO::ing_receive_msgbundle(tcp::socket* csocket, clientid_t c_simid)
 {
+
     unsigned char *msgbundle = (unsigned char*) malloc(msgbundle_size);
 
     boost::asio::async_read(*csocket, boost::asio::buffer(msgbundle, msgbundle_size),
@@ -231,7 +232,9 @@ void NetIO::ing_receive_msgbundle(tcp::socket* csocket, clientid_t c_simid)
         free(msgbundle);
 
         // Continue to async receive client message bundles
-        ing_receive_msgbundle(csocket, c_simid);
+        if(ret) {
+            ing_receive_msgbundle(csocket, c_simid);
+        }
     });
 }
 
@@ -369,6 +372,13 @@ void NetIO::stg_start_accept()
 
 void NetIO::send_client_mailbox()
 {
+
+#ifdef PROFILE_NET_CLIENTS
+    struct timespec tp;
+    clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+    unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+#endif
+
     // Send each client their tokens for the next epoch
     for(uint32_t lcid = 0; lcid < num_clients_per_stg; lcid++)
     {
@@ -416,6 +426,14 @@ void NetIO::send_client_mailbox()
         }
         */
     }
+
+#ifdef PROFILE_NET_CLIENTS
+    clock_gettime(CLOCK_REALTIME_COARSE, &tp);
+    unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
+    unsigned long diff = end - start;
+    printf("send_client_mailbox time: %lu.%06lu s\n", diff/1000000, diff%1000000);
+#endif
+
 }
 
 NetIO::NetIO(boost::asio::io_context &io_context, const Config &config)

+ 1 - 0
App/net.hpp

@@ -13,6 +13,7 @@
 #include "../Enclave/enclave_api.h"
 
 // #define DEBUG_NET_CLIENTS
+#define PROFILE_NET_CLIENTS
 
 // The inter-node (untrusted node to untrusted node) communication
 // protocol is as follows.  Nodes are numbered 0 through num_nodes-1.