Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint
От | Tom Lane |
---|---|
Тема | Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint |
Дата | |
Msg-id | 541906.1635443209@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint (Chapman Flack <chap@anastigmatix.net>) |
Ответы |
Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint
|
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: