Re: Improve code in tidbitmap.c - Mailing list pgsql-hackers

From Etsuro Fujita
Subject Re: Improve code in tidbitmap.c
Date
Msg-id 00a201cee12f$c0d04430$4270cc90$@etsuro@lab.ntt.co.jp
Whole thread Raw
In response to Improve code in tidbitmap.c  ("Etsuro Fujita" <fujita.etsuro@lab.ntt.co.jp>)
Responses Re: Improve code in tidbitmap.c
List pgsql-hackers
I'd like to do the complementary explanation of this.

In tbm_union_page() and tbm_intersect_page() in tidbitmap.c, WORDS_PER_PAGE
is used in the scan of a lossy chunk, instead of WORDS_PER_CHUNK, where
these macros are defined as:

/* number of active words for an exact page: */
#define WORDS_PER_PAGE  ((MAX_TUPLES_PER_PAGE - 1) / BITS_PER_BITMAPWORD +
1)
/* number of active words for a lossy chunk: */
#define WORDS_PER_CHUNK  ((PAGES_PER_CHUNK - 1) / BITS_PER_BITMAPWORD + 1)

Though the use of WORDS_PER_PAGE in the scan of a lossy chunk is logically
correct since these macros implicitly satisfy that WORDS_PER_CHUNK <
WORDS_PER_PAGE, I think WORDS_PER_CHUNK should be used in the scan of a
lossy chunk for code readability and maintenance.  So, I submitted a patch
working in such a way in an earlier email.

I think that, as a secondary effect of the patch, the scan would be
performed a bit efficiently.

I'll add the patch to the 2013-11 CF.  Any comments are welcome.

Thanks,

Best regards,
Etsuro Fujita




pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: GIN improvements part 1: additional information
Next
From: KONDO Mitsumasa
Date:
Subject: Optimize kernel readahead using buffer access strategy