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

Commit499d1cf

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 parentfd467ce commit499d1cf

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
@@ -5009,6 +5009,16 @@ initGenerateDataClientSide(PGconn *con)
50095009
j, (int64)naccounts*scale,
50105010
(int) (((int64)j*100) / (naccounts* (int64)scale)),
50115011
elapsed_sec,remaining_sec);
5012+
5013+
/*
5014+
* If the previous progress message is longer than the current
5015+
* one, add spaces to the current line to fully overwrite any
5016+
* remaining characters from the previous message.
5017+
*/
5018+
if (prev_chars>chars)
5019+
fprintf(stderr,"%*c",prev_chars-chars,' ');
5020+
fputc(eol,stderr);
5021+
prev_chars=chars;
50125022
}
50135023
/* let's not call the timing for each row, but only each 100 rows */
50145024
elseif (use_quiet&& (j %100==0))
@@ -5023,20 +5033,20 @@ initGenerateDataClientSide(PGconn *con)
50235033
j, (int64)naccounts*scale,
50245034
(int) (((int64)j*100) / (naccounts* (int64)scale)),elapsed_sec,remaining_sec);
50255035

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

50425052
if (eol!='\n')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp