From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0AA3B3858D38 for ; Wed, 6 Dec 2023 10:21:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0AA3B3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0AA3B3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701858087; cv=none; b=FFezZqU/sCYB4Qa75ie2xFA26uQ7ZNPeMxaQTvcYMCGWUnEBdcTdI4Y5Ds8uBUwOMgl4VR+3yLxTCscZxs2E3EV2Ob718yaC+dA2NL3eIWvVTkjbjZwUzEKlHttIzp68cZnhN6gNMUXlN4uGprSU/XEXM6ASUUz0kA2F/y/FyYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701858087; c=relaxed/simple; bh=ACiiQ/xt92TI4hiWXJgTv8u4ld821+Q0QxMoT9cwTpw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eIJVcGwz1M1eK7pTlt6oCzw8LZ2U3zUV5fwfD4UTlNZGvm1MNji+bIKqY2MBOTf9+Vsr7cpdRUSFmqSWzUoysQZduNjF98QA2S+akBn8LPJxHYZI64+iOEQqRj+tC65HAPGe/eJuMfocw0ciG3ixG7beZ6mhzmmDN/lqEITqOoo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701858082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qksYSfBr4HiHAUSl5+mT2OMD5ec0Z1NaD1EGnhjXvTQ=; b=PBQCvCAMRfNPPnEdP5+J+qtUV6Aas/GUwK22TGVhrlsJtbSIi3UPFJpOvvt26y7bJvGk5c e19yAiHW+xwW6zPHrH4LHekfHKHWRuaixTwn4Zjcco30iM+SoebIvzlk0LgqPh60e1RyvE jEGN2Zj1po7N5hiWUrQHVTV3SRoQfKc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-Q-2gyg00PM6mxlhM_VSsIw-1; Wed, 06 Dec 2023 05:21:19 -0500 X-MC-Unique: Q-2gyg00PM6mxlhM_VSsIw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BC6C835146; Wed, 6 Dec 2023 10:21:19 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1E083C30; Wed, 6 Dec 2023 10:21:17 +0000 (UTC) From: Florian Weimer To: "Zack Weinberg" Cc: "Kuan-Wei Chiu" , "GNU libc development" , "Adhemerval Zanella" , goldstein.w.n@gmail.com Subject: Re: [PATCH] stdlib: Optimize number of calls to comparison function References: <20231202214839.2634493-1-visitorckw@gmail.com> <87y1eaxtst.fsf@oldenburg.str.redhat.com> Date: Wed, 06 Dec 2023 11:21:15 +0100 In-Reply-To: (Zack Weinberg's message of "Tue, 05 Dec 2023 15:35:33 -0500") Message-ID: <87plzjd42s.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Zack Weinberg: > On Mon, Dec 4, 2023, at 1:31 PM, Kuan-Wei Chiu wrote: >> On Mon, Dec 04, 2023 at 09:20:50AM +0100, Florian Weimer wrote: >>> I think the factor in stdlib/tst-qsort5.c needs to be adjusted: >>>=20 >>> /* This is an arbitrary factor which is true for the current >>> implementation across a wide range of sizes. */ >>> TEST_VERIFY (factor <=3D 4.5); >> >> It seems that the factor can be adjusted to around 3.5. I can send >> another patch for this adjustment or resend it as a patch series. > > Before you go any further with this patch series I think we need to > decide whether our backward compatibility constraints mean our qsort > has to be a stable sort. If so, we should make it *always* be a > stable sort and write that into the documentation, and that would > mean junking the entire heapsort implementation. That makes sense, although there might not exist an in-place sorting algorithm that takes constant extra space regardless of element count and element size and has reasonable performance. Maybe we could say, =E2=80=9Cstable if element size is less than 1024 bytes=E2=80=9D or somethi= ng like that. What I'm concerned about is that with the current implementation, we take a performance hit *and* have compatibility problems. The compatibility problems would be easier to justify if we actually made things faster. Not calling malloc internally is unlikely to be compelling to programmers. Thanks, Florian