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 1tGEYb-001gNZ-Sv for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2024 09:42:01 +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 1tGEYa-00DOVn-1Y for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2024 09:42:00 +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 1tGEYZ-00DOVe-Ns for pgsql-hackers@lists.postgresql.org; Wed, 27 Nov 2024 09:41:59 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGEYW-0047t6-RJ for pgsql-hackers@postgresql.org; Wed, 27 Nov 2024 09:41:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=wVTzKIDLQ2rNpvvId5cLhqx2HmuLekAAOMqkvAnWmng=; b=wtw+/3GGwgmWgdSYZWpPHBj4JN LjqrRqV8S5duhkqXq/rxNHgLW2xhXpXhAR2iISxbq26YgaQK5YDSgYsMbvdN8CjmTH0CERO1+9Jmu n5pSZOEs6RHd7rUmzrZ2Zq5Onq7fv4vT6H19+S/I4cKpmbvT8UAfjvuu3PYHKquQ2/hhx+NGCBP83 PQg5ceLAnrmInpbgZISregdxW6w46wQpizg6FtPZQc/YmqcqZgexUXvaYsho2WDd/9ZVTXYvPp20R ceFIrEQpSbAfbAcBGuRerd0KWmJQmyLtlSfeoBhHdVyXoHHrduJ26JJQC7VcnaZn3yD4o5hOdKvQ0 iHHXrNqA==; Received: from [2409:11:4120:300:d7ba:aed9:899:b132] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1tGEYS-00AfAj-Pd; Wed, 27 Nov 2024 09:41:55 +0000 Date: Wed, 27 Nov 2024 18:41:40 +0900 (JST) Message-Id: <20241127.184140.897862112615216224.ishii@postgresql.org> To: masao.fujii@oss.nttdata.com Cc: pgsql-hackers@postgresql.org Subject: Re: Fix for Extra Parenthesis in pgbench progress message From: Tatsuo Ishii In-Reply-To: References: <95f1100e-e59b-41b7-a406-f865c2e69db7@oss.nttdata.com> <20241125.083155.1820744655877715597.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Nov_27_18_41_40_2024_553)--" Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:d7ba:aed9:899:b132 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----Next_Part(Wed_Nov_27_18_41_40_2024_553)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Yes, I will. > > But, the patch didn't apply cleanly to some back branches, so I've > created > and attached updated patches for them. Could you review these? > If they look good, I'll proceed with pushing them. Sure. The patch for master to v15 look good to me. Unfortunately v5-0001-pgbench-Ensure-previous-progress-message-is-fully-pg13-14.patch applies to v14 but does not apply to v13. $ git checkout REL_13_STABLE Switched to branch 'REL_13_STABLE' Your branch is up to date with 'origin/REL_13_STABLE'. $ git apply ~/v5-0001-pgbench-Ensure-previous-progress-message-is-fully-pg13-14.patch error: patch failed: src/bin/pgbench/pgbench.c:4222 error: src/bin/pgbench/pgbench.c: patch does not apply So I created a patch for pg13 using patch command. Attached is the patch for pg13. Best reagards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp ----Next_Part(Wed_Nov_27_18_41_40_2024_553)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pgbench_v13.patch" diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 6ea89cabc9..6bccacaf86 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3840,6 +3840,8 @@ initGenerateDataClientSide(PGconn *con) PGresult *res; int i; int64 k; + int chars = 0; + int prev_chars = 0; /* used to track elapsed time and estimate of the remaining time */ instr_time start, @@ -3926,10 +3928,10 @@ initGenerateDataClientSide(PGconn *con) elapsed_sec = INSTR_TIME_GET_DOUBLE(diff); remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j; - fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c", - j, (int64) naccounts * scale, - (int) (((int64) j * 100) / (naccounts * (int64) scale)), - elapsed_sec, remaining_sec, eol); + chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)", + j, (int64) naccounts * scale, + (int) (((int64) j * 100) / (naccounts * (int64) scale)), + elapsed_sec, remaining_sec); } /* let's not call the timing for each row, but only each 100 rows */ else if (use_quiet && (j % 100 == 0)) @@ -3943,14 +3945,24 @@ initGenerateDataClientSide(PGconn *con) /* have we reached the next interval (or end)? */ if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS)) { - fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c", - j, (int64) naccounts * scale, - (int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec, eol); + chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)", + j, (int64) naccounts * scale, + (int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec); /* skip to the next interval */ log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS); } } + + /* + * If the previous progress message is longer than the current one, + * add spaces to the current line to fully overwrite any remaining + * characters from the previous message. + */ + if (prev_chars > chars) + fprintf(stderr, "%*c", prev_chars - chars, ' '); + fputc(eol, stderr); + prev_chars = chars; } if (eol != '\n') ----Next_Part(Wed_Nov_27_18_41_40_2024_553)----