Thread: pgsql: Hand code string to integer conversion for performance.
Hand code string to integer conversion for performance. As benchmarks show, using libc's string-to-integer conversion is pretty slow. At least part of the reason for that is that strtol[l] have to be more generic than what largely is required inside pg. This patch considerably speeds up int2/int4 input (int8 already was already using hand-rolled code). Most of the existing pg_atoi callers have been converted. But as one requires pg_atoi's custom delimiter functionality, and as it seems likely that there's external pg_atoi users, it seems sensible to just keep pg_atoi around. Author: Andres Freund Reviewed-By: Robert Haas Discussion: https://postgr.es/m/20171208214437.qgn6zdltyq5hmjpk@alap3.anarazel.de Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/86eaf208ea048936df6be77276a246d3f92e9620 Modified Files -------------- contrib/spi/refint.c | 2 +- doc/src/sgml/sources.sgml | 2 +- src/backend/libpq/pqmq.c | 6 +- .../libpqwalreceiver/libpqwalreceiver.c | 4 +- src/backend/tsearch/wparser_def.c | 8 +- src/backend/utils/adt/arrayutils.c | 3 +- src/backend/utils/adt/int.c | 4 +- src/backend/utils/adt/int8.c | 1 + src/backend/utils/adt/numutils.c | 149 +++++++++++++++++++++ src/backend/utils/adt/varlena.c | 4 +- src/include/utils/builtins.h | 2 + src/test/regress/expected/int2.out | 14 +- src/test/regress/expected/select_parallel.out | 2 +- 13 files changed, 176 insertions(+), 25 deletions(-)
On 23 July 2018 at 10:30, Andres Freund <andres@anarazel.de> wrote: > Hand code string to integer conversion for performance. This could do with the attached to silence the compiler warnings from compilers that don't understand ereport(ERROR) does not return. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Attachment
On 2018-07-24 22:10:09 +1200, David Rowley wrote: > On 23 July 2018 at 10:30, Andres Freund <andres@anarazel.de> wrote: > > Hand code string to integer conversion for performance. > > This could do with the attached to silence the compiler warnings from > compilers that don't understand ereport(ERROR) does not return. Pushed. Not sure if any of those do enough control flow analysis to even consider those blocks reachable? But anyway, doesn't hurt. Greetings, Andres Freund
On 25 July 2018 at 05:11, Andres Freund <andres@anarazel.de> wrote: > Pushed. Not sure if any of those do enough control flow analysis to > even consider those blocks reachable? But anyway, doesn't hurt. Thanks. MSVC was producing a warning. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services