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.96) (envelope-from ) id 1vlwcb-005YfH-1m for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jan 2026 22:05:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vlwcY-006T7q-0u for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Jan 2026 22:05:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vlwcX-006T7g-32 for pgsql-hackers@lists.postgresql.org; Fri, 30 Jan 2026 22:05:42 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vlwcW-00000000GH5-0R56 for pgsql-hackers@postgresql.org; Fri, 30 Jan 2026 22:05:42 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-1248d27f2b9so3707174c88.0 for ; Fri, 30 Jan 2026 14:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769810737; x=1770415537; 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=Tzj/oBFrtuYJ5wQDn9loxKhCaPrxqZZkzVqrzJR/Jxw=; b=Q4doFdgqX5+Hg9Lh17eQwW1F26AiNcE4e24VRe66Wpy6uK2B0bB4jhniygELaDoeW+ WEMpUT2E9DPTuymFzyNXK1oEG4ENct0EIPvfOul+mSpVVhAMz4pY9impVyo6KfdezQ3K daETFH+F7cVAv8TFxCrt42HXRfZMzw2qHECpKHLotbCh/HejNRG1DeQyFmetlvrchddX 1HTfdkCP/SCZ+oEsw1vc6IQbovsX5oz2VFF5YLSXcyztD1AYX4EKzkJrVhs0m/ngdUxc smieb1piqvp4LgqPrlIdl4k79rKBr3fD0dIkhuoXlcnHs5+pbXzehqSllXxclzCl98HO Y8Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769810737; x=1770415537; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Tzj/oBFrtuYJ5wQDn9loxKhCaPrxqZZkzVqrzJR/Jxw=; b=UZlfA7Pm/ZxpNcPCQo9uZNnnn033yOkgy39DWKB6NL02YWKAWhsZ6jPocICrGn4uRk JLZKum4bBAcJ/boBtcY8B6jglztT0OgiDhnAdmIrmwqczAFdCYitzvfder8kNM7HgK1O k9STpdBmrsRoYmEtU6JoRW9DYQY6bvDxKSIx4+EZsjc0dRVNeiQGZp/4+Fg8SMS9wgtU O5t/fikuOhCSiB/KczlCMDxXrJSzYVoplK2ZLI3GybJumKryt6vBJcJlWMJanbtckRDL 6zYaqVjnVkOrJXWFzM/6DlFood+SqmwU8pEmxbnUu1S/F0uTrziNJRrOKzBlcs2tRvKt kYGQ== X-Forwarded-Encrypted: i=1; AJvYcCVM7I4nbNG5vSRL86IKKCGBqauMnVsPCJ3jt/JJPAUPK2VVe+Y4Snv0oNRJ/ASAmRC9fsyKHA24s6VaIOyC@postgresql.org X-Gm-Message-State: AOJu0YyKQOrlPDrOUgUItAuqyleuNTFW4x34XVbqAq0cLFLNBx9fPZ8O P7VQewo6M+pIepNnjRw3McUt5k+IQnsb4QBZUOSeUF3KFC/227PKI0uA X-Gm-Gg: AZuq6aL+Gprl6TIXLtg23ozaxByz3Jy3Y6KGZaQVzjQcETCi6GqTAor6rJefs+iffRQ oCoKMP65gjZC0CuTXUuG/Afyi2OkK5Hff9YzHHRMLLiFExQyZPNFfT8sOMVfzzYJI8oHsEEzuYi Rt4sGgJzYbLQdwtfZTixrs+PswRfwl47Yn3LO1va1XVeuqO46ua1KqdphwxFG9Jf8mI6Oy2yBx/ URv9kYzSsvJZaqkJNLfBk7+Ivx4UeeBIxsvg/Yqt2UgaGJAh3XupMaxw39V5Zk6rd0GKfGv/ema vTUNrEiKhvLpNWtiBgASqVhV5FW5NbO9PR/PWQt6CCesboMFTWs7noaeAABbkW9cPryTIzm4kcM fwDRRWsKSww4pdZ1EHmUTpaNTnzXI+Jmvnnearq2tnwxPXyqkJl33xTTM5Y7GjWkHchuT5SLaUy RLCLzSt4xcCkCOP1d/+ukl93II9jBLvw== X-Received: by 2002:a05:7022:6185:b0:11e:3e9:3ea3 with SMTP id a92af1059eb24-125c102e041mr1947431c88.50.1769810737062; Fri, 30 Jan 2026 14:05:37 -0800 (PST) Received: from o (71-34-92-171.ptld.qwest.net. [71.34.92.171]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-124a9df97d0sm11942897c88.13.2026.01.30.14.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 14:05:36 -0800 (PST) Date: Fri, 30 Jan 2026 14:05:33 -0800 From: Mark Wong To: Manni Wood Cc: Nazir Bilal Yavuz , KAZAR Ayoub , Nathan Bossart , Andrew Dunstan , Shinya Kato , PostgreSQL-development Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 On Tue, Jan 13, 2026 at 06:20:27PM -0600, Manni Wood wrote: > On Tue, Jan 13, 2026 at 1:12 PM Mark Wong wrote: > > > On Fri, Jan 09, 2026 at 05:21:45PM +0300, Nazir Bilal Yavuz wrote: > > > Were you able to understand why Mark's benchmark results are different > > > from ours? > > > > Not yet... I had some guesses, which is why I suggested the processor > > pinning > > and using a ramdisk. But we haven't tried applying all of those to my > > laptop, > > which has 3 core types, or the POWER system, which may be interesting to > > use a > > ram disk on. > > > > I'm curious though, and admittedly haven't tried looking myself yet, about > > how > > the SIMD calls might look across different processor architectures. We'll > > try > > to get that on the POWER system soon... > > > > Regards, > > Mark > > Hello! > > Nazir, I'm glad you are finding the benchmarks useful. I have more! :-) > > All of these benchmarks are all-in-RAM, because I do think that is the best > way of getting closest to the theoretical best and worst case scenarios. > > My laptop: > > master: (852558b9) > > text, no special: 14996 > text, 1/3 special: 17270 > csv, no special: 18274 > csv, 1/3 special: 23852 > > v3 > > text, no special: 11282 (24.7% speedup) > text, 1/3 special: 15748 (8.8% speedup) <-- I don't believe this but it's > what I got > csv, no special: 11571 (36.6% speedup) > csv, 1/3 special: 19934 (16.4% speedup) <-- I don't believe this but it's > what I got > > v4.2 > > text, no special: 11139 (25.7% speedup) > text, 1/3 special: 18900 (9.4% regression) > csv, no special: 11490 (37.1% speedup) > csv, 1/3 special: 26134 (9.5% regression) > > An AWS EC2 t2.2xlarge instance > > master: (852558b9) > > text, no special: 20677 > text, 1/3 special: 22660 > csv, no special: 24534 > csv, 1/3 special: 30999 > > v3 > > text, no special: 17534 (15.2% speedup) > text, 1/3 special: 22816 (0.6% regression) > csv, no special: 17664 (28.0% speedup) > csv, 1/3 special: 29338 (5.3% speedup) <-- I don't believe this but it's > what I got > > v4.2 > > text, no special: 17459 (15.5% speedup) > text, 1/3 special: 25051 (10.5% regression) > csv, no special: 17574 (28.3% speedup) > csv, 1/3 special: 32092 (3.5% regression) > > An AWS EC2 t4g.2xlarge instance (using ARM processor; first test of ARM > processor!) > > master: (852558b9) > > text, no special: 22081 > text, 1/3 special: 25100 > csv, no special: 27296 > csv, 1/3 special: 32344 > > v3 > > text, no special: 17724 (19.7% speedup) > text, 1/3 special: 27606 (9.9% regression) <-- yikes! We would want to test > this more > csv, no special: 17597 (35.5% speedup) > csv, 1/3 special: 32597 (0.8% regression) > > v4.2 > > text, no special: 17674 (20% speedup) > text, 1/3 special: 25773 (2.6% regression) <-- this regression is less than > for the v3 patch? Atypical... > csv, no special: 17651 (35.3% speedup) > csv, 1/3 special: 34055 (5.3% regression) I'm still lagging behind a little I ran the v4.2 patches again applied to 71c11369 on the POWER system that I have access to, using Manni's copysimdperf scripts to use a ramdisk and processor pinning. text, no special: -2508 (30% speedup) text, 1/3 special: -1753 (48% speedup) csv, no special: 9264 (3% regression) csv, 1/3 special: -4077 (0.3% speedup) Using Manni's script makes me feel more confident about executing the tests in the same way, so I don't know how concerning the difference in results are compared to the other architectures. > Yes, I think I agree with you that the everything-in-RAM benchmarks will > make the regressions more pronounced, just like the everything-in-RAM > benchmarks make the improvements more pronounced. > > I am not sure why the CSV regression, compared to the TXT regression (even > for the v3 patch which has smaller regressions than the v4.2 patch) is > usually worse. I probably should look over some flame graphs and see if I > can find the place where the CSV-parsing code is so much slower. The CSV > regression is actually a bit frustrating (at around 5%) because the TXT > regression, at less than 1% (for the v3 patch) is so much easier to bare. > > Here are some copy-to benchmarks for the v4 patch that applies SIMD to the > copy-to code. > > These were all-in-RAM tests. > > My laptop > > master: (852558b9) > > text, no special: 2948 > text, 1/3 special: 11258 > csv, no special: 6245 > csv, 1/3 special: 11258 > > v4 (copy to) > > text, no special: 2126 (27.9% speedup) > text, 1/3 special: 12080 (7.3% regression) <-- did not see such a big > regression before > csv, no special: 2432 (61.0% speedup) > csv, 1/3 special: 12344 (4.0% regression) <-- did not see such a big > regression before > > An AWS EC2 t2.2xlarge instance > > master: (852558b9) > > text, no special: 4647 > text, 1/3 special: 13865 > csv, no special: 5421 > csv, 1/3 special: 15284 > > v4 (copy to) > > text, no special: 2460 (47.0% speedup) > text, 1/3 special: 14023 (1.1% regression) > csv, no special: 2667 (50.7% speedup) > csv, 1/3 special: 15251 (0.2% speedup) > > An AWS EC2 t4g.2xlarge instance (using ARM processor; first test of ARM > processor!) > > master: (852558b9) > > text, no special: 6951 > text, 1/3 special: 17857 > csv, no special: 7951 > csv, 1/3 special: 18504 > > v4 (copy to) > > text, no special: 3372 (51.4% speedup) > text, 1/3 special: 15713 (12.0% speedup) > csv, no special: 3233 (59.3% speedup) > csv, 1/3 special: 1622 (12.3% speedup) > > Once again, the v4 patch for copy-to seems like a clearer win, though, to > be fair, there were regressions when running on my laptop. (I'm starting to > think servers or desktops are better than laptops for testing these things, > though maybe that's my bias: it just seems like the server results are > always less surprising.) > > Hope you all continue to find these useful... Regards, Mark -- Mark Wong EDB https://enterprisedb.com