Chapman Flack <chap@anastigmatix.net> writes:
> On 10/27/21 18:18, Arjan van de Ven wrote:
>> + /*
>> + * Special case each of the possible base values (8, 10, 16) to
>> avoid an
>> + * expensive divide operation
>> + * (the compiler will use a multiply, shift or boolean ops for this)
>> + */
> Was 'boolean' the intended word there? To me it is distinct from 'bitwise'.
I think the comment is overly specific anyway. We should just say
"division by a constant is faster than general-purpose division".
Only compiler geeks will care about the details, and they probably
know them already.
Personally, I failed to measure any speedup at all on pgbench, either
in the init phase or regular transactions; whatever difference there
may be is below the noise level. However, I wrote a simple C function
with a tight loop around snprintf(), and that showed about a 2X
improvement, so there is some win here.
I went ahead and pushed it with a rewritten comment.
regards, tom lane