Re: Double sorting split patch - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Double sorting split patch
Date
Msg-id CAEYLb_UmjBFymMPBGmpNNAE-vY6qZtyey62XX_=e6XuuWzYoqg@mail.gmail.com
Whole thread Raw
In response to Re: Double sorting split patch  (Alexander Korotkov <aekorotkov@gmail.com>)
Responses Re: Double sorting split patch
List pgsql-hackers
On 15 September 2011 19:46, Alexander Korotkov <aekorotkov@gmail.com> wrote:
> Proposed algorithm finds following splits by single pass on two arrays: one
> sorted by lower bound of interval and another sorted by upper bound of
> interval.

Have you considered if further performance improvements could come
from providing a qsort implementation that allows for the inlining of
the comparator? I find it curious that we go to the trouble of
providing a custom qsort implementation in qsort.c, pg_qsort, but
haven't gone one step further and considered inlining effects. Here's
a macro-based inlining implementation:

http://www.corpit.ru/mjt/qsort.html

I wondered in passing if compiler vendors had got around to figuring
out a way of solving the "inlining function pointer" problem that I
first read about years ago, so I ran this code, which benchmarks the
macro-based qsort above:

http://www.lemoda.net/c/inline-qsort-example/index.html

It's actually C++, but that isn't significant (c stdlib qsort() is
called). When I built this code with GCC 4.5, the results were:

C quick-sort time elapsed: 3.24
Inline C quick-sort time elapsed: 2.01

It looks like this is something that could be revisited.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services


pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: Double sorting split patch
Next
From: Josh Berkus
Date:
Subject: Re: Is there really no interest in SQL Standard?