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 1vsp3v-002bku-0z for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 21:26:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsp3u-000KN2-0f for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 21:26:22 +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 1vsp3t-000KMu-2u for pgsql-hackers@lists.postgresql.org; Wed, 18 Feb 2026 21:26:21 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vsp3q-000000002Hq-1u9Q for pgsql-hackers@postgresql.org; Wed, 18 Feb 2026 21:26:21 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-4639279c7a6so96935b6e.1 for ; Wed, 18 Feb 2026 13:26:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771449977; x=1772054777; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3h6Ph9kXw4vyP0CEKg2orrstjRGwmsuxLe8aC2tIumQ=; b=X7MFHOtb6ix0hNkRCDX9mV7oCiXwqbEtDdHx4jiv1EXpnUbeCKhRTjTHNNjUsozffD ZqWvDjegBS7mdwpOsOQM3lelW0iiDXSzYRe266tHnYl9tzbuXTZWFsl/npVURPBfI5lW Pq1cleT3KJAM14XFem77vITv4TiwTlOcclQuBVjPu5udVaa0R40iagbHa/59ZWQavGdg ZqpRLAa0d9oO6uXu8ofufzrzVz1wXAMLk7ZNPoACwCYKLhneybCxzXWv/xu/XK1G1N6M viJkGnmwCUfgcmH7R1i89JNSeZODwzD7x7UwESwzxcKg32BuaPzMcriZrt4fQSjsObr9 5PEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771449977; x=1772054777; h=in-reply-to: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=3h6Ph9kXw4vyP0CEKg2orrstjRGwmsuxLe8aC2tIumQ=; b=CFKzSzuRpTlI1GTO4BXmTT5yaIj7HjE7MXSxYTcH07iGP0NZGzl6AWZMhOUFlxA0z7 Q58RfZ8iAtwpJchzP4eD/Bs/Z10S1JEKWZZZlkTTDoRSWaWF3vjOZllPZaM45b3dJWR3 0TQn/tIk1YRekviZVCk4fjVUMUjXDcj+M0qMuv7YPI9Z6mNTpIERIa7K95HmsAUUxkuP hZ7lqhL+ZQ8syEQGL3335zxvmdZ0zWkUu/K9mw1UiCylu2ru7Oruuo7vM2yld4+ss1Go ljs3fbuhoaiQLjvkx2fDnEaHLU1v2AleoXivy2M3Qcu6R87QHEUbAb5jbWwOLgKBIKCW iRWA== X-Forwarded-Encrypted: i=1; AJvYcCUQptmi2RnTVQkJ3dg4sJUVT9Bpg1hyQMhaegpbbHtBVx/xzn1VM+GdQy1ZkmgK+Fgpddgx5SEdQYw4O1Hh@postgresql.org X-Gm-Message-State: AOJu0YxsV1YNAlmfEXS/ZV3B+zizjPS8zGfRS8NqcKnltDiDjhanNHmc xyjyGre7xM8t6KsOOm3d8ENYxoDNld3DvbzEd98ghXJYN0HIjRU1Tt4e X-Gm-Gg: AZuq6aKrLrzAfvlCW9X3C4UWEyBx9pYlJ2hF5Bz+xiwKjWkk/e5iVIpc3zfsz9+TwZ2 B1Bo36Hukn1NiJ1LfffijnPUrYzoAp5BTm1QyaC1AgbDzhiHKBm0XXmCpuxfGNXzCHAorHShOc0 si3HNlbN1G5ATDi6DlRJRf/9bLkNQfSOitjK9ceUPcw7Fp0WQivKGSPW0YFhIRHjVBQQluWFRzo o0yUC2oW75Kv1yYQ7q/PjtH9DsoyhBZNT3J1qhu8bKBKPHbD0SjK+3BZeTnnXZdHbS+xl+BLNID 9ix61bmVEzGArgvdmPhSTdWVV51j5hVS0dsn+R5V4N3gnpfUDeR4+lZEq+rDiSxo992atgTBeXh RDIByuComjaxHH7Dh9cg3e/q356zm3BpQitf/FLAZZQaiQVhw+g7cAGVFp4hDsW01jxwkjOOfxx y9I3TxjlFuqlB1eIaEjM770uCsQOF4kh9CSGHb5Ly2m6g3ciY1iRCsNv7F8MO0WM44SgfbN/KYp aw2uZavY+LEXwUkALyCu92LpQA= X-Received: by 2002:a05:6808:11c6:b0:45c:8c6c:f3f7 with SMTP id 5614622812f47-463b3f204e8mr7441556b6e.29.1771449976895; Wed, 18 Feb 2026 13:26:16 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-40eaf178c1fsm21939731fac.17.2026.02.18.13.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Feb 2026 13:26:16 -0800 (PST) Date: Wed, 18 Feb 2026 15:26:14 -0600 From: Nathan Bossart To: Nazir Bilal Yavuz Cc: KAZAR Ayoub , Neil Conway , Manni Wood , 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: multipart/mixed; boundary="qJ6V/+kxsNWNoiKe" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --qJ6V/+kxsNWNoiKe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 18, 2026 at 04:38:07PM +0300, Nazir Bilal Yavuz wrote: > By looking at these results having both is_csv and simd_enabled as an > argument and sending them as constant boolean arguments help most. Thanks for doing these tests. ISTM we might as well get this initial inlining stuff committed. Thoughts? -- nathan --qJ6V/+kxsNWNoiKe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0001-Speedup-COPY-FROM-with-additional-function-inlini.patch From 516176894a682e8bd4cb32202e3726f6621ba44d Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 18 Feb 2026 14:55:39 -0600 Subject: [PATCH v8 1/1] Speedup COPY FROM with additional function inlining. Following the example set by commit 58a359e585, we can squeeze out a little more performance from COPY FROM (FORMAT {text,csv}) by forcing CopyReadLineText() to be inlined and by passing the is_csv parameter as a constant. This allows the compiler to emit specialized code with the known-const false comparisons and subsequent branches removed. Author: Nazir Bilal Yavuz Reviewed-by: Ayoub Kazar Discussion: https://postgr.es/m/CAOzEurSW8cNr6TPKsjrstnPfhf4QyQqB4tnPXGGe8N4e_v7Jig%40mail.gmail.com --- src/backend/commands/copyfromparse.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index 94d6f415a06..0aa549837b5 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -141,7 +141,8 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0"; /* non-export function prototypes */ static bool CopyReadLine(CopyFromState cstate, bool is_csv); -static bool CopyReadLineText(CopyFromState cstate, bool is_csv); +static pg_attribute_always_inline bool CopyReadLineText(CopyFromState cstate, + bool is_csv); static int CopyReadAttributesText(CopyFromState cstate); static int CopyReadAttributesCSV(CopyFromState cstate); static Datum CopyReadBinaryAttribute(CopyFromState cstate, FmgrInfo *flinfo, @@ -1173,8 +1174,18 @@ CopyReadLine(CopyFromState cstate, bool is_csv) resetStringInfo(&cstate->line_buf); cstate->line_buf_valid = false; - /* Parse data and transfer into line_buf */ - result = CopyReadLineText(cstate, is_csv); + /* + * Parse data and transfer into line_buf. + * + * Because this is performance critical, we inline CopyReadLineText() and + * pass the boolean parameters as constants to allow the compiler to emit + * specialized code with the known-const false comparisons and subsequent + * branches removed. + */ + if (is_csv) + result = CopyReadLineText(cstate, true); + else + result = CopyReadLineText(cstate, false); if (result) { @@ -1241,7 +1252,7 @@ CopyReadLine(CopyFromState cstate, bool is_csv) /* * CopyReadLineText - inner loop of CopyReadLine for text mode */ -static bool +static pg_attribute_always_inline bool CopyReadLineText(CopyFromState cstate, bool is_csv) { char *copy_input_buf; -- 2.50.1 (Apple Git-155) --qJ6V/+kxsNWNoiKe--