Re: Inlining comparators as a performance optimisation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, Peter Geoghegan <peter@2ndquadrant.com>, PG Hackers <pgsql-hackers@postgresql.org>
Date: 2011-09-21T15:46:52Z
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
Andrew Dunstan <andrew@dunslane.net> writes: > On 09/21/2011 10:50 AM, Tom Lane wrote: >> The other question that I'm going to be asking is whether it's not >> possible to get most of the same improvement with a much smaller code >> footprint. I continue to suspect that getting rid of the SQL function >> impedance-match layer (myFunctionCall2Coll etc) would provide most of >> whatever gain is to be had here, without nearly as large a cost in code >> size and maintainability, and with the extra benefit that the speedup >> would also be available to non-core datatypes. > Can we get a patch so we can do benchmarks on this? Well, we'd have to negotiate what the API ought to be. What I'm envisioning is that datatypes could provide alternate comparison functions that are designed to be qsort-callable rather than SQL-callable. As such, they could not have entries in pg_proc, so it seems like there's no ready way to represent them in the catalogs. 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, so that the first comparison in a given sort run would be done the traditional way but then we'd notice the provided function pointer and start using that. It would not be too hard to pass back the pointer using FunctionCallInfoData.context, say. The downside is adding cycles to unoptimized cases to uselessly check for a returned function pointer that's not there. Perhaps it could be hacked so that we only add cycles to the very first call, but I've not looked closely at the code to see what would be involved. Has anyone got a better idea for getting hold of the alternate function? regards, tom lane