Adam Jackson <[email protected]> writes: > From: Roberto Ragusa <[email protected]> > > [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] > > Reviewed-by: Adam Jackson <[email protected]>
Can we just eliminate the silly switch and compute the "right" values to use here? This computes the same value for numBits from 6-16, except for 7 (which just looks wrong).
From d330c6782ee12aaff206a59729c8755a21539479 Mon Sep 17 00:00:00 2001 From: Roberto Ragusa <[email protected]> Date: Thu, 29 Sep 2016 11:16:17 -0400 Subject: [PATCH xserver] 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 <[email protected]> Signed-off-by: Keith Packard <[email protected]> --- dix/resource.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index ad71b24..8ce1c57 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 -- 2.9.3
-- -keith
signature.asc
Description: PGP signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
