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

Commit21b815f

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 parentbbf1ef7 commit21b815f

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
elseif (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)

[8]ページ先頭

©2009-2025 Movatter.jp