From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Reducing the chunk header sizes on all memory context types |
Date: | 2022-08-30 16:17:33 |
Message-ID: | 3680169.1661876253@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> Here's a patch which adds a comment to MemoryContextMethodID to Robert's patch.
OK, but while looking at that I noticed the adjacent
#define MEMORY_CONTEXT_METHODID_MASK \
UINT64CONST((1 << MEMORY_CONTEXT_METHODID_BITS) - 1)
I'm rather astonished that that compiles; UINT64CONST was only ever
meant to be applied to *literals*. I think what it's expanding to
is
((1 << MEMORY_CONTEXT_METHODID_BITS) - 1UL)
(or on some machines 1ULL) which only accidentally does approximately
what you want. It'd be all right perhaps to write
((UINT64CONST(1) << MEMORY_CONTEXT_METHODID_BITS) - 1)
but you might as well avoid the Postgres-ism and just write
((uint64) ((1 << MEMORY_CONTEXT_METHODID_BITS) - 1))
Nobody's ever going to make MEMORY_CONTEXT_METHODID_BITS large
enough for the shift to overflow in int arithmetic.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2022-08-30 16:27:04 | Re: Hash index build performance tweak from sorting |
Previous Message | Robert Haas | 2022-08-30 15:54:43 | Re: Reducing the chunk header sizes on all memory context types |