aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-21 07:47:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-21 07:47:35 +0000
commit41be6325c89377b9a2d9aff1493c3d4fb62e0fb4 (patch)
tree5060ec8b4fe35c192e90a748aadee18fea7610c1
parent7ef544c9bed6159c46be44a3d130e0de094a345f (diff)
downloadlibmicrohttpd-41be6325c89377b9a2d9aff1493c3d4fb62e0fb4.tar.gz
libmicrohttpd-41be6325c89377b9a2d9aff1493c3d4fb62e0fb4.zip
From:
Will Bryant <will.bryant@gmail.com> To: libmicrohttpd development and user mailinglist <libmicrohttpd@gnu.org> Date: Today 03:01:54 AM Attachments: 0001-use-separate-ports-for-subsequent-tests-in-the-perf-.patch So patch attached to use sequential port number assignments in those two perf test programs - with that and the earlier pipe shutdown patch, OS X passes all tests now. OpenIndiana also passes all the perf tests, leaving just the SIGPIPE matter. Incidentally, performance is terrible there. I would be interested to know why - my OpenIndiana box has a modern Intel Q9505 and gets in the region of 35 requests/s in each perf test, whereas my aging Intel Core 2 Duo macbook gets 600-900 despite having half the cores. Of course we only expect the non-concurrent test to use about 1 of the cores, but both that and the concurrent test actually use only about 1% of a single CPU. This is puzzling as OpenIndiana has the very performant and scalable sunos/solaris-derived kernel and libc, so something odd is definitely going on. Regarding the SIGPIPE, do you think a signal handler should be installed in all test programs, to implement the recommended behavior for applications, or only in those that need it? I am sitting on the fence. I think the argument for the latter would be that one would not normally expect SIGPIPE to occur during tests that do not test out error/abort behavior, but I don't think it would normally be harmful. (I haven't implemented the configure script integration to set the HAVE_LISTEN_SHUTDOWN conditional define for Linux etc. - can you help there? I have, for what it's worth, checked that Linux does also work using the pipe technique instead, so that seems well-portable.) Cheers, Will
-rw-r--r--src/testcurl/perf_get.c51
-rw-r--r--src/testcurl/perf_get_concurrent.c46
2 files changed, 57 insertions, 40 deletions
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index a316ed1e..31dd1177 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -171,7 +171,7 @@ ahc_echo (void *cls,
171 171
172 172
173static int 173static int
174testInternalGet (int poll_flag) 174testInternalGet (int port, int poll_flag)
175{ 175{
176 struct MHD_Daemon *d; 176 struct MHD_Daemon *d;
177 CURL *c; 177 CURL *c;
@@ -179,11 +179,14 @@ testInternalGet (int poll_flag)
179 struct CBC cbc; 179 struct CBC cbc;
180 CURLcode errornum; 180 CURLcode errornum;
181 unsigned int i; 181 unsigned int i;
182 char url[64];
183
184 sprintf(url, "http://localhost:%d/hello_world", port);
182 185
183 cbc.buf = buf; 186 cbc.buf = buf;
184 cbc.size = 2048; 187 cbc.size = 2048;
185 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 188 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
186 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 189 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
187 if (d == NULL) 190 if (d == NULL)
188 return 1; 191 return 1;
189 start_timer (); 192 start_timer ();
@@ -191,7 +194,7 @@ testInternalGet (int poll_flag)
191 { 194 {
192 cbc.pos = 0; 195 cbc.pos = 0;
193 c = curl_easy_init (); 196 c = curl_easy_init ();
194 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11080/hello_world"); 197 curl_easy_setopt (c, CURLOPT_URL, url);
195 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 198 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
196 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 199 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
197 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 200 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -227,7 +230,7 @@ testInternalGet (int poll_flag)
227 230
228 231
229static int 232static int
230testMultithreadedGet (int poll_flag) 233testMultithreadedGet (int port, int poll_flag)
231{ 234{
232 struct MHD_Daemon *d; 235 struct MHD_Daemon *d;
233 CURL *c; 236 CURL *c;
@@ -235,11 +238,14 @@ testMultithreadedGet (int poll_flag)
235 struct CBC cbc; 238 struct CBC cbc;
236 CURLcode errornum; 239 CURLcode errornum;
237 unsigned int i; 240 unsigned int i;
241 char url[64];
242
243 sprintf(url, "http://localhost:%d/hello_world", port);
238 244
239 cbc.buf = buf; 245 cbc.buf = buf;
240 cbc.size = 2048; 246 cbc.size = 2048;
241 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 247 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag,
242 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 248 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
243 if (d == NULL) 249 if (d == NULL)
244 return 16; 250 return 16;
245 start_timer (); 251 start_timer ();
@@ -247,7 +253,7 @@ testMultithreadedGet (int poll_flag)
247 { 253 {
248 cbc.pos = 0; 254 cbc.pos = 0;
249 c = curl_easy_init (); 255 c = curl_easy_init ();
250 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 256 curl_easy_setopt (c, CURLOPT_URL, url);
251 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 257 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
252 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 258 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
253 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 259 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -282,7 +288,7 @@ testMultithreadedGet (int poll_flag)
282} 288}
283 289
284static int 290static int
285testMultithreadedPoolGet (int poll_flag) 291testMultithreadedPoolGet (int port, int poll_flag)
286{ 292{
287 struct MHD_Daemon *d; 293 struct MHD_Daemon *d;
288 CURL *c; 294 CURL *c;
@@ -290,11 +296,14 @@ testMultithreadedPoolGet (int poll_flag)
290 struct CBC cbc; 296 struct CBC cbc;
291 CURLcode errornum; 297 CURLcode errornum;
292 unsigned int i; 298 unsigned int i;
299 char url[64];
300
301 sprintf(url, "http://localhost:%d/hello_world", port);
293 302
294 cbc.buf = buf; 303 cbc.buf = buf;
295 cbc.size = 2048; 304 cbc.size = 2048;
296 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 305 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
297 1081, NULL, NULL, &ahc_echo, "GET", 306 port, NULL, NULL, &ahc_echo, "GET",
298 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); 307 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END);
299 if (d == NULL) 308 if (d == NULL)
300 return 16; 309 return 16;
@@ -303,7 +312,7 @@ testMultithreadedPoolGet (int poll_flag)
303 { 312 {
304 cbc.pos = 0; 313 cbc.pos = 0;
305 c = curl_easy_init (); 314 c = curl_easy_init ();
306 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 315 curl_easy_setopt (c, CURLOPT_URL, url);
307 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 316 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
308 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 317 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
309 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 318 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -338,7 +347,7 @@ testMultithreadedPoolGet (int poll_flag)
338} 347}
339 348
340static int 349static int
341testExternalGet () 350testExternalGet (int port)
342{ 351{
343 struct MHD_Daemon *d; 352 struct MHD_Daemon *d;
344 CURL *c; 353 CURL *c;
@@ -355,12 +364,15 @@ testExternalGet ()
355 time_t start; 364 time_t start;
356 struct timeval tv; 365 struct timeval tv;
357 unsigned int i; 366 unsigned int i;
367 char url[64];
368
369 sprintf(url, "http://localhost:%d/hello_world", port);
358 370
359 multi = NULL; 371 multi = NULL;
360 cbc.buf = buf; 372 cbc.buf = buf;
361 cbc.size = 2048; 373 cbc.size = 2048;
362 d = MHD_start_daemon (MHD_USE_DEBUG, 374 d = MHD_start_daemon (MHD_USE_DEBUG,
363 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 375 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
364 if (d == NULL) 376 if (d == NULL)
365 return 256; 377 return 256;
366 start_timer (); 378 start_timer ();
@@ -374,7 +386,7 @@ testExternalGet ()
374 { 386 {
375 cbc.pos = 0; 387 cbc.pos = 0;
376 c = curl_easy_init (); 388 c = curl_easy_init ();
377 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world"); 389 curl_easy_setopt (c, CURLOPT_URL, url);
378 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 390 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
379 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 391 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
380 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 392 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -469,6 +481,7 @@ int
469main (int argc, char *const *argv) 481main (int argc, char *const *argv)
470{ 482{
471 unsigned int errorCount = 0; 483 unsigned int errorCount = 0;
484 int port = 1081;
472 485
473 oneone = NULL != strstr (argv[0], "11"); 486 oneone = NULL != strstr (argv[0], "11");
474 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 487 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
@@ -476,13 +489,13 @@ main (int argc, char *const *argv)
476 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 489 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
477 "/hello_world", 490 "/hello_world",
478 MHD_RESPMEM_MUST_COPY); 491 MHD_RESPMEM_MUST_COPY);
479 errorCount += testInternalGet (0); 492 errorCount += testInternalGet (port++, 0);
480 errorCount += testMultithreadedGet (0); 493 errorCount += testMultithreadedGet (port++, 0);
481 errorCount += testMultithreadedPoolGet (0); 494 errorCount += testMultithreadedPoolGet (port++, 0);
482 errorCount += testExternalGet (); 495 errorCount += testExternalGet (port++);
483 errorCount += testInternalGet (MHD_USE_POLL); 496 errorCount += testInternalGet (port++, MHD_USE_POLL);
484 errorCount += testMultithreadedGet (MHD_USE_POLL); 497 errorCount += testMultithreadedGet (port++, MHD_USE_POLL);
485 errorCount += testMultithreadedPoolGet (MHD_USE_POLL); 498 errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL);
486 MHD_destroy_response (response); 499 MHD_destroy_response (response);
487 if (errorCount != 0) 500 if (errorCount != 0)
488 fprintf (stderr, "Error (code: %u)\n", errorCount); 501 fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c
index deb949b2..da206490 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -153,7 +153,7 @@ ahc_echo (void *cls,
153 153
154 154
155static pid_t 155static pid_t
156do_gets () 156do_gets (int port)
157{ 157{
158 pid_t ret; 158 pid_t ret;
159 CURL *c; 159 CURL *c;
@@ -161,6 +161,9 @@ do_gets ()
161 unsigned int i; 161 unsigned int i;
162 unsigned int j; 162 unsigned int j;
163 pid_t par[PAR]; 163 pid_t par[PAR];
164 char url[64];
165
166 sprintf(url, "http://localhost:%d/hello_world", port);
164 167
165 ret = fork (); 168 ret = fork ();
166 if (ret == -1) abort (); 169 if (ret == -1) abort ();
@@ -174,7 +177,7 @@ do_gets ()
174 for (i=0;i<ROUNDS;i++) 177 for (i=0;i<ROUNDS;i++)
175 { 178 {
176 c = curl_easy_init (); 179 c = curl_easy_init ();
177 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 180 curl_easy_setopt (c, CURLOPT_URL, url);
178 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 181 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
179 curl_easy_setopt (c, CURLOPT_WRITEDATA, NULL); 182 curl_easy_setopt (c, CURLOPT_WRITEDATA, NULL);
180 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 183 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -220,16 +223,16 @@ join_gets (pid_t pid)
220 223
221 224
222static int 225static int
223testInternalGet (int poll_flag) 226testInternalGet (int port, int poll_flag)
224{ 227{
225 struct MHD_Daemon *d; 228 struct MHD_Daemon *d;
226 229
227 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 230 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
228 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 231 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
229 if (d == NULL) 232 if (d == NULL)
230 return 1; 233 return 1;
231 start_timer (); 234 start_timer ();
232 join_gets (do_gets ()); 235 join_gets (do_gets (port));
233 stop (poll_flag ? "internal poll" : "internal select"); 236 stop (poll_flag ? "internal poll" : "internal select");
234 MHD_stop_daemon (d); 237 MHD_stop_daemon (d);
235 return 0; 238 return 0;
@@ -237,40 +240,40 @@ testInternalGet (int poll_flag)
237 240
238 241
239static int 242static int
240testMultithreadedGet (int poll_flag) 243testMultithreadedGet (int port, int poll_flag)
241{ 244{
242 struct MHD_Daemon *d; 245 struct MHD_Daemon *d;
243 246
244 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 247 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag,
245 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 248 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
246 if (d == NULL) 249 if (d == NULL)
247 return 16; 250 return 16;
248 start_timer (); 251 start_timer ();
249 join_gets (do_gets ()); 252 join_gets (do_gets (port));
250 stop (poll_flag ? "thread with poll" : "thread with select"); 253 stop (poll_flag ? "thread with poll" : "thread with select");
251 MHD_stop_daemon (d); 254 MHD_stop_daemon (d);
252 return 0; 255 return 0;
253} 256}
254 257
255static int 258static int
256testMultithreadedPoolGet (int poll_flag) 259testMultithreadedPoolGet (int port, int poll_flag)
257{ 260{
258 struct MHD_Daemon *d; 261 struct MHD_Daemon *d;
259 262
260 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 263 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
261 1081, NULL, NULL, &ahc_echo, "GET", 264 port, NULL, NULL, &ahc_echo, "GET",
262 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); 265 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END);
263 if (d == NULL) 266 if (d == NULL)
264 return 16; 267 return 16;
265 start_timer (); 268 start_timer ();
266 join_gets (do_gets ()); 269 join_gets (do_gets (port));
267 stop (poll_flag ? "thread pool with poll" : "thread pool with select"); 270 stop (poll_flag ? "thread pool with poll" : "thread pool with select");
268 MHD_stop_daemon (d); 271 MHD_stop_daemon (d);
269 return 0; 272 return 0;
270} 273}
271 274
272static int 275static int
273testExternalGet () 276testExternalGet (int port)
274{ 277{
275 struct MHD_Daemon *d; 278 struct MHD_Daemon *d;
276 pid_t pid; 279 pid_t pid;
@@ -283,11 +286,11 @@ testExternalGet ()
283 int tret; 286 int tret;
284 287
285 d = MHD_start_daemon (MHD_USE_DEBUG, 288 d = MHD_start_daemon (MHD_USE_DEBUG,
286 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 289 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
287 if (d == NULL) 290 if (d == NULL)
288 return 256; 291 return 256;
289 start_timer (); 292 start_timer ();
290 pid = do_gets (); 293 pid = do_gets (port);
291 while (0 == waitpid (pid, NULL, WNOHANG)) 294 while (0 == waitpid (pid, NULL, WNOHANG))
292 { 295 {
293 max = 0; 296 max = 0;
@@ -316,6 +319,7 @@ int
316main (int argc, char *const *argv) 319main (int argc, char *const *argv)
317{ 320{
318 unsigned int errorCount = 0; 321 unsigned int errorCount = 0;
322 int port = 1081;
319 323
320 oneone = NULL != strstr (argv[0], "11"); 324 oneone = NULL != strstr (argv[0], "11");
321 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 325 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
@@ -323,13 +327,13 @@ main (int argc, char *const *argv)
323 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 327 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
324 "/hello_world", 328 "/hello_world",
325 MHD_RESPMEM_MUST_COPY); 329 MHD_RESPMEM_MUST_COPY);
326 errorCount += testInternalGet (0); 330 errorCount += testInternalGet (port++, 0);
327 errorCount += testMultithreadedGet (0); 331 errorCount += testMultithreadedGet (port++, 0);
328 errorCount += testMultithreadedPoolGet (0); 332 errorCount += testMultithreadedPoolGet (port++, 0);
329 errorCount += testExternalGet (); 333 errorCount += testExternalGet (port++);
330 errorCount += testInternalGet (MHD_USE_POLL); 334 errorCount += testInternalGet (port++, MHD_USE_POLL);
331 errorCount += testMultithreadedGet (MHD_USE_POLL); 335 errorCount += testMultithreadedGet (port++, MHD_USE_POLL);
332 errorCount += testMultithreadedPoolGet (MHD_USE_POLL); 336 errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL);
333 MHD_destroy_response (response); 337 MHD_destroy_response (response);
334 if (errorCount != 0) 338 if (errorCount != 0)
335 fprintf (stderr, "Error (code: %u)\n", errorCount); 339 fprintf (stderr, "Error (code: %u)\n", errorCount);