Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 27902bc

Browse files
committed
Fix progress logging when scale factor is large.
Integer overflow showed minus percent and minus remaining time something like this. 239300000 of 3800000000 tuples (-48%) done (elapsed 226.86 s, remaining -696.10 s).
1 parent 6dc71a7 commit 27902bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/pgbench/pgbench.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,11 +1610,11 @@ init(bool is_no_vacuum)
16101610
INSTR_TIME_SUBTRACT(diff, start);
16111611

16121612
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
1613-
remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
1613+
remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
16141614

16151615
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
16161616
j, (int64) naccounts * scale,
1617-
(int) (((int64) j * 100) / (naccounts * scale)),
1617+
(int) (((int64) j * 100) / (naccounts * (int64) scale)),
16181618
elapsed_sec, remaining_sec);
16191619
}
16201620
/* let's not call the timing for each row, but only each 100 rows */
@@ -1624,14 +1624,14 @@ init(bool is_no_vacuum)
16241624
INSTR_TIME_SUBTRACT(diff, start);
16251625

16261626
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
1627-
remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
1627+
remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
16281628

16291629
/* have we reached the next interval (or end)? */
16301630
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS))
16311631
{
16321632
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
16331633
j, (int64) naccounts * scale,
1634-
(int) (((int64) j * 100) / (naccounts * scale)), elapsed_sec, remaining_sec);
1634+
(int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec);
16351635

16361636
/* skip to the next interval */
16371637
log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS);

0 commit comments

Comments
 (0)