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@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
356db2340f
commit
c85f81825e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue