You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ian Holsman <Ia...@cnet.com> on 2001/04/30 20:47:34 UTC
[Proposed PATCH] mod_include -- Only evaluate the environment var
iables when needed
This patch changes mod_include so that it only evaluates the SSI environment tags when
required (in the handle_echo and printenv functions).
This change increases my PageReqs/sec from 246/sec to 313/sec (~27%) on pages which do
not need the environment variables set. (doesn't use the echo/printenv commands)
I'm not sure how this affects the mod-cgi SSI embedded command.
..Ian
Index: mod_include.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.109
diff -u -r1.109 mod_include.c
--- mod_include.c 2001/04/21 22:01:05 1.109
+++ mod_include.c 2001/04/30 18:47:08
@@ -98,6 +98,9 @@
#define BYTE_COUNT_THRESHOLD AP_MIN_BYTES_TO_WRITE
+
+
+static void set_lazy_vars( request_rec *r ) ;
/* ------------------------ Environment function -------------------------- */
/* XXX: could use ap_table_overlap here */
@@ -889,6 +892,9 @@
encode = E_ENTITY;
*inserted_head = NULL;
+
+ set_lazy_vars(r);
+
if (ctx->flags & FLAG_PRINTING) {
while (1) {
ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
@@ -2299,6 +2305,8 @@
char *tag_val = NULL;
apr_bucket *tmp_buck;
+ set_lazy_vars(r);
+
if (ctx->flags & FLAG_PRINTING) {
ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
if ((tag == NULL) && (tag_val == NULL)) {
@@ -2747,9 +2755,12 @@
else {
/* we're not a nested include, so we create an initial
* environment */
+ /*
ap_add_common_vars(r);
ap_add_cgi_vars(r);
add_include_vars(r, conf->default_time_fmt);
+ */
+ apr_table_unset( r->subprocess_env, "INCLUDE_VARS" );
}
/* XXX: this is bogus, at some point we're going to do a subrequest,
* and when we do it we're going to be subjecting code that doesn't
@@ -2817,6 +2828,22 @@
include_dir_config *conf = (include_dir_config *)mconfig;
conf->default_time_fmt = apr_pstrdup(cmd->pool, fmt);
return NULL;
+}
+/*
+ * Perform a evaluation of Standard SSI Include vars if they have not been included already
+ *
+ */
+static void set_lazy_vars( request_rec *r )
+{
+
+ if ( apr_table_get( r->subprocess_env, "INCLUDE_VARS" ) == NULL ) {
+ include_dir_config *conf = (include_dir_config *)ap_get_module_config(r->per_dir_config,
+ &include_module);
+ apr_table_setn(r->subprocess_env, "INCLUDE_VARS", "Y");
+ ap_add_common_vars(r);
+ ap_add_cgi_vars(r);
+ add_include_vars(r, conf->default_time_fmt);
+ }
}
/*
--
Ian Holsman
Performance Measurement & Analysis
415-364-8608