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
This commit is contained in:
Tom Lane 2018-12-20 12:19:07 -05:00
parent 0c2377152f
commit 216af5eea5
1 changed files with 13 additions and 1 deletions

View File

@ -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 */