From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by sourceware.org (Postfix) with ESMTPS id 47429385F021 for ; Fri, 27 Oct 2023 20:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 47429385F021 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 47429385F021 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698438336; cv=none; b=nDHoPhyMLFtrPxSwlzBhBcfya379rSxj0wJ6P3wW6YBQgD8Lka7YR+OWdJJqq88QQTiy+qFf83xP5I+gIkniG4bsZRikegkpCHTZAAlUBhynCCoo4gjotOFCLqNjSV5lmbW3MR4lP69hi7p8wxt6gRv6g+A1zJ9MaYcNlHBX1m0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698438336; c=relaxed/simple; bh=dxHUtw0iHUQ1ndS/taksC/XpLce2S3mdrCCYxM8Ftck=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vMloSp7y4C7tMuIIeOi+5xKx7QuBqDsPv1/Q3IcrV26mOA3FO7btBVGX5VvF5AW9hVLSoYWiq0dAjFQwt+ovD6OuHVujTPlfvoPPraHQqy41uHNFAdk66VUePinnvmSejMtlom5qmqgNvL/LWZaODGIumz6173ERD4C9XNGgR2s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-d9c7bba32beso1817115276.1 for ; Fri, 27 Oct 2023 13:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698438334; x=1699043134; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=5Wr3Qaw0Nj9hzTvW6CzFXIoTo00024emvv47TSbhFIE=; b=QTCk15DRScWCqlLySpkFpZrlz/dJY9VADBOPzHRrJQxhNXf0P1Fvo36ajBZXyeJDNU 4Ih0zRK11xhp1OUUpdCDigvaTBTzcNHJ8ssu4gOKFMynAXwvHj3RwFr+AvR8kjGl9tSX 4MaZyqqJp/qp53DhqWzu4dGFKK4laD7GOCT3+yUtJm4zjM9yhOthKEranXqnTZqLw4Dx WLeVXNsdOnIdrGyL2mXwO7rpaJd7+S+CGK9reAYgMu2cHha7qotU5MJgOYp2JSrUXj8I ptnLwU4tcjyO26V3ITlGsttX4YzCYEw0tFaPVTBRoW5olV6q6XAOqEF1pi9BR61Ct+x/ 2OHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698438334; x=1699043134; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5Wr3Qaw0Nj9hzTvW6CzFXIoTo00024emvv47TSbhFIE=; b=qK6//E26A2lJbRwdcYyXtc9ZY/AzHUgi6sscZNOUWDIDDFntHpp4G09E3ksgbjt/nO iWsT7J7oi9yppjU0Vj2O5x044CwLJXctlLHSAdoFzex/lxqSg+XMHLGcXHuTBVDemopB L1JzRXGi72fo9g+b4HBDsIVV34CRoyeN9KI+teRqeY8iAjLtput1DLhCqdHm8A35efvw RC1wVaSSf5tJbCAAA+2TiLX92B2MeGS4969eGumZqcu/nA+pYB/+xm+7Jeym7kr4DL8f 9OAhJmt0pOMZRoAqawMbxgx5HMMOcabReULnBSa+X4IgDKWV1FeTOBiXKrt6VUOHLDWI yMHA== X-Gm-Message-State: AOJu0YzKa5FErb8P35quxPS/i9rT8SWTcPmS7wAQcEHl+/XKmna2Qi0k hmAMlJMBLQqf0TFAyt2NV8uObN2YqRJ/1OdVWjE= X-Google-Smtp-Source: AGHT+IFT1lPCQQokpjelwdlVMtVp0gs3P1QUgR+e9aaA0thH2uvJnEZc/w9EFq8YNGCJEIyTmJq3hg== X-Received: by 2002:a25:6b47:0:b0:da0:cd7b:5cb3 with SMTP id o7-20020a256b47000000b00da0cd7b5cb3mr3919751ybm.15.1698438334693; Fri, 27 Oct 2023 13:25:34 -0700 (PDT) Received: from [192.168.15.31] (189-46-2-229.dsl.telesp.net.br. [189.46.2.229]) by smtp.gmail.com with ESMTPSA id n128-20020a254086000000b00d89679f6d22sm956104yba.64.2023.10.27.13.25.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Oct 2023 13:25:33 -0700 (PDT) Message-ID: Date: Fri, 27 Oct 2023 17:24:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 0/7] Use introsort for qsort Content-Language: en-US To: Noah Goldstein Cc: libc-alpha@sourceware.org, Paul Eggert , Florian Weimer References: <20231003122251.3325435-1-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 03/10/23 15:13, Noah Goldstein wrote: > On Tue, Oct 3, 2023 at 5:22 AM Adhemerval Zanella > 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 ;) ?