Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1od74w-0007db-A1 for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Sep 2022 09:40:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1od73w-0006Np-QF for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Sep 2022 09:39:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1od73w-0006NH-Dd for pgsql-hackers@lists.postgresql.org; Tue, 27 Sep 2022 09:39:36 +0000 Received: from mx.zeyos.com ([88.99.153.70]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1od73u-0001ie-08 for pgsql-hackers@postgresql.org; Tue, 27 Sep 2022 09:39:35 +0000 Received: from mx.zeyos.com (localhost [127.0.0.1]) by mx.zeyos.com (Postfix) with ESMTP id 77B8461990 for ; Tue, 27 Sep 2022 11:39:31 +0200 (CEST) Authentication-Results: mx.zeyos.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=zeyos.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeyos.com; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:to:from:from:subject:subject :date:date; s=dkim; t=1664271571; x=1665135572; bh=n/X6v7ClnuoWo N5CCv56JYosb9SPDbJw5tw+jjymKWY=; b=Q1P+lIzhYV8Dw9WuMNtjGSi6V/rPw qTqgXzSlao7HhOUkLrStpJSg7/2Sqe06u9M9vR0T6GYEh/dWH6ptF70mRL7CVJJE UpQf3ly/V+AF9aONLgN5jeqpt8FqMB3tg7NS6TB+SuGXzMBVASAxBqJs/vKpVssq 6EvjLQMBs/Agzw= X-Virus-Scanned: Debian amavisd-new at mx.zeyos.com Received: from mx.zeyos.com ([127.0.0.1]) by mx.zeyos.com (mx.zeyos.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wf4QKXJef4Zr for ; Tue, 27 Sep 2022 11:39:31 +0200 (CEST) Received: from cloud.zeyos.com (static.182.82.88.23.clients.your-server.de [23.88.82.182]) by mx.zeyos.com (Postfix) with ESMTPSA id 5119A61983; Tue, 27 Sep 2022 11:39:31 +0200 (CEST) Date: Tue, 27 Sep 2022 11:39:31 +0200 Subject: Re: Insertion Sort Improvements From: Benjamin Coutu To: John Naylor Cc: pgsql-hackers Message-ID: <6047084d3cc4d8cf4ef7@zeyos.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Getting back to improvements for small sort runs, it might make sense to co= nsider using in-register based sorting via sorting networks for very small = runs.=0A=0AThis talk is specific to database sorting and illustrates how su= ch an approach can be vectorized: https://youtu.be/HeFwVNHsDzc?list=3DPLSE8= ODhjZXjasmrEd2_Yi1deeE360zv5O&t=3D1090=0A=0AIt looks like some of the comme= rcial DBMSs do this very successfully. They use 4 512bit registers (AVX-512= ) in this example, which could technically store 4 * 4 sort-elements (given= that the sorting key is 64 bit and the tuple pointer is 64 bit). I wonder = whether this could also be done with just SSE (instead of AVX), which the p= roject now readily supports thanks to your recent efforts?