Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb05656

Browse files
committed
Fix pgbench performance issue induced by commitaf35fe5.
Commitaf35fe5 caused "pgbench -i" to emit a '\r' characterfor each data row loaded (when stderr is a terminal).That's effectively invisible on-screen, but it causes theconnected terminal program to consume a lot of cycles.It's even worse if you're connected over ssh, as the datathen has to pass through the ssh tunnel.Simplest fix is to move the added logic inside the if-teststhat check whether to print a progress line. We could doit another way that avoids duplicating these few lines,but on the whole this seems the most transparent way towrite 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@b7kqdmzzwzgbBackpatch-through: 13
1 parent11bba6e commitfb05656

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
@@ -5011,6 +5011,16 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
50115011
j,total,
50125012
(int) ((j*100) /total),
50135013
table,elapsed_sec,remaining_sec);
5014+
5015+
/*
5016+
* If the previous progress message is longer than the current
5017+
* one, add spaces to the current line to fully overwrite any
5018+
* remaining characters from the previous message.
5019+
*/
5020+
if (prev_chars>chars)
5021+
fprintf(stderr,"%*c",prev_chars-chars,' ');
5022+
fputc(eol,stderr);
5023+
prev_chars=chars;
50145024
}
50155025
/* let's not call the timing for each row, but only each 100 rows */
50165026
elseif (use_quiet&& (j %100==0))
@@ -5026,20 +5036,20 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
50265036
(int) ((j*100) /total),
50275037
table,elapsed_sec,remaining_sec);
50285038

5039+
/*
5040+
* If the previous progress message is longer than the current
5041+
* one, add spaces to the current line to fully overwrite any
5042+
* remaining characters from the previous message.
5043+
*/
5044+
if (prev_chars>chars)
5045+
fprintf(stderr,"%*c",prev_chars-chars,' ');
5046+
fputc(eol,stderr);
5047+
prev_chars=chars;
5048+
50295049
/* skip to the next interval */
50305050
log_interval= (int)ceil(elapsed_sec /LOG_STEP_SECONDS);
50315051
}
50325052
}
5033-
5034-
/*
5035-
* If the previous progress message is longer than the current one,
5036-
* add spaces to the current line to fully overwrite any remaining
5037-
* characters from the previous message.
5038-
*/
5039-
if (prev_chars>chars)
5040-
fprintf(stderr,"%*c",prev_chars-chars,' ');
5041-
fputc(eol,stderr);
5042-
prev_chars=chars;
50435053
}
50445054

50455055
if (chars!=0&&eol!='\n')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp