From 216af5eea5c8fdc9fca9d44da9eec33ac5e002d2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 20 Dec 2018 12:19:07 -0500 Subject: [PATCH] Make bitmapset.c use 64-bit bitmap words on 64-bit machines. Using the full width of the CPU's native word size shouldn't cost anything in typical cases. When working with large bitmapsets, this halves the number of operations needed for many common BMS operations. On the right sort of test case, a measurable improvement is obtained. David Rowley Discussion: https://postgr.es/m/CAKJS1f9EGBd2h-VkXvb=51tf+X46zMX5T8h-KYgXEV_u2zmLUw@mail.gmail.com --- src/include/nodes/bitmapset.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/include/nodes/bitmapset.h b/src/include/nodes/bitmapset.h index b6f1a9e6e5..433df8a46d 100644 --- a/src/include/nodes/bitmapset.h +++ b/src/include/nodes/bitmapset.h @@ -27,13 +27,25 @@ struct List; /* * Data representation + * + * Larger bitmap word sizes generally give better performance, so long as + * they're not wider than the processor can handle efficiently. We use + * 64-bit words if pointers are that large, else 32-bit words. */ +#if SIZEOF_VOID_P >= 8 + +#define BITS_PER_BITMAPWORD 64 +typedef uint64 bitmapword; /* must be an unsigned type */ +typedef int64 signedbitmapword; /* must be the matching signed type */ + +#else -/* The unit size can be adjusted by changing these three declarations: */ #define BITS_PER_BITMAPWORD 32 typedef uint32 bitmapword; /* must be an unsigned type */ typedef int32 signedbitmapword; /* must be the matching signed type */ +#endif + typedef struct Bitmapset { int nwords; /* number of words in array */