public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Gustafsson <[email protected]>
To: Thomas Munro <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: A qsort template
Date: Tue, 2 Mar 2021 22:25:39 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+hUKGJ2-eaDqAum5bxhpMNhvuJmRDZxB_Tow0n-gse+HG0Yig@mail.gmail.com>
References: <CA+hUKGJ2-eaDqAum5bxhpMNhvuJmRDZxB_Tow0n-gse+HG0Yig@mail.gmail.com>
> On 18 Feb 2021, at 04:09, Thomas Munro <[email protected]> wrote:
> In another thread[1], I proposed $SUBJECT, but then we found a better
> solution to that thread's specific problem. The general idea is still
> good though: it's possible to (1) replace several existing copies of
> our qsort algorithm with one, and (2) make new specialised versions a
> bit more easily than the existing Perl generator allows. So, I'm back
> with a rebased stack of patches. I'll leave specific cases for new
> worthwhile specialisations for separate proposals; I've heard about
> several.
Just to play around with this while reviewing I made a qsort_strcmp, like in
the attached, and tested it using a ~9M word [0] randomly shuffled wordlist.
While being too small input to make any meaningful difference in runtime (it
shaved a hair off but it might well be within the error margin) there was no
regression either. More importantly, it was really simple and quick to make a
tailored qsort which is the intention with the patch. While still being a bit
of magic, moving from the Perl generator makes this slightly less magic IMO so
+1 on this approach.
A tiny nitpick on the patch itself:
+ * - ST_COMPARE(a, b) - a simple comparison expression
+ * - ST_COMPARE(a, b, arg) - variant that takes an extra argument
Indentation.
All tests pass and the documentation in the the sort_template.h is enough to go
on, but I would prefer to see a comment in port/qsort.c referring back to
sort_template.h for documentation.
--
Daniel Gustafsson https://vmware.com/
[0] https://github.com/dwyl/english-words/ shuffled 20 times over
Attachments:
[application/octet-stream] qsort_tmpl_strcmp-patch (2.9K, ../[email protected]/2-qsort_tmpl_strcmp-patch)
download
view thread (52+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: A qsort template
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox