My goal was to check for useless memory allocation when calling logging function. Logging with TRACE is unlikely to output something on a production machine. However, function called as parameters of the logging function will still be called.

I made a check on the whole source code to check for useless memory allocation as a "side effect" of logging.
I found the one below, in an error path.


It is part of the time I'm spending to analyze memory allocation and use done by httpd. I've modified apr_palloc and so on to give me some feedback and I'm looking at it. With current trunk, with a light configuration and a server configured to be single threaded, 11541 calls to apr_palloc, for a total of 4,4 Mo, are performed during stat-up. According to my configuration, I find it high, but ok, why not, it is just start-up For processing a single request like http://localhosr/foo, 254 new calls are done for a total of 15 ko, mostly in the request pool. Reducing it to fit in only one 8k, if possible, would be nice. It would avoid the pool to allocate more memory.
Here is my goal.


BTW, I tried to activate pool debug with using |-enable-pool-debug=all but the server crashes while starting on my test machine. Do you know if it is supposed to work (and I do something wrong) or no one uses it with httpd ?

I haven't saved details about it but it would be easy to reproduce if you are interested.


|CJ



Le 13/03/2013 22:26, Stefan Fritsch a écrit :
Note that there is some macro magic in http_log.h that does this automatically on C99 compilers. There is nothing wrong with doing the check explicitly, and it is definitely a good idea if the saved function call is very expensive. But in general other improvements may have more impact and therefore be a better use of your time. But of course that's your choice ;)

On Fri, 1 Mar 2013, jaillet...@apache.org wrote:

Author: jailletc36
Date: Fri Mar  1 06:33:40 2013
New Revision: 1451478

URL: http://svn.apache.org/r1451478
Log:
Avoid some memory allocation on error path in 'http2env' if TRACE1 logging is not activated
Avoid a function ca

Modified:
   httpd/httpd/trunk/server/util_script.c

Modified: httpd/httpd/trunk/server/util_script.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_script.c?rev=1451478&r1=1451477&r2=1451478&view=diff ==============================================================================
--- httpd/httpd/trunk/server/util_script.c (original)
+++ httpd/httpd/trunk/server/util_script.c Fri Mar  1 06:33:40 2013
@@ -73,9 +73,10 @@ static char *http2env(request_rec *r, co
            *cp++ = '_';
        }
        else {
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
- "Not exporting header with invalid name as envvar: %s",
-                          ap_escape_logitem(r->pool, w));
+            if (APLOGrtrace1(r))
+                ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
+ "Not exporting header with invalid name as envvar: %s",
+                            ap_escape_logitem(r->pool, w));
            return NULL;
        }
    }


Reply via email to