xserver: Branch 'master'

Keith Packard keithp at kemper.freedesktop.org
Fri Oct 28 16:29:20 UTC 2016


 dix/resource.c |   33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)

New commits:
commit c85f81825e196e96337347e0ce3a538fb2e38f16
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Oct 28 09:28:32 2016 -0700

    dix: Bump MAXHASHSIZE for the resource db [v2]
    
    [This was originally a workaround for a client-side resource leak:
    
    http://lists.freedesktop.org/archives/xorg-devel/2012-November/034555.html
    
    Obviously that's a broken app, but the performance problem it
    illustrates - that walking the linked list ends up burning all your CPU
    time - is real enough. - ajax]
    
    v2: Replace with a shorter code sequence which computes the same
        results for all but numBits == 7
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/resource.c b/dix/resource.c
index 68efd24..b6ef99f 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -156,7 +156,7 @@ static void RebuildTable(int    /*client */
 
 #define INITBUCKETS 64
 #define INITHASHSIZE 6
-#define MAXHASHSIZE 11
+#define MAXHASHSIZE 16
 
 typedef struct _Resource {
     struct _Resource *next;
@@ -668,29 +668,14 @@ InitClientResources(ClientPtr client)
 int
 HashResourceID(XID id, int numBits)
 {
-    id &= RESOURCE_ID_MASK;
-    switch (numBits)
-    {
-        case 6:
-            return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12))));
-        case 7:
-            return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13))));
-        case 8:
-            return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16))));
-        case 9:
-            return ((int)(0x1FF & (id ^ (id>>9))));
-        case 10:
-            return ((int)(0x3FF & (id ^ (id>>10))));
-        case 11:
-            return ((int)(0x7FF & (id ^ (id>>11))));
-    }
-    if (numBits >= 11)
-        return ((int)(0x7FF & (id ^ (id>>11))));
-    else
-    {
-        assert(numBits >= 0);
-        return id & ~((~0) << numBits);
-    }
+    static XID mask;
+
+    if (!mask)
+        mask = RESOURCE_ID_MASK;
+    id &= mask;
+    if (numBits < 9)
+        return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0) << numBits);
+    return (id ^ (id >> numBits)) & ~((~0) << numBits);
 }
 
 static XID


More information about the xorg-commit mailing list