Re: Fix for Extra Parenthesis in pgbench progress message
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Tatsuo Ishii <ishii@postgresql.org>, btogiwarayuushi@oss.nttdata.com
Cc: pgsql-hackers@postgresql.org
Date: 2024-11-06T16:30:32Z
Lists: pgsql-hackers
On 2024/11/02 20:43, Tatsuo Ishii wrote: >> Hi, >> >> I noticed an issue in the pgbench progress message where an extra >> closing parenthesis )) appears, as shown below: >> >> 7000000 of 10000000 tuples (70%) of pgbench_accounts done (elapsed >> 19.75 s, remaining 8.46 s)) > > Yeah, annoying. > >> This occurs when running commands like pgbench -i -s100 and is caused >> by leftover characters when using \r with fprintf. I made a patch to >> address this by adding extra spaces before \r, which clears any >> remaining characters. While effective, I recognize this solution may >> not be the most sophisticated. > > The patch works perfectly for the case that there is one extra brace > as shown in your example. However I think it will not work if there > are two or more extra braces. Are you suggesting adding more space characters before the carriage return in the progress reporting line, like this? Since the line includes both elapsed and remaining times, its total length doesn’t change much. I think adding five spaces before the carriage return should be enough. Thoughts? - chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s) %c", + chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)%5s%c", j, total, (int) ((j * 100) / total), - table, elapsed_sec, remaining_sec, eol); + table, elapsed_sec, remaining_sec, "", eol); Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION
Commits
-
Fix pgbench performance issue induced by commit af35fe501.
- b6decfc1d22b 13.19 landed
- 5addea71c7c7 14.16 landed
- 499d1cf55d3d 15.11 landed
- fb056564ec5b 18.0 landed
- e35d396ec354 17.3 landed
- 21b815f92e82 16.7 landed
-
pgbench: Ensure previous progress message is fully cleared when updating.
- f1cb5e51f329 13.19 landed
- 0f13e1a78b14 14.16 landed
- 1e46f7351abc 15.11 landed
- 1cf646957135 16.7 landed
- adb103fcacdd 17.3 landed
- af35fe501af5 18.0 landed