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

Commit5addea7

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 parent9f6ad2f commit5addea7

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
@@ -4312,6 +4312,16 @@ initGenerateDataClientSide(PGconn *con)
43124312
j, (int64)naccounts*scale,
43134313
(int) (((int64)j*100) / (naccounts* (int64)scale)),
43144314
elapsed_sec,remaining_sec);
4315+
4316+
/*
4317+
* If the previous progress message is longer than the current
4318+
* one, add spaces to the current line to fully overwrite any
4319+
* remaining characters from the previous message.
4320+
*/
4321+
if (prev_chars>chars)
4322+
fprintf(stderr,"%*c",prev_chars-chars,' ');
4323+
fputc(eol,stderr);
4324+
prev_chars=chars;
43154325
}
43164326
/* let's not call the timing for each row, but only each 100 rows */
43174327
elseif (use_quiet&& (j %100==0))
@@ -4326,20 +4336,20 @@ initGenerateDataClientSide(PGconn *con)
43264336
j, (int64)naccounts*scale,
43274337
(int) (((int64)j*100) / (naccounts* (int64)scale)),elapsed_sec,remaining_sec);
43284338

4339+
/*
4340+
* If the previous progress message is longer than the current
4341+
* one, add spaces to the current line to fully overwrite any
4342+
* remaining characters from the previous message.
4343+
*/
4344+
if (prev_chars>chars)
4345+
fprintf(stderr,"%*c",prev_chars-chars,' ');
4346+
fputc(eol,stderr);
4347+
prev_chars=chars;
4348+
43294349
/* skip to the next interval */
43304350
log_interval= (int)ceil(elapsed_sec /LOG_STEP_SECONDS);
43314351
}
43324352
}
4333-
4334-
/*
4335-
* If the previous progress message is longer than the current one,
4336-
* add spaces to the current line to fully overwrite any remaining
4337-
* characters from the previous message.
4338-
*/
4339-
if (prev_chars>chars)
4340-
fprintf(stderr,"%*c",prev_chars-chars,' ');
4341-
fputc(eol,stderr);
4342-
prev_chars=chars;
43434353
}
43444354

43454355
if (eol!='\n')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp