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 1q987O-00027w-FZ for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 17:47:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q987M-0000qk-Qr for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 17:47:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q987M-0000qL-CL for pgsql-hackers@lists.postgresql.org; Tue, 13 Jun 2023 17:47:44 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q987E-002Aql-Mc for pgsql-hackers@postgresql.org; Tue, 13 Jun 2023 17:47:43 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6b162127472so3599865a34.0 for ; Tue, 13 Jun 2023 10:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon-tech.20221208.gappssmtp.com; s=20221208; t=1686678454; x=1689270454; h=in-reply-to:references:message-id:from:to:subject:cc:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9+r0of2VdmAYJmIP3KazIOkmmUisqtETylCcoyIZUKM=; b=iV7gblBnnGPRR9dmTx4CQvzSjWcH79XJ4K43SU58QVxyALvkHKrOw3BAtDnDbL3PtB L22vySHe+NlZSwYqeWWZ7T45q6k3QLvWzTHZ7Do+ouvjkMTo9QQbqE7ewMTZacXHsMB0 S5ij1xhxr0Qe1kBahKGQnt4LKjnjz/z6xusX1VN1Upa81kx6R3XUmoTXOn2b3qvM5eIG rrHLF1SGEKQv8tFansI6VQpc5NqYT9wLbTeOT2at6pUowklZdw9rfQ04+JLsfpggWUMe tv9C7H1HIZamt5rfD0qC0Lo5oj4fJ3aOnFuHC+5nS4MTALaq/Xnbu8sELHNmoKa5/c0F UqXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686678454; x=1689270454; h=in-reply-to:references:message-id:from:to:subject:cc:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9+r0of2VdmAYJmIP3KazIOkmmUisqtETylCcoyIZUKM=; b=P6teQivrkMOWX2Qo+EB7ZhEp6bwoza7O90FbJP+SB/bXMOy0DRMWf8yGwnoAtKCLaa /8CEI7FP3VwO693py5X/vuB+EDwRulTog4NNgZ83bUGrVTtAYT4wk+C339KTSWeDp2D9 ukXqpO7kEgSBfEWKKfWaIw/GC6X+m8edb60Mg+r/Coi4sabv3+APIOprPy8ECcK9Kh9v xndTPlZrLEKPJKDSOWrOQM63asNmKqcv4fALVC7leWBnZXoCV/PcopsjH+9MQjWx/m0L gJosv+Vjau+kL4kIue3TBAVIFZF41E6PQElZtUK/Mns4WgW6Yf70Jt9s+NlZlDGGqVpY a1Ag== X-Gm-Message-State: AC+VfDxi9VHR3wJKf9BSX0qkckRIOGwoNuQ0CNfzN1EQ4CnFf9k5A60l Yc/LNU2uAsfYco3iVTf6eCfXKg== X-Google-Smtp-Source: ACHHUZ6O+8bqXvAMWA95I8AZ6Ea1Ali/8ELQy0LH+udTDjPkNV60gWUoP3aPzKoKuouSUawcPlSgIA== X-Received: by 2002:a05:6870:710:b0:1a6:7bd4:3fb with SMTP id ea16-20020a056870071000b001a67bd403fbmr5664606oab.23.1686678454731; Tue, 13 Jun 2023 10:47:34 -0700 (PDT) Received: from localhost ([2607:fb90:e696:c1dc:3996:e070:71ee:42fb]) by smtp.gmail.com with ESMTPSA id g17-20020a056870c39100b001726cfeea97sm7564809oao.29.2023.06.13.10.47.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 10:47:34 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 13 Jun 2023 12:47:33 -0500 Cc: Subject: Re: Use COPY for populating all pgbench tables To: "Tristan Partin" , "David Rowley" From: "Tristan Partin" Message-Id: X-Mailer: aerc 0.15.2-46-g263d8cbec504 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu Jun 8, 2023 at 11:38 AM CDT, Tristan Partin wrote: > On Thu Jun 8, 2023 at 12:33 AM CDT, David Rowley wrote: > > On Thu, 8 Jun 2023 at 07:16, Tristan Partin wrote: > > > > > > master: > > > > > > 50000000 of 50000000 tuples (100%) done (elapsed 260.93 s, remaining = 0.00 s)) > > > vacuuming... > > > creating primary keys... > > > done in 1414.26 s (drop tables 0.20 s, create tables 0.82 s, client-s= ide generate 1280.43 s, vacuum 2.55 s, primary keys 130.25 s). > > > > > > patchset: > > > > > > 50000000 of 50000000 tuples (100%) of pgbench_accounts done (elapsed = 243.82 s, remaining 0.00 s)) > > > vacuuming... > > > creating primary keys... > > > done in 375.66 s (drop tables 0.14 s, create tables 0.73 s, client-si= de generate 246.27 s, vacuum 2.77 s, primary keys 125.75 s). > > > > I've also previously found pgbench -i to be slow. It was a while ago, > > and IIRC, it was due to the printfPQExpBuffer() being a bottleneck > > inside pgbench. > > > > On seeing your email, it makes me wonder if PG16's hex integer > > literals might help here. These should be much faster to generate in > > pgbench and also parse on the postgres side. > > > > I wrote a quick and dirty patch to try that and I'm not really getting > > the same performance increases as I'd have expected. I also tested > > with your patch too and it does not look that impressive either when > > running pgbench on the same machine as postgres. > > I didn't expect my patch to increase performance in all workloads. I was > mainly aiming to fix high-latency connections. Based on your results > that looks like a 4% reduction in performance of client-side data > generation. I had thought maybe it is worth having a flag to keep the > old way too, but I am not sure a 4% hit is really that big of a deal. > > > pgbench copy speedup > > > > ** master > > drowley@amd3990x:~$ pgbench -i -s 1000 postgres > > 100000000 of 100000000 tuples (100%) done (elapsed 74.15 s, remaining 0= .00 s) > > vacuuming... > > creating primary keys... > > done in 95.71 s (drop tables 0.00 s, create tables 0.01 s, client-side > > generate 74.45 s, vacuum 0.12 s, primary keys 21.13 s). > > > > ** David's Patched > > drowley@amd3990x:~$ pgbench -i -s 1000 postgres > > 100000000 of 100000000 tuples (100%) done (elapsed 69.64 s, remaining 0= .00 s) > > vacuuming... > > creating primary keys... > > done in 90.22 s (drop tables 0.00 s, create tables 0.01 s, client-side > > generate 69.91 s, vacuum 0.12 s, primary keys 20.18 s). > > > > ** Tristan's patch > > drowley@amd3990x:~$ pgbench -i -s 1000 postgres > > 100000000 of 100000000 tuples (100%) of pgbench_accounts done (elapsed > > 77.44 s, remaining 0.00 s) > > vacuuming... > > creating primary keys... > > done in 98.64 s (drop tables 0.00 s, create tables 0.01 s, client-side > > generate 77.47 s, vacuum 0.12 s, primary keys 21.04 s). > > > > I'm interested to see what numbers you get. You'd need to test on > > PG16 however. I left the old code in place to generate the decimal > > numbers for versions < 16. > > I will try to test this soon and follow up on the thread. I definitely > see no problems with your patch as is though. I would be more than happy > to rebase my patches on yours. Finally got around to doing more benchmarking. Using an EC2 instance hosted in Ireland, and my client laptop in Austin, Texas. Workload: pgbench -i -s 500 master (9aee26a491) done in 1369.41 s (drop tables 0.21 s, create tables 0.72 s, client-side ge= nerate 1336.44 s, vacuum 1.02 s, primary keys 31.03 s). done in 1318.31 s (drop tables 0.21 s, create tables 0.72 s, client-side ge= nerate 1282.67 s, vacuum 1.02 s, primary keys 33.69 s). copy done in 307.42 s (drop tables 0.21 s, create tables 0.82 s, client-side gen= erate 270.95 s, vacuum 1.02 s, primary keys 34.42 s). david done in 1311.14 s (drop tables 0.72 s, create tables 0.72 s, client-side ge= nerate 1274.98 s, vacuum 0.94 s, primary keys 33.79 s). done in 1340.18 s (drop tables 0.14 s, create tables 0.59 s, client-side ge= nerate 1304.78 s, vacuum 0.92 s, primary keys 33.75 s). copy + david done in 348.70 s (drop tables 0.23 s, create tables 0.72 s, client-side gen= erate 312.94 s, vacuum 0.92 s, primary keys 33.90 s). I ran two tests for master and your patch David. For the last test, I adapted your patch onto mine. I am still seeing the huge performance gains on my branch. --=20 Tristan Partin Neon (https://neon.tech)