Re: Inlining comparators as a performance optimisation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: Andrew Dunstan <andrew@dunslane.net>, Peter Geoghegan <peter@2ndquadrant.com>, PG Hackers <pgsql-hackers@postgresql.org>
Date: 2011-09-21T16:13:07Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Speed up conversion of signed integers to C strings.
- 4fc115b2e981 9.1.0 cited
-
Remove some unnecessary tests of pgstat_track_counts.
- f4d242ef9473 9.1.0 cited
-
Remove cvs keywords from all files.
- 9f2e21138693 9.1.0 cited
-
Code cleanup for function prototypes: change two K&R-style prototypes
- b9954fbb4ef2 8.3.0 cited
-
Use Min() instead of min() in qsort, for consistency and to avoid
- b38900c76776 8.2.0 cited
-
pgindent run for 8.2.
- f99a569a2ee3 8.2.0 cited
-
Switch over to using our own qsort() all the time, as has been proposed
- 6edd2b4a91bd 8.2.0 cited
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes: > On 21.09.2011 18:46, Tom Lane wrote: >> The idea that I was toying with was to allow the regular SQL-callable >> comparison function to somehow return a function pointer to the >> alternate comparison function, > You could have a new function with a pg_proc entry, that just returns a > function pointer to the qsort-callback. Yeah, possibly. That would be a much more invasive change, but cleaner in some sense. I'm not really prepared to do all the legwork involved in that just to get to a performance-testable patch though. > Or maybe the interface should be an even more radical replacement of > qsort, not just the comparison function. Instead of calling qsort, > tuplesort.c would call the new datatype-specific sort-function (which > would be in pg_proc). The implementation could use an inlined version of > qsort, like Peter is suggesting, or it could do something completely > different, like a radix sort or a GPU-assisted sort or whatever. No. In the first place, that only helps for in-memory sorts. In the second, it would absolutely destroy our ability to change the behavior of sorting ever again. Considering that we've added ASC/DESC, NULLS FIRST/LAST, and collation support over the years, are you really prepared to bet that the sort code will never need any more feature upgrades? (This concern is in fact the source of my beef with the whole inlining proposal to begin with, but allowing the inlining to occur into third-party code that we don't control at all would be a hundred times worse.) regards, tom lane