diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-07-11 09:53:27 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-07-11 09:53:27 +0000 |
commit | ad091afd936f778e6141653d2e03fcfc5ae8efc2 (patch) | |
tree | eb591f5ff280b3fb3275738297f642b0182c06ea | |
parent | b044af1f353387b59a03c8cac8d46260264f93fa (diff) |
Added PJSIP_MAX_NET_EVENTS configuration to pjsip
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@602 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip-apps/src/samples/pjsip-perf.c | 85 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_config.h | 59 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_endpoint.c | 2 |
3 files changed, 121 insertions, 25 deletions
diff --git a/pjsip-apps/src/samples/pjsip-perf.c b/pjsip-apps/src/samples/pjsip-perf.c index 292e1653..ae4f2dd0 100644 --- a/pjsip-apps/src/samples/pjsip-perf.c +++ b/pjsip-apps/src/samples/pjsip-perf.c @@ -985,7 +985,8 @@ static void usage(void) " URL The SIP URL to be contacted.\n" "\n" "Client options:\n" - " --method=METHOD, -m Set the test method [default: OPTIONS]\n" + " --method=METHOD, -m Set test method (set to INVITE for call benchmark)\n" + " [default: OPTIONS]\n" " --count=N, -n Set total number of requests to initiate\n" " [default=%d]\n" " --stateless, -s Set to operate in stateless mode\n" @@ -999,12 +1000,14 @@ static void usage(void) "\n" "Client and Server options:\n" " --local-port=PORT, -p Set local port [default: 5060]\n" - " --use-tcp, -T Use TCP instead of UDP [default: no]\n" + " --use-tcp, -T Use TCP instead of UDP. Note that when started as\n" + " client, you must add ;transport=tcp parameter to URL\n" + " [default: no]\n" " --thread-count=N Set number of worker threads [default=1]\n" "\n" "Misc options:\n" " --help, -h Display this screen\n" - " --verbose, -v Display verbose logging (can be put more than once)\n" + " --verbose, -v Verbose logging (put more than once for even more)\n" "\n" "When started as server, pjsip-perf can be contacted on the following URIs:\n" " - sip:0@server-addr To handle requests statelessly.\n" @@ -1255,21 +1258,22 @@ static pj_status_t submit_job(void) static int client_thread(void *arg) { unsigned last_timeout_check = 0; - pj_time_val end_time, now; - - PJ_UNUSED_ARG(arg); + pj_time_val end_time, last_report, now; + unsigned thread_index = (unsigned)arg; pj_thread_sleep(100); pj_gettimeofday(&end_time); end_time.sec += app.client.timeout; + pj_gettimeofday(&last_report); + if (app.client.first_request.sec == 0) { pj_gettimeofday(&app.client.first_request); } /* Submit all jobs */ - while (app.client.job_submitted < app.client.job_count && !app.thread_quit) { + while (app.client.job_submitted < app.client.job_count && !app.thread_quit){ pj_time_val timeout = { 0, 1 }; unsigned i; int outstanding; @@ -1305,12 +1309,21 @@ static int client_thread(void *arg) /* Handle event */ pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); - /* Check for time out */ - if (app.client.job_submitted - last_timeout_check >= 2000) { + /* Check for time out, also print report */ + if (app.client.job_submitted - last_timeout_check >= 500) { pj_gettimeofday(&now); - if (PJ_TIME_VAL_GTE(now, end_time)) + if (PJ_TIME_VAL_GTE(now, end_time)) { break; + } last_timeout_check = app.client.job_submitted; + + + if (thread_index == 0 && now.sec-last_report.sec >= 2) { + printf("\r%d jobs started, %d completed... ", + app.client.job_submitted, app.client.job_finished); + fflush(stdout); + last_report = now; + } } } @@ -1319,9 +1332,17 @@ static int client_thread(void *arg) } + if (thread_index == 0) { + printf("\r%d jobs started, %d completed%s\n", + app.client.job_submitted, app.client.job_finished, + (app.client.job_submitted!=app.client.job_finished ? + ", waiting..." : ".") ); + fflush(stdout); + } + /* Wait until all jobs completes, or timed out */ pj_gettimeofday(&now); - while (now.sec < end_time.sec && + while (PJ_TIME_VAL_LT(now, end_time) && app.client.job_finished < app.client.job_count && !app.thread_quit) { @@ -1329,7 +1350,32 @@ static int client_thread(void *arg) unsigned i; for (i=0; i<1000; ++i) { - pjsip_endpt_handle_events2(app.sip_endpt, &timeout, NULL); + unsigned count; + count = 0; + pjsip_endpt_handle_events2(app.sip_endpt, &timeout, &count); + if (count == 0) + break; + } + + pj_gettimeofday(&now); + } + + /* Wait couple of seconds if there are still unfinished jobs */ + pj_gettimeofday(&now); + end_time = now; + end_time.sec += 2; + while (PJ_TIME_VAL_LT(now, end_time) && + app.client.job_finished < app.client.job_submitted) + { + pj_time_val timeout = { 0, 1 }; + unsigned i; + + for (i=0; i<1000; ++i) { + unsigned count; + count = 0; + pjsip_endpt_handle_events2(app.sip_endpt, &timeout, &count); + if (count == 0) + break; } pj_gettimeofday(&now); @@ -1432,6 +1478,9 @@ int main(int argc, char *argv[]) { static char report[1024]; + puts("PJSIP Performance Measurement Tool\n" + "(c)2006 pjsip.org\n"); + if (create_app() != 0) return 1; @@ -1486,13 +1535,13 @@ int main(int argc, char *argv[]) } - PJ_LOG(3,(THIS_FILE, "Sending %d %s to '%.*s' with %d maximum outstanding jobs, please wait..", + printf("Sending %d %s to '%.*s' with %d maximum outstanding jobs, please wait..\n", app.client.job_count, test_type, (int)app.client.dst_uri.slen, app.client.dst_uri.ptr, - app.client.job_window)); + app.client.job_window); for (i=0; i<app.thread_count; ++i) { - status = pj_thread_create(app.pool, NULL, &client_thread, NULL, + status = pj_thread_create(app.pool, NULL, &client_thread, (void*)i, 0, 0, &app.thread[i]); if (status != PJ_SUCCESS) { app_perror(THIS_FILE, "Unable to create thread", status); @@ -1527,10 +1576,14 @@ int main(int argc, char *argv[]) if (msec_req == 0) msec_req = 1; + if (app.client.job_submitted < app.client.job_count) + puts("\ntimed-out!\n"); + else + puts("\ndone.\n"); pj_ansi_snprintf( report, sizeof(report), - "Total %d %s sent in %d ms at rate %d/sec\n" + "Total %d %s sent in %d ms at rate of %d/sec\n" "Total %d responses receieved in %d ms:\n" " - 2xx responses: %7d (rate=%d/sec)\n" " - 3xx responses: %7d (rate=%d/sec)\n" diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index 2d635d62..b7b513a0 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -147,6 +147,57 @@ #endif +/** + * This macro controls maximum numbers of ioqueue events to be processed + * in a single pjsip_endpt_handle_events() poll. When PJSIP detects that + * there are probably more events available from the network and total + * events so far is less than this value, PJSIP will call pj_ioqueue_poll() + * again to get more events. + * + * Value 1 works best for ioqueue with select() back-end, while for IOCP it is + * probably best to set this value equal to PJSIP_MAX_TIMED_OUT_ENTRIES + * since IOCP only processes one event at a time. + * + * Default: 1 + */ +#ifndef PJSIP_MAX_NET_EVENTS +# define PJSIP_MAX_NET_EVENTS 1 +#endif + + +/** + * Max entries to process in timer heap per poll. + * + * Default: 10 + */ +#ifndef PJSIP_MAX_TIMED_OUT_ENTRIES +# define PJSIP_MAX_TIMED_OUT_ENTRIES 10 +#endif + + +/** + * Idle timeout interval to be applied to transports with no usage + * before the transport is destroyed. Value is in seconds. + * + * Default: 60 + */ +#ifndef PJSIP_TRANSPORT_IDLE_TIME +# define PJSIP_TRANSPORT_IDLE_TIME 60 +#endif + + +/** + * Maximum number of usages for a transport before a new transport is + * created. This only applies for ephemeral transports such as TCP. + * + * Currently this is not used. + * + * Default: -1 + */ +#ifndef PJSIP_MAX_TRANSPORT_USAGE +# define PJSIP_MAX_TRANSPORT_USAGE ((unsigned)-1) +#endif + /* Endpoint. */ #define PJSIP_MAX_TIMER_COUNT (2*PJSIP_MAX_TSX_COUNT + 2*PJSIP_MAX_DIALOG_COUNT) @@ -163,8 +214,6 @@ #define PJSIP_POOL_INC_TDATA 4000 #define PJSIP_POOL_LEN_UA 4000 #define PJSIP_POOL_INC_UA 4000 -#define PJSIP_TRANSPORT_CLOSE_TIMEOUT 30 -#define PJSIP_MAX_TRANSPORT_USAGE 16 #define PJSIP_MAX_FORWARDS_VALUE 70 @@ -192,12 +241,6 @@ #define PJSIP_POOL_LEN_DIALOG 1200 #define PJSIP_POOL_INC_DIALOG 512 -/* Transport idle timeout before it's destroyed. */ -#define PJSIP_TRANSPORT_IDLE_TIME 30 - -/* Max entries to process in timer heap per poll. */ -#define PJSIP_MAX_TIMED_OUT_ENTRIES 10 - /* Maximum header types. */ #define PJSIP_MAX_HEADER_TYPES 64 diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c index a9280ef8..a00c1af7 100644 --- a/pjsip/src/pjsip/sip_endpoint.c +++ b/pjsip/src/pjsip/sip_endpoint.c @@ -656,7 +656,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt, net_event_count += c; timeout.sec = timeout.msec = 0; } - } while (c > 0 && net_event_count < PJSIP_MAX_TIMED_OUT_ENTRIES*2); + } while (c > 0 && net_event_count < PJSIP_MAX_NET_EVENTS); count += net_event_count; if (p_count) |