diff -Naur httperf-0.8/gen/Makefile.in httperf-0.8-new/gen/Makefile.in --- httperf-0.8/gen/Makefile.in 2000-10-11 21:07:51.000000000 -0400 +++ httperf-0.8-new/gen/Makefile.in 2007-02-22 18:18:25.000000000 -0500 @@ -31,7 +31,7 @@ LIBGEN_OBJS = call_seq.o conn_rate.o misc.o rate.o session.o \ uri_fixed.o uri_wlog.o uri_wset.o \ wsess.o wsesslog.o wsesspage.o \ - sess_cookie.o + sess_cookie.o uri_wlog2.o all: libgen.a diff -Naur httperf-0.8/gen/rate.c httperf-0.8-new/gen/rate.c --- httperf-0.8/gen/rate.c 2000-10-11 19:37:14.000000000 -0400 +++ httperf-0.8-new/gen/rate.c 2007-02-22 17:26:17.000000000 -0500 @@ -98,6 +98,8 @@ rg->done = ((*rg->tick) (rg->arg) < 0); } +extern Time next_arrival_time_file(Rate_Generator *rg); + void rate_generator_start (Rate_Generator *rg, Event_Type completion_event) { @@ -123,6 +125,7 @@ case DETERMINISTIC: func = next_arrival_time_det; break; case UNIFORM: func = next_arrival_time_uniform; break; case EXPONENTIAL: func = next_arrival_time_exp; break; + case FROM_FILE: func = next_arrival_time_file; break; default: fprintf (stderr, "%s: unrecognized interarrival distribution %d\n", prog_name, rg->rate->dist); diff -Naur httperf-0.8/gen/uri_wlog2.c httperf-0.8-new/gen/uri_wlog2.c --- httperf-0.8/gen/uri_wlog2.c 1969-12-31 19:00:00.000000000 -0500 +++ httperf-0.8-new/gen/uri_wlog2.c 2007-02-22 18:02:43.000000000 -0500 @@ -0,0 +1,194 @@ +/* + httperf -- a tool for measuring web server performance + Copyright (C) 2000 Hewlett-Packard Company + Contributed by Stephane Eranian + + This file is part of httperf, a web server performance measurment + tool. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA +*/ + +/* This load generator can be used to recreate a workload based on a + server log file. + + This module can be used in conjunction with two comands to help in + extracting information from the httpd CLF file (contact + eranian@hpl.hp.com). + + Please note that you don't necessary need any of those tools. You + can recreate the list of URIs by hand or with any other programs as + long as you respect the format expected by this module (and also + provided than you have the corresponding document tree on the + server side). + + The format of the file used by this module is very simple (maybe + too simple): + + URI1\0URI2\0......URIn\0 + + It is a simple concatenated list of URI separated by the \0 (end of + string) marker. + + This way, we don't need any parsing of the string when generating + the URI. + + You can choose to loop on te list of URIs by using the following + command line option to httperf: + + % httperf .... --wlog y,my_uri_file + + Otherwise httperf will stop once it reaches the end of the list. + + Any comment on this module contact eranian@hpl.hp.com or + davidm@hpl.hp.com. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +static char *fbase, *fend, *fcurrent; + +enum {ARRIVAL_TIME, URL_FETCH} next_op = ARRIVAL_TIME; +static Time next_time; +char *next_url; + +Time next_arrival_time_file(void *rg) +{ + int usec, len, did_wrap = 0; + + printf("next_time, op=%d\n", next_op); + if (next_op == URL_FETCH) + return next_time; + + next_op = URL_FETCH; + if (fcurrent >= fend) { + if (did_wrap) + panic ("%s: %s does not contain any valid URIs\n", + prog_name, param.wlog.file); + did_wrap = 1; + fcurrent = fbase; + if (!param.wlog.do_loop) + core_exit (); + } + + usec = atoi(fcurrent); + double t = usec / 1000000.0; + printf("arrival: %f (%s)\n", t, fcurrent); + len = strlen(fcurrent); + fcurrent += len+1; + return t; +} + +static void +set_uri (Event_Type et, Call * c) +{ + int len, did_wrap = 0; + const char *uri; + + assert (et == EV_CALL_NEW && object_is_call (c)); + + printf("set_uri, op=%d\n", next_op); + + if (next_op == ARRIVAL_TIME) { + call_set_uri (c, next_url, strlen(next_url)); + return; + } + do + { + if (fcurrent >= fend) + { + if (did_wrap) + panic ("%s: %s does not contain any valid URIs\n", + prog_name, param.wlog.file); + did_wrap = 1; + + /* We reached the end of the uri list so wrap around to the + beginning. If not looping, also ask for the test to stop + as soon as possible (the current request will still go + out, but httperf won't wait for its reply to show up). */ + fcurrent = fbase; + if (!param.wlog.do_loop) + core_exit (); + } + uri = next_url = fcurrent; + len = strlen (fcurrent); + call_set_uri (c, uri, len); + fcurrent += len + 1; + } + while (len == 0); + next_op = ARRIVAL_TIME; + + if (verbose) + printf ("%s: accessing URI `%s'\n", prog_name, uri); +} + +static void +init_wlog (void) +{ + struct stat st; + Any_Type arg; + int fd; + + fd = open (param.wlog.file, O_RDONLY, 0); + if (fd == -1) + panic ("%s: can't open %s\n", prog_name, param.wlog.file); + + fstat (fd, &st); + if (st.st_size == 0) + panic ("%s: file %s is empty\n", prog_name, param.wlog.file); + + /* mmap anywhere in address space: */ + fbase = (char *) mmap (0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (fbase == (char *) 0 - 1) + panic ("%s: can't mmap the file: %s\n", prog_name, strerror (errno)); + + close (fd); + + /* set the upper boundary: */ + fend = fbase + st.st_size; + /* set current entry: */ + fcurrent = fbase; + + arg.l = 0; + event_register_handler (EV_CALL_NEW, (Event_Handler) set_uri, arg); +} + +static void +stop_wlog (void) +{ + munmap (fbase, fend - fbase); +} + +Load_Generator uri_wlog2 = + { + "Generates URIs and interarrival times based on a predetermined list", + init_wlog, + no_op, + stop_wlog + }; diff -Naur httperf-0.8/httperf.c httperf-0.8-new/httperf.c --- httperf-0.8/httperf.c 2000-10-31 15:20:00.000000000 -0500 +++ httperf-0.8-new/httperf.c 2007-02-22 17:47:00.000000000 -0500 @@ -91,6 +91,8 @@ int debug_level; #endif +int wlog2; + static Time perf_sample_start; static struct option longopts[] = @@ -132,6 +134,7 @@ {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"wlog", required_argument, (int *) ¶m.wlog, 0}, + {"wlog2", required_argument, (int *) &wlog2, 0}, {"wsess", required_argument, (int *) ¶m.wsess, 0}, {"wsesslog", required_argument, (int *) ¶m.wsesslog, 0}, {"wsesspage", required_argument, (int *) ¶m.wsesspage, 0}, @@ -196,7 +199,7 @@ main (int argc, char **argv) { extern Load_Generator uri_fixed, uri_wlog, uri_wset, conn_rate, call_seq; - extern Load_Generator wsess, wsesslog, wsesspage, sess_cookie, misc; + extern Load_Generator wsess, wsesslog, wsesspage, sess_cookie, misc, uri_wlog2; extern Stat_Collector stats_basic, session_stat; extern Stat_Collector stats_print_reply; extern char *optarg; @@ -552,6 +555,15 @@ param.wlog.do_loop = (*optarg == 'y') || (*optarg == 'Y'); param.wlog.file = optarg + 2; } + else if (flag == &wlog2) + { + gen[1] = &uri_wlog2; + + param.wlog.do_loop = (*optarg == 'y') || (*optarg == 'Y'); + param.wlog.file = optarg + 2; + param.rate.dist = FROM_FILE; + param.rate.rate_param = 1.0; + } else if (flag == ¶m.wsess) { num_gen = 2; /* XXX fix me---somehow */ diff -Naur httperf-0.8/httperf.h httperf-0.8-new/httperf.h --- httperf-0.8/httperf.h 2000-10-31 15:32:09.000000000 -0500 +++ httperf-0.8-new/httperf.h 2007-02-22 17:30:30.000000000 -0500 @@ -57,7 +57,8 @@ { DETERMINISTIC, /* also called fixed-rate */ UNIFORM, /* over interval [min_iat,max_iat) */ - EXPONENTIAL /* with mean mean_iat */ + EXPONENTIAL, /* with mean mean_iat */ + FROM_FILE } Dist_Type; diff -Naur httperf-0.8/README.wlog2 httperf-0.8-new/README.wlog2 --- httperf-0.8/README.wlog2 1969-12-31 19:00:00.000000000 -0500 +++ httperf-0.8-new/README.wlog2 2007-02-22 18:16:28.000000000 -0500 @@ -0,0 +1,13 @@ +--wlog2 [y|n],FILE + +Takes a file similar to 'wlog', except that it contains interarrival +times as well as URIs. Times are given in text formt in units of +microseconds, interleaved with URLs, and starting with a time. E.g.: + + 14500\0/x/y/z\01000000\0/x/y + +would access /x/y/z, then wait 14500 uS, then /x/y, then wait 1 second. + +Peter Desnoyers +UMass Computer Science, 2007 +pjd@cs.umass.edu