[PATCH 2/2] Use fls() to find chunk set - Mailing list pgsql-hackers

From Jeremy Kerr
Subject [PATCH 2/2] Use fls() to find chunk set
Date
Msg-id 1243957479.379718.764595571686.2.gpush@pingu
Whole thread Raw
In response to Re: faster version of AllocSetFreeIndex for x86 architecture  (Jeremy Kerr <jk@ozlabs.org>)
List pgsql-hackers
Results in a ~2% performance increase by using the powerpc fls()
implementation.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

---src/backend/utils/mmgr/aset.c |    8 ++------1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 0e2d4d5..762cf72 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -65,6 +65,7 @@#include "postgres.h"#include "utils/memutils.h"
+#include "utils/bitops.h"/* Define this to detail debug alloc information *//* #define HAVE_ALLOCINFO */
@@ -270,12 +271,7 @@ AllocSetFreeIndex(Size size)    if (size > 0)    {
-        size = (size - 1) >> ALLOC_MINBITS;
-        while (size != 0)
-        {
-            idx++;
-            size >>= 1;
-        }
+        idx = fls((size - 1) >> ALLOC_MINBITS);        Assert(idx < ALLOCSET_NUM_FREELISTS);    }


pgsql-hackers by date:

Previous
From: Jeremy Kerr
Date:
Subject: [PATCH 1/2] Add bit operations util header
Next
From: Robert Haas
Date:
Subject: Re: PostgreSQL Developer meeting minutes up