[PATCH 2/2] Use fls() to find chunk set

From: Jeremy Kerr <jk(at)ozlabs(dot)org>
To: <pgsql-hackers(at)postgresql(dot)org>
Cc: Atsushi Ogawa <a_ogawa(at)hi-ho(dot)ne(dot)jp>
Subject: [PATCH 2/2] Use fls() to find chunk set
Date: 2009-06-02 15:44:39
Message-ID: 1243957479.379718.764595571686.2.gpush@pingu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Results in a ~2% performance increase by using the powerpc fls()
implementation.

Signed-off-by: Jeremy Kerr <jk(at)ozlabs(dot)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);
}

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-06-02 15:44:58 Re: PostgreSQL Developer meeting minutes up
Previous Message Tom Lane 2009-06-02 15:43:48 Managing multiple branches in git