Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxBLi-00Bhu3-Em for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Sep 2025 21:30:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxBLe-0044zr-Al for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Sep 2025 21:30:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxBLd-0044zf-Np for pgsql-hackers@lists.postgresql.org; Fri, 12 Sep 2025 21:30:26 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uxBLb-00069o-3C for pgsql-hackers@postgresql.org; Fri, 12 Sep 2025 21:30:25 +0000 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-4103fb72537so25362255ab.0 for ; Fri, 12 Sep 2025 14:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757712623; x=1758317423; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ZjCq5NvmdoEv+LWUyc0wUonPsdHgVvUzZMUqPx5+A5k=; b=JPAIq6FqGbni7/BlcboFyRwNu+p+wf/nkWXwtwUK0pC6h5YnED6c3CJr2oJN0eD17x wkw2efIvkZxQmWAW+zfXGmDohH+hNNCcesZaP75kbQXbMrx6Y28GJRrs1BwFZO+C+9V5 TxjOdvNTGEz698+cggI6keZhKGffvL9E1xxovRijj1LGp93/IlR1R0lhvPvacOuDGr7+ IZePEHDWfYNh/0VionxN3P2j6wPdRxO2qPnkAkPgDOiEo381y9UnyrPtsBjX6yXOWyXo wUeUY31N6WT/a+LbwpNQtPTuFXa6mK06qTLnvPPhmz5O9zPpgvEN1BIS5nnk7c03KRec hbnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757712623; x=1758317423; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZjCq5NvmdoEv+LWUyc0wUonPsdHgVvUzZMUqPx5+A5k=; b=wGE1hSfnlNr5EPaRcrSpQ07mefy4CttWWlW/k4hBgW1mHbDL4i7Bqe6WmXoPSJpmu4 T7hYPmwlFgVxgTXMnr7p6S+/ZEE9EPnNy9X8KFOhk9czCyHEyxGYC5hTnkeqcDGAAAs1 dITJY7ZqG/3QyIl8Y/RXSpD6+++VuVmMCgkz01dIJv5cE0+/W0G51nhV4NftAtKPtjIz +qzvGutRaEozbW78xTvc7g+3IsktlEh3wkwoRfLuEf8Pam+PceZX/5Tjm0KvWqjQEasg USl0UIQ9ZKVYODPrrJw05nTIUP/jJgokTH7V2tBfHCBYuxVHGfeu5544XLVwuN+w2eVq SCSg== X-Forwarded-Encrypted: i=1; AJvYcCXJ10+0X0PUWMFNDcaGXpZahZMjp5OiTmfREodX8yAN8HKA1qZimGbBb4Ql0sTivzbecEdAXTZU9vJGimju@postgresql.org X-Gm-Message-State: AOJu0Yw47JZcjvEZ6A76JduSnZ9WjJhVTbY7O7hZh9kK7056RZwuksLH B+PZc+RlOZp3Qj4q5L8iXz1TwZ+7UI5oBOyt9MDl7w8cZCC9VkXZIG2V X-Gm-Gg: ASbGncuqTQDUIiT/+ydGVVTYJhNUMMjuv1N0nWLWKEqGTiOJllR4Jh0bn0A0mPXFMaL +J1v79bc6ZF3MXDhAZQk542KUo89MWLcfsFxBRR4el3oBbu08XFZfrX5aJPiM9COQbjxzlanaTa JDNr09UOxkAEyhnkyVE5QmZgFGe0nRycfEfmU27W0+P/zax1qjARkhQYULM09SjXMbt+fND3DJU saVhhJVRGQBptInLblxjepfIUr7B5t5ADfpnKlyhW8WAawfr4LNGLKOekW6aSNtOhPt4S9MMKCx NLhG8gCm4havQXj5qXzrOrEPqzAU3FgDsnbxbYpBYs7JVLErf5v9CDggLF10OdKQLUWQi0rZApq GLxUzxmO3EH+1eEA8WHzAUnKseJIBgO+T8phS1+GCOT+ij1lHVzaSlIs2ni3ErQSzaf7/zBI0FE FVvdv8ue5L12L5sgvaNp6k4NU= X-Google-Smtp-Source: AGHT+IHW3IxDZN5Lkafl7XOVMwG3OOlsSE3avJ/C2+KM7iAvnn+l2RMnRqQ1h1+H+GG1YUi3/KmofQ== X-Received: by 2002:a05:6e02:1b03:b0:403:ecdc:91e7 with SMTP id e9e14a558f8ab-420a426898dmr64231525ab.24.1757712623499; Fri, 12 Sep 2025 14:30:23 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-41df8eb525dsm24563045ab.28.2025.09.12.14.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Sep 2025 14:30:22 -0700 (PDT) Date: Fri, 12 Sep 2025 16:30:21 -0500 From: Nathan Bossart To: "Chiranmoy.Bhattacharya@fujitsu.com" Cc: Tom Lane , John Naylor , David Rowley , "pgsql-hackers@postgresql.org" , "Devanga.Susmitha@fujitsu.com" , "Ragesh.Hajela@fujitsu.com" Subject: Re: [PATCH] Hex-coding optimizations using SVE on ARM. Message-ID: References: <1787140.1757604720@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="RTY7yQ9xOxj5kkz7" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --RTY7yQ9xOxj5kkz7 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Sep 12, 2025 at 06:49:01PM +0000, Chiranmoy.Bhattacharya@fujitsu.com wrote: > Using simd.h does make it easier to maintain. Is there a plan to upgrade > simd.h to use SSE4 or SSSE3 in the future? Since SSE2 is much older, it > lacks some of the more specialized intrinsics. For example, vectorized > table lookup can be implemented via [0], and it’s available in SSSE3 and > later x86 instruction sets. There have been a couple of discussions about the possibility of requiring x86-64-v2 for Postgres, but I'm not aware of any serious efforts in that area. I've attached a new version of the patch with a simd.h version of hex_decode(). Here are the numbers: arm buf | HEAD | patch | % diff -------+-------+-------+-------- 16 | 22 | 23 | -5 64 | 61 | 23 | 62 256 | 158 | 47 | 70 1024 | 542 | 122 | 77 4096 | 2103 | 429 | 80 16384 | 8548 | 1673 | 80 65536 | 34663 | 6738 | 81 x86 buf | HEAD | patch | % diff -------+-------+-------+-------- 16 | 13 | 14 | -8 64 | 42 | 15 | 64 256 | 126 | 42 | 67 1024 | 461 | 149 | 68 4096 | 1802 | 576 | 68 16384 | 7166 | 2280 | 68 65536 | 28625 | 9108 | 68 A couple of notes: * For hex_decode(), we just give up on the SIMD path and fall back on the scalar path as soon as we see anything outside [0-9A-Za-z]. I suspect this might introduce a regression for inputs of ~32 to ~64 bytes that include whitespace (which must be skipped) or invalid characters, but I don't whether those inputs are common or whether we care. * The code makes some assumptions about endianness that might not be true everywhere, but I've yet to dig into this further. -- nathan --RTY7yQ9xOxj5kkz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v9-0001-Optimize-hex_encode-and-hex_decode-using-SIMD.patch