From 6399d7bdeafff87574f514b39bc41a35e0922180 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Thu, 24 Dec 2009 17:48:23 +0100 Subject: [PATCH] sync --- Makefile.am | 3 +- Makefile.in | 3 +- doc/bench.c | 149 +++++++++++++++++++++++++++ src/ulib/net/server/client_image.cpp | 2 +- tests/examples/TSA/CA/tsaserial | 2 +- tests/examples/benchmarking.cfg | 5 + 6 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 doc/bench.c diff --git a/Makefile.am b/Makefile.am index 6ad82a2c5..37896d2fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,8 @@ AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = autoconf configure.help TODO LICENSE README.md README.LZO cdb README.cdb README.configure *.spec* \ - ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse doc/html doc/Doxyfile doc/userver_usp_benchmarking.txt openwrt + ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \ + doc/html doc/Doxyfile doc/userver_usp_benchmarking.txt doc/bench.c MAINTAINERCLEANFILES = configure aclocal.m4 libtool Makefile.in Makefile INSTALL diff --git a/Makefile.in b/Makefile.in index 8332b6e08..5ea80d7aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -356,7 +356,8 @@ thrprefix = @thrprefix@ AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = autoconf configure.help TODO LICENSE README.md README.LZO cdb README.cdb README.configure *.spec* \ - ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse doc/html doc/Doxyfile doc/userver_usp_benchmarking.txt openwrt + ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \ + doc/html doc/Doxyfile doc/userver_usp_benchmarking.txt doc/bench.c MAINTAINERCLEANFILES = configure aclocal.m4 libtool Makefile.in Makefile INSTALL SUBDIRS = include src examples contrib tests diff --git a/doc/bench.c b/doc/bench.c new file mode 100644 index 000000000..61629cc21 --- /dev/null +++ b/doc/bench.c @@ -0,0 +1,149 @@ +// ============================================================================ +// +// bench.c: invoke Apache Benchmark (ab) for a concurrency range and collect +// results in a file suitable for OpenOffice.org SpreadSheet charting +// +// 100.html is a 100-byte file initially designed to avoid testing the +// kernel (I wanted to compare the CPU efficiency of each Web server). +// +// The ITER define can be set to 1 to speed up a test but in that case +// values are not as reliable as when using more rounds (and using a +// low ITER[ations] value usually gives lower performances). +// +// G-WAN for Windows upgrades Registry system values to remove some +// artificial limits (original values are just renamed), you need to +// reboot after you run G-WAN for the first time to load those values. +// Rebooting for each test has an effect on Windows (you are faster), +// like testing after IIS 7.0 was tested (you are even faster), and +// the Windows Vista 64-bit TCP/IP stack is 10% faster (for all) if +// ASP.Net is *not* installed. +// +// Linux Ubuntu 8.1 did not show those boot-related side-effects but +// here also I have had to tune the system to run the test: +// +// sudo gedit /etc/security/limits.conf +// * soft nofile = 200000 +// * hard nofile = 200000 +// +// sudo gedit /etc/sysctl.conf +// fs.file-max = 200000 +// net.ipv4.ip_local_port_range = 1024 65535 +// net.ipv4.ip_forward = 0 +// net.ipv4.conf.default.rp_filter = 1 +// kernel.sysrq = 0 +// net.core.rmem_max = 262143 +// net.core.rmem_default = 262143 +// net.ipv4.tcp_rmem = 4096 131072 262143 +// net.ipv4.tcp_wmem = 4096 131072 262143 +// net.ipv4.tcp_sack = 0 +// net.ipv4.tcp_timestamps = 0 +// kernel.shmmax = 67108864 +// +// As I was not able to make the 'open files limit' persist for G-WAN +// after a reboot G-WAN attemps to setup this to an 'optimal' value +// depending on the amount of RAM available on your system: +// +// fd_max=(256*(tram/4)<200000)?256*(tram/4):1000000; +// +// Other values may need to be tuned to get optimal Linux performances +// I just did my best as a one-month Linux newbe. +// +// NB: this test was 15-20% faster (for all) when ab was running on a +// computer and the Web server on another machine via a gigabit +// LAN (but absolute performances were less interesting me than +// relative performances). +// +// This program is left in the public domain +// Author: Pierre GAUTHIER, http://trustleap.ch/ +// +// ============================================================================ +#include +#include +#include +#include +#include + +#ifdef _WIN32 +# include +# include +#else +#define Sleep(v) sleep(v/1000) +#define strstri strcasestr +#endif + +// ---------------------------------------------------------------------------- +#define LOOP 1000 // the range to cover (0-1000 concurrent clients) +#define ITER 20 // the number of iterations of concurrency (worse,aver,best) +// ---------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + int i, j, nbr, best, worse, aver; + char str[256], buff[10000]; + FILE *f, *fo=fopen("test.txt", "w+b"); + + for(i=10; i<=LOOP; i+=10) + { + sprintf(str, + "/usr/sbin/ab -n 1000000 -c %u -t 1" // NO Keep-Alives +// "/usr/sbin/ab -n 1000000 -c %u -k -t 1" // KEEP-ALIVES (ab don't distribute the requests across process) + " \"http://10.30.1.131/usp/hello_world.usp\"" // ULib / teepeedee2 +// " \"http://10.30.1.131/csp?hello\"" +// " \"http://192.168.200.88:8080/100.html\"" +// " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=1\"" +// " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=10\"" +// " \"http://192.168.200.88:8080/hello.php\"" +// " \"http://192.168.200.88:8080/loan.php?name=Eva&amount=10000&rate=3.5&term=1\"" +// " \"http://192.168.200.88:8080/loan.php?name=Eva&amount=10000&rate=3.5&term=10\"" + " > ab.txt", i); + + for(best=0, aver=0, worse=0xffff0, j=0; j='0'&&*p<='9') p++; *p=0; + nbr=atol(n); + } + else + { + puts("* Requ. per sec. not found!"); + puts(str); + goto fault; + } + } + if(bestnbr) worse=nbr; + aver+=nbr; + } + aver/=ITER; + + // display data for convenience and save data on disk + printf("##### %4u,%5u,%5u,%5u #####\n", i, worse, aver, best); + fprintf(fo, "%u,%u,%u,%u\n", i, worse, aver, best); + fflush(fo); // in case we interrupt the test + } + fclose(fo); + return 0; +} +// ============================================================================ +// End of Source Code +// ============================================================================ diff --git a/src/ulib/net/server/client_image.cpp b/src/ulib/net/server/client_image.cpp index b7c590fca..2a136ce2d 100644 --- a/src/ulib/net/server/client_image.cpp +++ b/src/ulib/net/server/client_image.cpp @@ -410,7 +410,7 @@ void UClientImage_Base::run() pClientImage->pevent = U_NEW(UEvent(pClientImage->UEventFd::fd, EV_READ | EV_PERSIST, *pClientImage)); - UDispatcher::add(*pevent); + UDispatcher::add(*(pClientImage->pevent)); # endif return; diff --git a/tests/examples/TSA/CA/tsaserial b/tests/examples/TSA/CA/tsaserial index ddda6ca83..eff6fca91 100644 --- a/tests/examples/TSA/CA/tsaserial +++ b/tests/examples/TSA/CA/tsaserial @@ -1 +1 @@ -19E1 +19E8 diff --git a/tests/examples/benchmarking.cfg b/tests/examples/benchmarking.cfg index ea95e6313..88222a2ac 100644 --- a/tests/examples/benchmarking.cfg +++ b/tests/examples/benchmarking.cfg @@ -27,6 +27,9 @@ userver { ## REQ_TIMEOUT timeout for request from client ## CGI_TIMEOUT timeout for cgi execution ## +## MAX_KEEP_ALIVE Specifies the maximum number of requests that can be served through a Keep-Alive (Persistent) session. +## (Value <= 1 will disable Keep-Alive) +## ## CERT_FILE certificate of server ## KEY_FILE private key of server ## PASSWORD password for private key of server @@ -69,6 +72,8 @@ userver { ## REQ_TIMEOUT 20 ## CGI_TIMEOUT 20 + MAX_KEEP_ALIVE 256 + ## CERT_FILE ../ulib/CA/server.crt ## KEY_FILE ../ulib/CA/server.key ## PASSWORD caciucco