Start to add request time profiling.
[bluesky.git] / nfs3 / rpc.c
index f753bd1..05d9722 100644 (file)
@@ -149,6 +149,8 @@ async_rpc_send_failure(RPCRequest *req, enum accept_stat stat)
     async_rpc_flush(req->connection);
     g_mutex_unlock(req->connection->send_lock);
 
+    bluesky_profile_free(req->profile);
+
     if (req->args != NULL) {
         char buf[4];
         XDR xdr;
@@ -186,6 +188,9 @@ async_rpc_send_reply(RPCRequest *req, void *result)
 {
     bluesky_time_hires time_end;
 
+    bluesky_profile_add_event(req->profile,
+                              g_strdup("Start encoding NFS response"));
+
     GString *str = g_string_new("");
     XDR xdr_out;
     xdr_string_create(&xdr_out, str, XDR_ENCODE);
@@ -224,7 +229,12 @@ async_rpc_send_reply(RPCRequest *req, void *result)
            req->xid, time_end - req->time_start);
 #endif
 
+    bluesky_profile_add_event(req->profile,
+                              g_strdup("NFS reply sent"));
+    bluesky_profile_print(req->profile);
+
     /* Clean up. */
+    bluesky_profile_free(req->profile);
     g_string_free(str, TRUE);
 
     if (req->args != NULL) {
@@ -319,14 +329,15 @@ nfs_program_3(RPCRequest *req)
     xdrproc_t _xdr_argument, _xdr_result;
     char *(*local)(char *, RPCRequest *);
 
-#if 0
+    bluesky_profile_set(req->profile);
+
     if (req->req_proc < sizeof(nfs_proc_names) / sizeof(const char *)) {
-        printf("Dispatched NFS RPC message type %s\n",
-               nfs_proc_names[req->req_proc]);
-    } else {
-        printf("Dispatched unknown NFS RPC message type %d\n", req->req_proc);
+        bluesky_profile_add_event(
+            req->profile,
+            g_strdup_printf("Dispatching NFS %s request",
+                            nfs_proc_names[req->req_proc])
+        );
     }
-#endif
 
     switch (req->req_proc) {
     case NFSPROC3_NULL:
@@ -596,7 +607,8 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc)
 
     RPCRequest *req = g_new0(RPCRequest, 1);
     req->connection = rpc;
-    req->time_start = time_start;
+    req->profile = bluesky_profile_new();
+    bluesky_profile_add_event(req->profile, g_strdup("Receive NFS request"));
     req->xid = xid;
 
     if (ntohl(header->prog) != NFS_PROGRAM) {