Content-Length: 323866 | pFad | http://github.com/postgres/postgres/commit/21b815f92e82f6aad557d99492b12a912943fdbc

EA Fix pgbench performance issue induced by commit af35fe501. · postgres/postgres@21b815f · GitHub
Skip to content

Commit 21b815f

Browse files
committed
Fix pgbench performance issue induced by commit af35fe5.
Commit af35fe5 caused "pgbench -i" to emit a '\r' character for each data row loaded (when stderr is a terminal). That's effectively invisible on-screen, but it causes the connected terminal program to consume a lot of cycles. It's even worse if you're connected over ssh, as the data then has to pass through the ssh tunnel. Simplest fix is to move the added logic inside the if-tests that check whether to print a progress line. We could do it another way that avoids duplicating these few lines, but on the whole this seems the most transparent way to write it. Like the previous commit, back-patch to all supported versions. Reported-by: Andres Freund <andres@anarazel.de> Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/4k4drkh7bcmdezq6zbkhp25mnrzpswqi2o75d5uv2eeg3aq6q7@b7kqdmzzwzgb Backpatch-through: 13
1 parent bbf1ef7 commit 21b815f

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4983,6 +4983,16 @@ initGenerateDataClientSide(PGconn *con)
49834983
j, (int64) naccounts * scale,
49844984
(int) (((int64) j * 100) / (naccounts * (int64) scale)),
49854985
elapsed_sec, remaining_sec);
4986+
4987+
/*
4988+
* If the previous progress message is longer than the current
4989+
* one, add spaces to the current line to fully overwrite any
4990+
* remaining characters from the previous message.
4991+
*/
4992+
if (prev_chars > chars)
4993+
fprintf(stderr, "%*c", prev_chars - chars, ' ');
4994+
fputc(eol, stderr);
4995+
prev_chars = chars;
49864996
}
49874997
/* let's not call the timing for each row, but only each 100 rows */
49884998
else if (use_quiet && (j % 100 == 0))
@@ -4997,20 +5007,20 @@ initGenerateDataClientSide(PGconn *con)
49975007
j, (int64) naccounts * scale,
49985008
(int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec);
49995009

5010+
/*
5011+
* If the previous progress message is longer than the current
5012+
* one, add spaces to the current line to fully overwrite any
5013+
* remaining characters from the previous message.
5014+
*/
5015+
if (prev_chars > chars)
5016+
fprintf(stderr, "%*c", prev_chars - chars, ' ');
5017+
fputc(eol, stderr);
5018+
prev_chars = chars;
5019+
50005020
/* skip to the next interval */
50015021
log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS);
50025022
}
50035023
}
5004-
5005-
/*
5006-
* If the previous progress message is longer than the current one,
5007-
* add spaces to the current line to fully overwrite any remaining
5008-
* characters from the previous message.
5009-
*/
5010-
if (prev_chars > chars)
5011-
fprintf(stderr, "%*c", prev_chars - chars, ' ');
5012-
fputc(eol, stderr);
5013-
prev_chars = chars;
50145024
}
50155025

50165026
if (eol != '\n')

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgres/postgres/commit/21b815f92e82f6aad557d99492b12a912943fdbc

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy