You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@hyperreal.org on 1999/05/24 08:53:37 UTC
cvs commit: apache-apr/pthreads/src/main http_config.c http_core.c http_main.c
manoj 99/05/23 23:53:37
Modified: pthreads/src/include httpd.h
pthreads/src/main http_config.c http_core.c http_main.c
Log:
Change the algorithm for spare server maintanence to base its decisions
on the number of idle threads, rather than the number of mostly idle
processes.
Revision Changes Path
1.15 +0 -8 apache-apr/pthreads/src/include/httpd.h
Index: httpd.h
===================================================================
RCS file: /home/cvs/apache-apr/pthreads/src/include/httpd.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -u -r1.14 -r1.15
--- httpd.h 1999/04/14 21:03:19 1.14
+++ httpd.h 1999/05/24 06:53:32 1.15
@@ -370,14 +370,6 @@
#define DEFAULT_THREADS_PER_CHILD 50
#endif
-#ifndef DEFAULT_IDLE_THRESHOLD
-#define DEFAULT_IDLE_THRESHOLD (int)(DEFAULT_THREADS_PER_CHILD * 0.05)
-#endif
-
-#ifndef DEFAULT_BUSY_THRESHOLD
-#define DEFAULT_BUSY_THRESHOLD (DEFAULT_THREADS_PER_CHILD - (int)(DEFAULT_THREADS_PER_CHILD * 0.05))
-#endif
-
#ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
#define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
#endif
1.12 +0 -2 apache-apr/pthreads/src/main/http_config.c
Index: http_config.c
===================================================================
RCS file: /home/cvs/apache-apr/pthreads/src/main/http_config.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -u -r1.11 -r1.12
--- http_config.c 1999/03/17 17:01:18 1.11
+++ http_config.c 1999/05/24 06:53:33 1.12
@@ -1394,8 +1394,6 @@
ap_lock_fname = DEFAULT_LOCKFILE;
ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
- ap_idle_thread_threshold = DEFAULT_IDLE_THRESHOLD;
- ap_busy_thread_threshold = DEFAULT_BUSY_THRESHOLD;
/* ZZZ Initialize the Network Address here. */
ap_bind_address.s_addr = htonl(INADDR_ANY);
ap_listeners = NULL;
1.13 +0 -35 apache-apr/pthreads/src/main/http_core.c
Index: http_core.c
===================================================================
RCS file: /home/cvs/apache-apr/pthreads/src/main/http_core.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -u -r1.12 -r1.13
--- http_core.c 1999/04/14 21:03:28 1.12
+++ http_core.c 1999/05/24 06:53:33 1.13
@@ -2155,28 +2155,7 @@
return NULL;
}
-static const char *set_idle_threshold(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
- ap_idle_thread_threshold = atoi(arg);
- return NULL;
-}
-
-static const char *set_busy_threshold(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_busy_thread_threshold = atoi(arg);
- return NULL;
-}
-
static const char *set_max_free_servers(cmd_parms *cmd, void *dummy, char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
@@ -2224,8 +2203,6 @@
}
static const char *set_threads(cmd_parms *cmd, void *dummy, char *arg) {
- int user_def_idle = ap_idle_thread_threshold;
- int user_def_busy = ap_busy_thread_threshold;
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return err;
@@ -2233,14 +2210,6 @@
ap_threads_per_child = atoi(arg);
- ap_idle_thread_threshold = (int)(ap_threads_per_child * 0.05);
- ap_busy_thread_threshold = ap_threads_per_child - (int)(ap_threads_per_child * 0.05);
-
- if (user_def_idle != DEFAULT_IDLE_THRESHOLD)
- ap_idle_thread_threshold = user_def_idle;
- if (user_def_busy != DEFAULT_BUSY_THRESHOLD)
- ap_busy_thread_threshold = user_def_busy;
-
if (ap_threads_per_child < 1) {
fprintf(stderr, "WARNING: Require ThreadsPerChild > 0, setting to 1\n");
ap_threads_per_child = 1;
@@ -2838,10 +2807,6 @@
"Maximum number of idle children" },
{ "MaxServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1,
"Deprecated equivalent to MaxSpareServers" },
-{ "IdleThreadThreshold", set_idle_threshold, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle threads, below which process is considered ready for reaping." },
-{ "BusyThreadThreshold", set_busy_threshold, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle threads, above which process is considered busy." },
{ "ServersSafetyLimit", set_server_limit, NULL, RSRC_CONF, TAKE1,
"Deprecated equivalent to MaxClients" },
{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
1.84 +16 -20 apache-apr/pthreads/src/main/http_main.c
Index: http_main.c
===================================================================
RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -u -r1.83 -r1.84
--- http_main.c 1999/05/24 06:29:43 1.83
+++ http_main.c 1999/05/24 06:53:34 1.84
@@ -2079,8 +2079,7 @@
static void perform_idle_server_maintenance(void)
{
int i, j;
- int to_kill;
- int idle_count, idle_thread_count;
+ int idle_count_ceil, idle_count_floor, idle_thread_count;
thread_score *ss;
time_t now = 0;
int free_length;
@@ -2091,8 +2090,9 @@
/* initialize the free_list */
free_length = 0;
- to_kill = -1;
- idle_count = 0;
+ idle_count_ceil = 0;
+ idle_count_floor = 0;
+ idle_thread_count = 0;
last_non_dead = -1;
total_non_dead = 0;
@@ -2103,8 +2103,8 @@
int status = SERVER_DEAD;
int any_dying_threads = 0;
int all_dead_threads = 1;
+ int idle_thread_addition = 0;
- idle_thread_count = 0;
if (i >= max_daemons_limit && free_length == idle_spawn_rate)
break;
for (j = 0; j < ap_threads_per_child; j++) {
@@ -2122,13 +2122,7 @@
* This depends on the ordering of SERVER_READY and SERVER_STARTING.
*/
if (status <= SERVER_READY) {
- ++ idle_thread_count;
- /* always kill the highest numbered child if we have to...
- * no really well thought out reason ... other than observing
- * the server behaviour under linux where lower numbered
- * children tend to service more hits (and hence are more
- * likely to have their data in cpu caches).
- */
+ ++idle_thread_addition;
}
}
if (all_dead_threads && free_length < idle_spawn_rate) {
@@ -2140,15 +2134,17 @@
}
if (!any_dying_threads) {
++total_non_dead;
-
- if (idle_thread_count > ap_idle_thread_threshold) {
- idle_count++;
- to_kill = i;
- }
+ idle_thread_count += idle_thread_addition;
}
}
max_daemons_limit = last_non_dead + 1;
- if (idle_count > ap_daemons_max_free) {
+ idle_count_floor = idle_thread_count / ap_threads_per_child;
+ idle_count_ceil = idle_count_floor;
+ if (idle_thread_count % ap_threads_per_child) {
+ idle_count_ceil++;
+ }
+
+ if (idle_count_ceil > ap_daemons_max_free) {
/* Kill off one child */
char char_of_death = '!';
if (write(ap_pipe_of_death[1], &char_of_death, 1) == -1) {
@@ -2156,7 +2152,7 @@
}
idle_spawn_rate = 1;
}
- else if (idle_count < ap_daemons_min_free) {
+ else if (idle_count_floor < ap_daemons_min_free) {
/* terminate the free list */
if (free_length == 0) {
/* only report this condition once */
@@ -2179,7 +2175,7 @@
"to increase StartServers, or Min/MaxSpareServers), "
"spawning %d children, there are %d idle, and "
"%d total children", idle_spawn_rate,
- idle_count, total_non_dead);
+ idle_count_floor, total_non_dead);
}
for (i = 0; i < free_length; ++i) {
make_child(server_conf, free_slots[i], now);