Speed up in-memory tuplesorting.
Robert Haas <rhaas@postgresql.org>
Speed up in-memory tuplesorting. Per recent work by Peter Geoghegan, it's significantly faster to tuplesort on a single sortkey if ApplySortComparator is inlined into quicksort rather reached via a function pointer. It's also faster in general to have a version of quicksort which is specialized for sorting SortTuple objects rather than objects of arbitrary size and type. This requires a couple of additional copies of the quicksort logic, which in this patch are generate using a Perl script. There might be some benefit in adding further specializations here too, but thus far it's not clear that those gains are worth their weight in code footprint.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/Makefile | modified | +3 −1 |
| src/backend/utils/sort/gen_qsort_tuple.pl | added | +232 −0 |
| src/backend/utils/sort/.gitignore | added | +1 −0 |
| src/backend/utils/sort/Makefile | modified | +8 −0 |
| src/backend/utils/sort/tuplesort.c | modified | +35 −33 |
| src/port/qsort_arg.c | modified | +1 −1 |
| src/port/qsort.c | modified | +1 −1 |
| src/tools/msvc/Solution.pm | modified | +8 −0 |