Enhance pgbench -l option to add timestamp. Patch contributed by Greg
authorTatsuo Ishii
Fri, 6 Apr 2007 09:16:16 +0000 (09:16 +0000)
committerTatsuo Ishii
Fri, 6 Apr 2007 09:16:16 +0000 (09:16 +0000)
Smith. Along with Japanese doc updation by Tasuo Ishii.

> This patch changes the way pgbench outputs its latency log files so that
> every transaction gets a timestamp and notes which transaction type was
> executed.  It's a one-line change that just dumps some additional
> information that was already sitting in that area of code. I also made a
> couple of documentation corrections and clarifications on some of the more
> confusing features of pgbench.
>
> It's straightforward to parse log files in this format to analyze what
> happened during the test at a higher level than was possible with the
> original format.  You can find some rough sample code to convert this
> latency format into CVS files and then into graphs at
> http://www.westnet.com/~gsmith/content/postgresql/pgbench.htm which I'll
> be expanding on once I get all my little patches sent in here.

contrib/pgbench/README.pgbench
contrib/pgbench/README.pgbench_jis
contrib/pgbench/pgbench.c

index 7fc683cef035027f6d3b1fe5d4f47ea2e95c82f6..ef040c094d7663c2adfea9020897eb802319cab6 100644 (file)
@@ -1,4 +1,4 @@
-$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.16 2007/04/06 08:49:44 ishii Exp $
+$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.17 2007/04/06 09:16:15 ishii Exp $
 
 pgbench README
 
@@ -96,10 +96,14 @@ o options
        default is 1.  NOTE: scaling factor should be at least
        as large as the largest number of clients you intend
        to test; else you'll mostly be measuring update contention.
+       Regular (not initializing) runs using one of the
+       built-in tests will detect scale based on the number of
+       branches in the database.  For custom (-f) runs it can
+       be manually specified with this parameter.
 
    -D varname=value
-       Define a variable. It can be refereed to by a script
-       provided by using -f option. Multile -D options are allowed.
+       Define a variable. It can be refered to by a script
+       provided by using -f option. Multiple -D options are allowed.
 
    -U login
        Specify db user's login name if it is different from
@@ -141,9 +145,22 @@ o options
        with the name "pgbench_log.xxx", where xxx is the PID
        of the pgbench process. The format of the log is:
 
-           client_id transaction_no time
+           client_id transaction_no time file_no time-epoch time-us
 
-       where time is measured in microseconds.
+       where time is measured in microseconds, , the file_no is
+       which test file was used (useful when multiple were
+       specified with -f), and time-epoch/time-us are a
+       UNIX epoch format timestamp followed by an offset
+       in microseconds (suitable for creating a ISO 8601
+       timestamp with a fraction of a second) of when
+       the transaction completed.
+
+       Here are example outputs:
+
+       0 199 2241 0 1175850568 995598
+       0 200 2465 0 1175850568 998079
+       0 201 2513 0 1175850569 608
+       0 202 2038 0 1175850569 2663
 
    -d
        debug option.
@@ -165,6 +182,8 @@ o What is the "transaction" actually performed in pgbench?
 
   (7) end;
 
+If you specify -N, (4) and (5) aren't included in the transaction.
+
 o -f option
 
   This supports for reading transaction script from a specified
index 5afa9324367249fc1ec1ba1999048082e5571f02..e06587a879145eb7cddd24020734c99ef77d557a 100644 (file)
@@ -1,4 +1,4 @@
-$PostgreSQL: pgsql/contrib/pgbench/README.pgbench_jis,v 1.17 2007/04/06 08:49:44 ishii Exp $
+$PostgreSQL: pgsql/contrib/pgbench/README.pgbench_jis,v 1.18 2007/04/06 09:16:16 ishii Exp $
 
 pgbench README
 
