[PATCH 6/6 HACK] dix: introduce a hack for logging server workload

Tiago Vignatti tiago.vignatti at nokia.com
Tue Sep 7 05:50:27 PDT 2010


I don't expect this patch to be applied to vanilla xserver.

It logs X11 requests and their time spent being processed, writing in a file.
Also the input processing is recorded. This all can be used for
characterization of the workload.

X Registery code is used to get the name (parsing protocol.txt).

TODO: see if this commit is overlapping somehow X Record Extension and cnee
(seems it's tied with the core protocol only and doesn't record extensions).

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 dix/dispatch.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 17f308c..5f2fad1 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -348,6 +348,9 @@ Dispatch(void)
     HWEventQueuePtr* icheck = checkForInput;
     long			start_tick;
 
+    FILE *fd;
+    fd = fopen("xserver-requests.txt","a+");
+
     nextFreeClientID = 1;
     nClients = 0;
 
@@ -360,7 +363,11 @@ Dispatch(void)
     {
         if (*icheck[0] != *icheck[1])
 	{
+	    int a, b;
+	    a = GetTimeInMillis();
 	    ProcessInputEvents();
+	    b = GetTimeInMillis();
+	    fprintf(fd, "INPUTPROCESSING:::%d\n", b - a);
 	    FlushIfCriticalOutputPending();
 	}
 
@@ -396,8 +403,13 @@ Dispatch(void)
 	    while (!isItTimeToYield)
 	    {
 	        if (*icheck[0] != *icheck[1])
-		    ProcessInputEvents();
-		
+	        {
+			int a, b;
+			a = GetTimeInMillis();
+			ProcessInputEvents();
+			b = GetTimeInMillis();
+			fprintf(fd, "INPUTPROCESSING:::%d\n", b - a);
+	        }
 		FlushIfCriticalOutputPending();
 		if (!SmartScheduleDisable && 
 		    (SmartScheduleTime - start_tick) >= SmartScheduleSlice)
@@ -423,6 +435,9 @@ Dispatch(void)
 			      ((xReq *)client->requestBuffer)->length,
 			      client->index, client->requestBuffer);
 #endif
+		int a, b;
+		a = GetTimeInMillis();
+
 		if (result > (maxBigRequestSize << 2))
 		    result = BadLength;
 		else {
@@ -431,6 +446,11 @@ Dispatch(void)
 			result = (* client->requestVector[MAJOROP])(client);
 		    XaceHookAuditEnd(client, result);
 		}
+
+		b = GetTimeInMillis();
+		fprintf(fd, "%s:%d:%d\n",
+		        LookupRequestName(MAJOROP, MinorOpcodeOfRequest(client)),
+		        MAJOROP, b - a);
 #ifdef XSERVER_DTRACE
 		XSERVER_REQUEST_DONE(LookupMajorName(MAJOROP), MAJOROP,
 			      client->sequence, client->index, result);
@@ -456,6 +476,7 @@ Dispatch(void)
 	}
 	dispatchException &= ~DE_PRIORITYCHANGE;
     }
+    fclose(fd);
 #if defined(DDXBEFORERESET)
     ddxBeforeReset ();
 #endif
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list