httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: svn commit: r109866 - /httpd/httpd/trunk/modules/loggers/mod_log_config.c
Date Sun, 05 Dec 2004 13:47:44 GMT
On Sun, Dec 05, 2004 at 07:05:23AM -0000, Paul Querna wrote:
> Author: pquerna
> Date: Sat Dec  4 23:05:23 2004
> New Revision: 109866
> 
> URL: http://svn.apache.org/viewcvs?view=rev&rev=109866
> Log:
> mod_log_config.c: Use iovecs to write the log line to eliminate a memcpy

IIRC, writev'ing several small blocks to a file is actually generally
more expensive than doing a memcpy in userspace and calling write.  Did
you benchmark this to be faster/better/...?

> Modified:
>    httpd/httpd/trunk/modules/loggers/mod_log_config.c
> 
> Modified: httpd/httpd/trunk/modules/loggers/mod_log_config.c
> Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/loggers/mod_log_config.c?view=diff&rev=109866&p1=httpd/httpd/trunk/modules/loggers/mod_log_config.c&r1=109865&p2=httpd/httpd/trunk/modules/loggers/mod_log_config.c&r2=109866
> ==============================================================================
> --- httpd/httpd/trunk/modules/loggers/mod_log_config.c	(original)
> +++ httpd/httpd/trunk/modules/loggers/mod_log_config.c	Sat Dec  4 23:05:23 2004
> @@ -1343,19 +1343,18 @@
>                             apr_size_t len)
>  
>  {
> -    char *str;
> -    char *s;
>      int i;
>      apr_status_t rv;
> +    struct iovec *vec;
>  
> -    str = apr_palloc(r->pool, len + 1);
> +    vec = apr_palloc(r->pool, nelts * sizeof(struct iovec));
>  
> -    for (i = 0, s = str; i < nelts; ++i) {
> -        memcpy(s, strs[i], strl[i]);
> -        s += strl[i];
> +    for (i = 0; i < nelts; ++i) {
> +        vec[i].iov_base = strs[i];
> +        vec[i].iov_len = strl[i];
>      }
>  
> -    rv = apr_file_write((apr_file_t*)handle, str, &len);
> +    rv = apr_file_writev((apr_file_t*)handle, vec, nelts, &i);
>  
>      return rv;
>  }

Mime
View raw message