@@ -76,6 +76,13 @@ pgbench \e$B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%\e(B
        \e$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?!<$O\e(B 1 \e$B$G$9!%\e(B
        -f \e$B%*%W%7%g%s$G;XDj$7$?%U%!%$%k$+$i%9%1!<%j%s%0%U%!%/\e(B
        \e$B%?!<$r;2>H$9$k$K$O\e(B scale \e$B$H$$$&JQ?tL>$r;HMQ$7$^$9!%\e(B
+       \e$BCm0U\e(B: \e$B%9%1!<%j%s%0%U%!%/%?!<$O>/$J$/$H$b\e(B -c \e$B$G;XDj$5$l$kF1;~@\\e(B
+       \e$BB3%f!<%6?t$HF1$8$+$=$l$h$j$bBg$-$/$7$F$/$@$5$$!%$G$J$$$H!$\e(B
+       pgbench\e$B$N7k2L$O\e(BUPDATE\e$B$N6%9g$KBg$-$/1F6A$5$l$F$7$^$$$^$9!%\e(B
+       \e$BAH9~$_$N%Y%s%A%^!<%/%Q%?!<%s$G$O!$\e(Bbraches\e$B$N?t\e(B(=braches\e$B%F!<%V%k\e(B
+       \e$B$N9T?t\e(B)\e$B$,<+F0E*$K%9%1!<%j%s%0%U%!%/%?!<$K@_Dj$5$l$^$9!%\e(B
+       \e$B%+%9%?%`%/%(%j\e(B(-f\e$B%*%W%7%g%s;HMQ\e(B)\e$B$G$O!$%9%1!<%j%s%0%U%!%/%?!<$O\e(B
+       \e$B<+F0@_Dj$5$l$^$;$s!%\e(B
 
 -D varname=value
 
@@ -130,10 +137,24 @@ pgbench \e$B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%\e(B
        \e$B%+%l%s%H%G%#%l%/%H%j0J2<$N\e(Bpgbench_log.xxx\e$B$H$$$&%U%!%$\e(B
        \e$B%k$G$9!%%U%!%$%k$N%U%)!<%^%C%H$O!$\e(B
        
-           \e$B%/%i%$%"%s%H\e(BID    \e$B%H%i%s%6%/%7%g%sHV9f\e(B  \e$B;~4V\e(B
+           \e$B%/%i%$%"%s%H\e(BID    \e$B%H%i%s%6%/%7%g%sHV9f\e(B  \e$B;~4V\e(B \e$B%U%!%$%kHV9f\e(B Unix\e$B%?%$%`\e(B(\e$BIC\e(B) \e$B%*%U%;%C%H\e(B
 
        \e$B$H$J$C$F$$$^$9!%;~4V$O%^%$%/%mICC10L$G$9!%\e(B
 
+       \e$B%U%!%$%kHV9f$O%F%9%H$K;H$o$l$?%U%!%$%k$NHV9f$G$9\e(B(-f\e$B%*%W%7%g%s\e(B
+       \e$B$rJ#?t;XDj$7$?$H$-$KM-MQ$G$9\e(B)\e$B!%\e(B
+
+       \e$B!V\e(BUnix\e$B%?%$%`\e(B(\e$BIC\e(B) \e$B%*%U%;%C%H!W$O!$%H%i%s%6%/%7%g%s$,40N;$7$?$H\e(B
+       \e$B$-$N\e(BUNIX\e$B%(%]%C%/%?%$%`$H%^%$%/%mICC10L$N%*%U%;%C%H$G$9\e(B(ISO
+       8601\e$B%?%$%`%9%?%s%W$HIC$NCf$NC\e(B)\e$B!%\e(B
+
+       \e$B%m%0$N=PNONc$r<($7$^$9!%\e(B
+
+       0 199 2241 0 1175850568 995598
+       0 200 2465 0 1175850568 998079
+       0 201 2513 0 1175850569 608
+       0 202 2038 0 1175850569 2663
+
 -d     \e$B%G%P%C%0%*%W%7%g%s!%MM!9$J>pJs$,I=<($5$l$^$9!%\e(B
 
 \e$B"#%G!<%?%Y!<%9$N=i4|2=\e(B
@@ -198,6 +219,8 @@ pgbench \e$B$G$O!$0J2<$N%7!<%1%s%9$rA4It40N;$7$F\e(B1\e$B%H%i%s%6%/%7%g%s$H?t$($F\e(
 
 (7) end;
 
+-N\e$B%*%W%7%g%s$r;HMQ$9$k$H!$\e(B(4)(5)\e$B$O\e(B
+
 \e$B"#F~NO%U%!%$%k$N%U%)!<%^%C%H\e(B
 
 -f \e$B%*%W%7%g%s$r;XDj$7$F%H%i%s%6%/%7%g%s$K4^$^$l$k\e(B SQL \e$B%3%^%s%I$NFbMF$r\e(B
index 369b7669f121e7bc66614a12609f9db28cdea4f6..2ffd24b25b907d2242e9331a18b8f070724fcd8d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.63 2007/04/06 08:49:44 ishii Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.64 2007/04/06 09:16:16 ishii Exp $
  *
  * pgbench: a simple benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -469,7 +469,8 @@ top:
            diff = (int) (now.tv_sec - st->txn_begin.tv_sec) * 1000000.0 +
                (int) (now.tv_usec - st->txn_begin.tv_usec);
 
-           fprintf(LOGFILE, "%d %d %.0f\n", st->id, st->cnt, diff);
+           fprintf(LOGFILE, "%d %d %.0f %d %ld %ld\n",
+               st->id, st->cnt, diff, st->use_file, now.tv_sec,now.tv_usec);
        }
 
        if (commands[st->state]->type == SQL_COMMAND)