Patchwork [1/4] xace: ricer tuning for XaceHook

login
register
mail settings
Submitter Adam Jackson
Date Dec. 13, 2011, 10:31 p.m.
Message ID <1323815513-6624-2-git-send-email-ajax@redhat.com>
Download mbox | patch
Permalink /patch/8295/
State Accepted
Commit 11977fab546da35d579ebe285e3c26864007805e
Headers show

Comments

Adam Jackson - Dec. 13, 2011, 10:31 p.m.
gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the
varargs code for some reason, so do it ourselves.

Before:
40000000 trep @   0.0010 msec (1050420.2/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (1921147.6/sec): ShmPutImage 10x10 square

After:
40000000 trep @   0.0009 msec (1087458.5/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 Xext/xace.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Alan Coopersmith - Dec. 13, 2011, 10:50 p.m.
On 12/13/11 14:31, Adam Jackson wrote:
> gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the
> varargs code for some reason, so do it ourselves.

Perhaps because it would have to do some gymnastics to realize that
in all cases we happen to either initialize prv to NULL or a pointer
to a struct member initialized to Success, and that it really is
equivalent to the return prv ? *prv : Success when the inlined
CallCallbacks determines there's nothing to do there.

(At least it took me a couple reads through the code to realize myself
  that this really does just fastpath that case and does not change the
  semantics of it.)

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

Patch

diff --git a/Xext/xace.c b/Xext/xace.c
index c757cad..ef69fe3 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -101,6 +101,10 @@  int XaceHook(int hook, ...)
     } u;
     int *prv = NULL;	/* points to return value from callback */
     va_list ap;		/* argument list */
+
+    if (!XaceHooks[hook])
+	return Success;
+
     va_start(ap, hook);
 
     /* Marshal arguments for passing to callback.