public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org, Paul Eggert <eggert@cs.ucla.edu>,
	 Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH v8 0/7] Use introsort for qsort
Date: Fri, 27 Oct 2023 20:31:29 -0500	[thread overview]
Message-ID: <CAFUsyf+0UbVayXPNhbW5OEBEFpiLxQPp8CjpRCYnVqsfcLEG3A@mail.gmail.com> (raw)
In-Reply-To: <a804f0bc-2b21-453b-a3ac-73a65a0f75f9@linaro.org>

On Fri, Oct 27, 2023 at 3:25 PM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 03/10/23 15:13, Noah Goldstein wrote:
> > On Tue, Oct 3, 2023 at 5:22 AM Adhemerval Zanella
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >> The motivation for using introsort is to make it fully AS-safe and
> >> AC-Safe, with a limited stack size requirement, to remove the use of
> >> malloc (which is troublesome since it seems some programs do longjmp
> >> from the callback comparison program), and keep worst-case scenario
> >> bounded to O(n*ln(n)) (instead of potentially quadradic as for the
> >> quicksort).
> >>
> >> The implementation does not aim to be the state-of-the-art sort
> >> algorithm, instead it uses used a well-understood introsort (used on
> >> libstdc++, for instance) and leveraged the current quicksort
> >> implementation along with a heapsort one from Linux kernel.
> >>
> >> Performance-wise, the introsort does fall short compared to the
> >> mergesort [1].  I have not added a benchmark because I think this should
> >> not be the focus of this patch.
> >>
> >> Changes from v7:
> >> - Move __memswap to a static inline on its own header.
> >> - Improve some comments.
> >>
> >> Changes from v6:
> >> - Added internal __memswap symbol.
> >> - Improved tst-qsort3 with a reference implementation and a new
> >>   duplicated input.
> >>
> >> Changes from v5:
> >> - Rewrite heapsort to a custom implementation.
> >> - Use may_alias attribute on swap optimization.
> >>
> >> Changes from v4
> >> - Use enum for swap function selection.
> >> - Simplify is_aligned.
> >> - Renamed insertsort.
> >>
> >> PS: this is a update for
> >> https://sourceware.org/pipermail/libc-alpha/2023-October/151887.html
> >> which should be ignored.
> >>
> >> Adhemerval Zanella (7):
> >>   string: Add internal memswap implementation
> >>   stdlib: Optimization qsort{_r} swap implementation
> >>   stdlib: Move insertion sort out qsort
> >>   stdlib: qsort: Move some macros to inline function
> >>   stdlib: Implement introsort for qsort (BZ 19305)
> >>   stdlib: Remove use of mergesort on qsort (BZ 21719)
> >>   stdlib: Add more qsort{_r} coverage
> >>
> >>  include/stdlib.h          |   2 -
> >>  manual/argp.texi          |   2 +-
> >>  manual/locale.texi        |   3 +-
> >>  manual/search.texi        |   7 +-
> >>  stdlib/Makefile           |   3 +-
> >>  stdlib/msort.c            | 309 --------------------------------
> >>  stdlib/qsort.c            | 318 +++++++++++++++++++++++++--------
> >>  stdlib/tst-qsort3.c       | 366 ++++++++++++++++++++++++++++++++++++++
> >>  string/Makefile           |  12 ++
> >>  string/test-memswap.c     | 192 ++++++++++++++++++++
> >>  sysdeps/generic/memswap.h |  41 +++++
> >>  11 files changed, 856 insertions(+), 399 deletions(-)
> >>  delete mode 100644 stdlib/msort.c
> >>  create mode 100644 stdlib/tst-qsort3.c
> >>  create mode 100644 string/test-memswap.c
> >>  create mode 100644 sysdeps/generic/memswap.h
> >>
> >> --
> >> 2.34.1
> >>
> > Minus the nit about the memswap changes, this series looks good.
>
> Thanks for the review, may I get reviewed-by ;) ?

LGTM with nit about memswap tests.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>

  reply	other threads:[~2023-10-28  1:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 12:22 Adhemerval Zanella
2023-10-03 12:22 ` [PATCH v8 1/7] string: Add internal memswap implementation Adhemerval Zanella
2023-10-03 17:42   ` Noah Goldstein
2023-10-27 20:23     ` Adhemerval Zanella Netto
2023-10-27 22:47       ` Gabriel Ravier
2023-10-28  1:30         ` Noah Goldstein
2023-10-30 19:02   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 2/7] stdlib: Optimization qsort{_r} swap implementation Adhemerval Zanella
2023-10-30 19:02   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 3/7] stdlib: Move insertion sort out qsort Adhemerval Zanella
2023-10-30 19:03   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 4/7] stdlib: qsort: Move some macros to inline function Adhemerval Zanella
2023-10-30 19:03   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 5/7] stdlib: Implement introsort for qsort (BZ 19305) Adhemerval Zanella
2023-10-30 19:03   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 6/7] stdlib: Remove use of mergesort on qsort (BZ 21719) Adhemerval Zanella
2023-10-30 19:04   ` Noah Goldstein
2023-10-03 12:22 ` [PATCH v8 7/7] stdlib: Add more qsort{_r} coverage Adhemerval Zanella
2023-10-30 19:04   ` Noah Goldstein
2023-10-03 18:13 ` [PATCH v8 0/7] Use introsort for qsort Noah Goldstein
2023-10-27 20:24   ` Adhemerval Zanella Netto
2023-10-28  1:31     ` Noah Goldstein [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-10-02 19:33 Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFUsyf+0UbVayXPNhbW5OEBEFpiLxQPp8CjpRCYnVqsfcLEG3A@mail.gmail.com \
    --to=goldstein.w.n@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).