Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20276/runtime

Modified Files:
      Tag: XQuery_0-16
        pathfinder.mx xrpc_client.mx xrpc_server.mx 
Log Message:
Improved the output of XRPC server and client when the option "timing"
is used.



Index: xrpc_client.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_client.mx,v
retrieving revision 1.6.2.6
retrieving revision 1.6.2.7
diff -u -d -r1.6.2.6 -r1.6.2.7
--- xrpc_client.mx      21 Feb 2007 16:23:54 -0000      1.6.2.6
+++ xrpc_client.mx      26 Feb 2007 17:26:11 -0000      1.6.2.7
@@ -87,14 +87,19 @@
                     updCall, arity, iterc, ws, fun_vid, fun_iter, fun_item,
                     fun_kind, int_values, dbl_values, dec_values, str_values);
 
-    var time_milClntDeSeriaStart := usec();
+    var time_xrpcClntDeSeria := usec();
+
+    var ret := oid_nil;
+    if (updCall != 1)
+        ret := ws_opencoll(ws, rpcres, local_name, TEMP_DOC);
+
+    time_xrpcClntDeSeria := usec() - time_xrpcClntDeSeria;
     if (options.search("timing") >= 0) {
-        printf("\nMIL_Client_DeSerialisation_Start: %lld microsec\n",
-                time_milClntDeSeriaStart);
+        printf("XRPC_Client_DeSerialisation:   %lld microsec\n",
+                time_xrpcClntDeSeria);
     }
 
-    if (updCall = 1) return oid_nil;
-    return ws_opencoll(ws, rpcres, local_name, TEMP_DOC);
+    return ret;
 }
 ADDHELP("rpc_client", "zhang", "November 2005",
 "DESCRIPTION:\n\
@@ -325,7 +330,7 @@
     var rpc_iter := bat(void,bat).seqbase([EMAIL PROTECTED]);
 
     unq_dsts @ [steps] batloop(){
-        var time_milClntSeria := usec();
+        var time_xrpcClntSeria := usec();
 
         # get iteration numbers for this destination
         var iter_dst := [oid](rpc_dsts.ord_uselect($t).reverse());
@@ -346,10 +351,10 @@
         fun_iter_dst := fun_iter_dst.leftjoin(iter_dst.mark([EMAIL 
PROTECTED]));
         fun_iter_dst := [oid](fun_iter_dst.tmark([EMAIL PROTECTED]));
 
-        time_milClntSeria := usec() - time_milClntSeria;
-        if (options.startsWith("timing")) {
-            printf("\nMIL_Client_Serialisation: %lld microsec\n",
-                    time_milClntSeria);
+        time_xrpcClntSeria := usec() - time_xrpcClntSeria;
+        if (options.search("timing") >= 0) {
+            printf("XRPC_Client_Serialisation:     %lld microsec\n",
+                    time_xrpcClntSeria);
         }
 
         var local_name := "rpc_res_00" + str(int($h)+1);
@@ -363,6 +368,8 @@
                          dec_values, str_values);
         });
 
+        var time_xrpcClntDeSeria := usec();
+
         if (isnil(rpc_err)) {
             if (updCall != 1) {
                 lock_set(mylock);
@@ -370,6 +377,11 @@
                 rpc_iter.append(iter_dst.hmark([EMAIL PROTECTED]));
                 lock_unset(mylock);
             }
+            time_xrpcClntDeSeria := usec() - time_xrpcClntDeSeria;
+            if (options.search("timing") >= 0) {
+                printf("XRPC_Client_DeSerialisation:   %lld microsec\n",
+                        time_xrpcClntDeSeria);
+            }
         } else {
             # We do not want to discard results from other destinations
             # where executions might have succeeded, so we only print a
@@ -378,15 +390,11 @@
             printf("error occurred during RPC call to \"%s\"\n%s\n",
                     $t, rpc_err);
         }
-
-        var time_milClntDeSeriaEnd := usec();
-        if (options.startsWith("timing")) {
-            printf("MIL_Client_DeSerialisation_End: %lld microsec\n\n",
-                    time_milClntDeSeriaEnd);
-        }
     }
     lock_destroy(mylock);
 
+    var time_xrpcClntDeSeria := usec();
+
     var res_iter := bat(void,oid).seqbase([EMAIL PROTECTED]);
     var res_item := bat(void,oid).seqbase([EMAIL PROTECTED]);
     var res_kind := bat(void,int).seqbase([EMAIL PROTECTED]);
@@ -426,6 +434,13 @@
                                  res_bats.fetch(1), res_item.fetch(i), 
                                  res_bats.fetch(2), res_kind.fetch(i));
     }
+
+    time_xrpcClntDeSeria := usec() - time_xrpcClntDeSeria;
+    if (options.search("timing") >= 0) {
+        printf("XRPC_Client_DeSerialisation:   %lld microsec\n\n",
+                time_xrpcClntDeSeria);
+    }
+
     return res_bats;
 }
 ADDHELP("doLoopLiftedRPC", "zhang", "April 2006",
@@ -725,7 +740,7 @@
     lng percentage = 0;
     int ret, sock = -1;
     buffer *b = NULL;
-    str strptr=NULL, str_val = NULL;
+    str ptr = NULL, strptr=NULL, str_val = NULL;
     stream *in = NULL, *out = NULL, *bs = NULL;
     /* Hold the temp BATs after the RPC response has been shredded: */
     BAT *shredBAT = NULL;
@@ -743,7 +758,8 @@
     BAT *attr_qn = NULL, *attr_prop = NULL;
     BAT *qn_prefix = NULL, *qn_loc = NULL, *prop_val = NULL;
 
-    lng time_clntSeria = 0, time_clnt2Serv = 0, time_clntDeSeria = 0;
+    lng time_xrpcClntSeria = 0, time_xrpcClntDeSeria = 0;
+    lng time_xrpcClnt2Serv = 0;
     size_t bytes_sent = 0, bytes_received = 0;
 
     errCheck(iterc, argc, ws, fun_vid, fun_iter, fun_item, fun_kind,
@@ -764,7 +780,7 @@
     }
 
     /* Start timing Client Serialisation */
-    time_clntSeria = GDKusec();
+    time_xrpcClntSeria = GDKusec();
 
     /* Create buffer for the RPC request message */
     b = buffer_create(MAX_BUF_SIZE);
@@ -1034,10 +1050,10 @@
     str2buf(b, XRPC_FOOTER);
     b->buf[b->pos] = 0;
     /* Stop timing Client Serialisation */
-    time_clntSeria = GDKusec() - time_clntSeria;
+    time_xrpcClntSeria = GDKusec() - time_xrpcClntSeria;
 
     /* Start timing Network Send Client2Server */
-    time_clnt2Serv = GDKusec();
+    time_xrpcClnt2Serv = GDKusec();
     bytes_sent = stream_printf(out,
             "POST %s HTTP/1.1\r\n"
             "Host: %s\r\n"
@@ -1053,7 +1069,7 @@
         return GDK_FAIL;
     }
     /* Stop timing Network Send Client2Server */
-    time_clnt2Serv= GDKusec() - time_clnt2Serv;
+    time_xrpcClnt2Serv= GDKusec() - time_xrpcClnt2Serv;
 
     /*** Receive all response data ***/
     b->pos = b->buf[0] = 0;
@@ -1075,6 +1091,8 @@
         return GDK_FAIL;
     }
 
+    /* Start timing Client DeSerialisation */
+    time_xrpcClntDeSeria = GDKusec();
     /* the HTTP header starts with "HTTP/1.x xxx", after the first
      * white space character, it is the 3-digits return code */
     strptr = strchr(b->buf, (int)' ') + 1;
@@ -1084,7 +1102,7 @@
 
         /* get the error code, error string out of the message */
         if(strptr){
-            char *ptr = strchr(strptr, '\r');
+            ptr = strchr(strptr, '\r');
             if (ptr){
                 ptr[0] = '\0';
                 GDKerror("HTTP Error Code  : %s\n", b->buf);
@@ -1109,8 +1127,6 @@
         return GDK_FAIL;
     }
 
-    /* Start timing Client DeSerialisation */
-    time_clntDeSeria = GDKusec();
     if (!(shredBAT = BATnew(TYPE_str, TYPE_bat, 32))){
         GDKerror("CMDhttp_post: failed to malloc shredBAT\n");
         clean_up(sock, in, out, bs, b, argcnt, iterc);
@@ -1119,6 +1135,8 @@
     if (!(*updCall)){
         bit verbose = FALSE;
         strptr = strstr(b->buf, "<env:Envelope");
+        ptr = strrchr(b->buf, '>'); /* Find end of "</env:Envelope>" */
+        ptr[1] = '\0';
         if (!strptr || CMDshred_str(shredBAT, strptr, &percentage, NULL, 
&verbose) == GDK_FAIL) {
             GDKerror("CMDhttp_post: invalid XRPC response received\n");
             GDKerror("%s\n", strptr?strptr:b->buf);
@@ -1132,16 +1150,27 @@
             return GDK_FAIL;
         }
     }
-    time_clntDeSeria = GDKusec() - time_clntDeSeria;
+    time_xrpcClntDeSeria = GDKusec() - time_xrpcClntDeSeria;
 
-    if (strstr(options, "timing")) {
-        printf("\n");
-        printf("Client_Serialisation: %lld microsec\n", time_clntSeria);
-        printf("Network_Client_2_Server: %lld microsec\n", time_clnt2Serv);
-        printf("Client_DeSerialisation: %lld microsec\n", time_clntDeSeria);
-        printf("\n");
-        printf("Data_Sent: " SZFMT " bytes\n", bytes_sent);
-        printf("Data_Received: " SZFMT " bytes\n", bytes_received);
+    if (options && strstr(options, "timing")) {
+        stream_printf(GDKout,
+                "XRPC_Client_Serialisation:     %lld microsec\n"
+                "XRPC_Network_Client_2_Server:  %lld microsec\n"
+                "XRPC_Client_DeSerialisation:   %lld microsec\n"
+                "\n"
+                "XRPC_Data_Sent:                " SZFMT " bytes\n"
+                "XRPC_Data_Received:            " SZFMT " bytes\n\n",
+                time_xrpcClntSeria,
+                time_xrpcClnt2Serv,
+                time_xrpcClntDeSeria,
+                bytes_sent,
+                bytes_received);
+    }
+
+    if( (ptr+= 2) && strstr(ptr, "XRPC_Server_Timing") ){
+        ptr += 19;
+        stream_printf(GDKout, strstr(ptr, "XRPC_"));
+        stream_printf(GDKout, "\n");
     }
 
     clean_up(sock, in, out, bs, b, argcnt, iterc);

Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.288.2.19
retrieving revision 1.288.2.20
diff -u -d -r1.288.2.19 -r1.288.2.20
--- pathfinder.mx       22 Feb 2007 15:25:14 -0000      1.288.2.19
+++ pathfinder.mx       26 Feb 2007 17:26:10 -0000      1.288.2.20
@@ -4158,15 +4158,6 @@
     
     /* Done preparing the query. Time to (re-)execute the MIL tree */
     if (xquery_tree_exec(ctx, prepfun->lt, 1)) {
-/*
-        if (strstr(*(ctx->genType), "rpcdtime") != NULL) {
-           printf("\nServer_Application: %.3f msec\n", (*ctx->time_compile + 
*ctx->time_exec) / 1000.0 );
-           printf("\tTrans: %.3f msec\n", (*ctx->time_compile) / 1000.0 );
-           printf("\tShred: %.3f msec\n", (*ctx->time_shred) / 1000.0 );
-           printf("\tQuery: %.3f msec\n", (*ctx->time_exec - *ctx->time_shred) 
/ 1000.0 );
-           printf("Server_Serialisation + Network_Server_2_Client: %.3f 
msec\n", (*ctx->time_print) / 1000.0 );
-        }
-*/
         return NULL;
     }
     return xquery_function_error;
@@ -5361,9 +5352,10 @@
               str* argval,
               BAT* shredBAT)
 {
-    xquery_client *ctx = (xquery_client*) mc->fc;
+    lng time_xrpcServApp = GDKusec();
     lng usec = GDKusec();
-    char *mode = (flags&2)?"timing-xml":"timing-xml-noheader-xrpc";
+    xquery_client *ctx = (xquery_client*) mc->fc;
+    char *mode = (flags&2)?"xml":"xml-noheader-xrpc";
     char *err, *buf, *ns = "fn";
     stream *s = NULL;
 
@@ -5373,9 +5365,6 @@
     buf = GDKstrdup(method);
     (*ctx->method) = buf;
 
-    if ((flags&1) == 0){
-        mode += 7; /* no "timing-" */
-    }
     err = xquery_change_genType(ctx, mode);
     if (err) return err;
 
@@ -5399,6 +5388,17 @@
         if (err == (char*) -1) err = "xquery_method: function could not be 
resolved.\n";
     }
 
+    time_xrpcServApp = GDKusec() - time_xrpcServApp;
+
+    if (flags&1){
+        /* print timing ourselves */
+        stream_printf(GDKout, "\nXRPC_Server_Timing:\n"
+               "XRPC_Server_Application:       %lld microsec\n"
+               "XRPC_Network_Server_2_Client:  %lld microsec\n",
+               (*ctx->time_shred + *ctx->time_compile + *ctx->time_exec),
+               *ctx->time_print);
+    }
+
     if (s) {
         stream_close(ctx->fderr);
         stream_destroy(ctx->fderr);

Index: xrpc_server.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_server.mx,v
retrieving revision 1.7.2.11
retrieving revision 1.7.2.12
diff -u -d -r1.7.2.11 -r1.7.2.12
--- xrpc_server.mx      23 Feb 2007 16:32:07 -0000      1.7.2.11
+++ xrpc_server.mx      26 Feb 2007 17:26:12 -0000      1.7.2.12
@@ -946,6 +946,19 @@
           str *argval,
           BAT *shredBAT)
 {
+    /* Possible values of serializeMode:
+     * 0: xml-noheader-xrpc
+     *    This is the normal serialize mode used for XRPC calls
+     * 1: timing-xml-noheader-xrpc
+     *    Let the XRPC server print the time of XRPC_Server_Application
+     *    and XRPC_Network_Server_2_Client at the server side.
+     * 2: xml
+     *    Used for the GET, PUT, DELETE HTTP requests to avoid "xrpc"
+     *    mode of serialization
+     * 3. timing-xml
+     *    Again, print time info at the XRPC server side, but is usually
+     *    not used.
+     */
     stream_printf(mc->c->fdout, "HTTP/1.1 200 OK\r\n"
             "Content-Type: application/soap+xml; "
             "charset=\"utf-8\"\r\n\r\n");
@@ -974,12 +987,12 @@
     char *module = NULL, *location = NULL, *method = NULL;
     bit isSimpleParam = 1;
     lng argc = 0, iterc = 0, nr_args = 0;
-    lng time_servDeSeria, time_servApp;
+    lng time_xrpcServDeSeria;
     lng **argcnt = NULL; /* argcnt[iterc][argc] */
     str *argtpe = NULL, *argval = NULL;
     int serializeMode = timing; 
 
-    time_servDeSeria = GDKusec();
+    time_xrpcServDeSeria = GDKusec();
     shredBAT = request2bat(mc->c->fdout, shttpd_get_msg(arg));
     if(!shredBAT)
         return GDK_FAIL;
@@ -991,10 +1004,9 @@
         BBPreclaim(shredBAT);
         return GDK_FAIL;
     }
-    time_servDeSeria = GDKusec() - time_servDeSeria;
+    time_xrpcServDeSeria = GDKusec() - time_xrpcServDeSeria;
     
     /* Execute the query and send XRPC response */
-    time_servApp = GDKusec();
     if(execQuery(mc, serializeMode, module, location, method,
                  argc, iterc, argcnt, argtpe, argval,
                  isSimpleParam?NULL:shredBAT) == GDK_FAIL) {
@@ -1002,12 +1014,11 @@
         BBPreclaim(shredBAT);
         return GDK_FAIL;
     }
-    time_servApp = GDKusec() - time_servApp;
 
     if (timing) {
-        printf("Server_DeSerialisation: %lld microsec\n"
-               "Server_Application: %lld microsec\n",
-               time_servDeSeria, time_servApp);
+        stream_printf(GDKout,
+                "XRPC_Server_DeSerialisation:    %lld microsec\n",
+                time_xrpcServDeSeria);
     }
 
     clean_up(argcnt, argtpe, argval, iterc, nr_args);
@@ -1162,8 +1173,8 @@
     char *s;
     
     if (rpcd_running) {
-        GDKerror("CMDrpcd_start: RPC receiver already running\n");
-        return GDK_FAIL;
+        stream_printf(GDKout, "\nRPC receiver already running\n");
+        return GDK_SUCCEED;
     }
 
     xrpc_port = rpcd_running = *port;


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to