Hi A small malloc change, saves some 4kb of memory, and improves cache usage.
- Lauri
>From 42a571089ba9ce029a153edf75454a54ccce9f0d Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Mon, 7 May 2012 16:46:35 +0300 Subject: [PATCH] sched: Allocate the connections at once This saves some 4kb of memory, and improves cache usage. Signed-off-by: Lauri Kasanen <[email protected]> --- src/mk_scheduler.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mk_scheduler.c b/src/mk_scheduler.c index 8d28277..52d4777 100644 --- a/src/mk_scheduler.c +++ b/src/mk_scheduler.c @@ -212,7 +212,7 @@ static void *mk_sched_launch_worker_loop(void *thread_conf) int mk_sched_register_thread(int efd) { int i; - struct sched_connection *sched_conn; + struct sched_connection *sched_conn, *array; struct sched_list_node *sl; static int wid = 0; @@ -236,8 +236,10 @@ int mk_sched_register_thread(int efd) mk_list_init(&sl->busy_queue); mk_list_init(&sl->av_queue); + array = mk_mem_malloc_z(sizeof(struct sched_connection) * config->worker_capacity); + for (i = 0; i < config->worker_capacity; i++) { - sched_conn = mk_mem_malloc_z(sizeof(struct sched_connection)); + sched_conn = &array[i]; sched_conn->status = MK_SCHEDULER_CONN_AVAILABLE; sched_conn->socket = -1; sched_conn->arrive_time = 0; -- 1.7.2.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
