public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Viktor Reznov <yann.collet.is.not.a.perfectionist@gmail.com>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH] Halving the number of recursive calls
Date: Mon, 13 May 2024 10:04:23 -0400	[thread overview]
Message-ID: <3f8f8f3a-6c54-4b94-a666-001150ebbb32@redhat.com> (raw)
In-Reply-To: <CAKs8_O+FRyB3kpzxQZPVrQGwVzRzwViK17kVpWzQAEzQtHi9VQ@mail.gmail.com>

On 5/12/24 10:40 PM, Viktor Reznov wrote:
> From b4813bd1d7f48014e24f8a8749da49f7749c4f37 Mon Sep 17 00:00:00 2001
> From: Reznov <yann.collet.is.not.a.perfectionist@gmail.com>
> Date: Mon, 13 May 2024 05:27:05 +0300
> Subject: [PATCH] Halving the number of recursive calls

Thank you for contributing to glibc! :-)

Please note that this patch fails to pass pre-commit CI:
https://patchwork.sourceware.org/project/glibc/patch/CAKs8_O+FRyB3kpzxQZPVrQGwVzRzwViK17kVpWzQAEzQtHi9VQ@mail.gmail.com/
- Patch fails to apply due to line wrapping.

Please have a look at the contribution checklist here:
https://sourceware.org/glibc/wiki/Contribution%20checklist

In particular:

- You can use `git send-email` to send the message to the list to avoid wrapping
  issues with mail clients.

- You must choose one of the processes for copyright for your patch, either
  disclaim, assign, or developer certificate of origin.


Lastly, How did you test the performance gains?

Does this change show up visibly in a microbenchmark or workload?


> ---
>  stdlib/qsort.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/stdlib/qsort.c b/stdlib/qsort.c
> index be47aebbe0..30ba492869 100644
> --- a/stdlib/qsort.c
> +++ b/stdlib/qsort.c
> @@ -198,16 +198,15 @@ msort_with_tmp (const struct msort_param *p,
> void *b, size_t n)
>    char *b1, *b2;
>    size_t n1, n2;
> 
> -  if (n <= 1)
> -    return;
> -
>    n1 = n / 2;
>    n2 = n - n1;
>    b1 = b;
>    b2 = (char *) b + (n1 * p->s);
> 
> -  msort_with_tmp (p, b1, n1);
> -  msort_with_tmp (p, b2, n2);
> +  if (n1 > 1)
> +    msort_with_tmp (p, b1, n1);
> +  if (n2 > 1)
> +    msort_with_tmp (p, b2, n2);
> 
>    char *tmp = p->t;
>    const size_t s = p->s;

-- 
Cheers,
Carlos.


  reply	other threads:[~2024-05-13 14:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  2:40 Viktor Reznov
2024-05-13 14:04 ` Carlos O'Donell [this message]
2024-05-14  5:27   ` Viktor Reznov
2024-05-14  6:08     ` Xi Ruoyao
2024-05-14  9:14       ` Adhemerval Zanella Netto

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=3f8f8f3a-6c54-4b94-a666-001150ebbb32@redhat.com \
    --to=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=yann.collet.is.not.a.perfectionist@gmail.com \
    /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).