You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Pane <bp...@pacbell.net> on 2001/07/15 16:19:51 UTC
[PATCH] performance fixes for number formatting
In profiling the httpd, I've found the conv_10 function
(used in the implementation of "%d" for the apr_*printf
functions) to be one of the top 10 consumers of user-mode
CPU time. There are a small number of places in the httpd
that cause most of the calls to this function.
The attached patch fixes the problem. It includes two
changes to APR:
* new functions apr_itoa, apr_ltoa, and apr_off_t_toa
that provide itoa-type functionality based on pools
* Inline code in inet_ntop4 to replace sprintf for converting
binary IP addresses into dotted-decimal format
and two changes to Apache:
* use the apr_itoa functions in setting the content length,
in place of apr_psprintf
* use the apr_itoa functions to replace frequent uses of
'sprintf("%d",...)' in mod_log_config.
--Brian
Re: [PATCH] performance fixes for number formatting
Posted by Greg Ames <gr...@remulak.net>.
Brian Pane wrote:
>
> In profiling the httpd, I've found the conv_10 function
> (used in the implementation of "%d" for the apr_*printf
> functions) to be one of the top 10 consumers of user-mode
> CPU time. There are a small number of places in the httpd
> that cause most of the calls to this function.
>
> The attached patch fixes the problem.
committed...thanks! Keep up the good work.
Greg
Re: [PATCH] performance fixes for number formatting
Posted by Brian Pane <bp...@pacbell.net>.
dean gaudet wrote:
>On Tue, 17 Jul 2001, Brian Pane wrote:
>
>>dean gaudet wrote:
>>
>>>you might want to disassemble the functions in gdb (or using objdump) to
>>>make sure that gcc emits a single division instruction for the "x / 10",
>>>"x % 10" expressions -- i forget the cases where it can and can't do this.
>>>the low level div instruction is a two result opcode, quotient and
>>>remainder. if it isn't doing it, then figure out how to make it do that
>>>and you'll see even more improvement :)
>>>
>>I see one just idivl call in the output of gcc on x86. I assume
>>that means it has done the optimization, right?
>>
>
>yup, rad -- you should also see it use %eax (quotient) and %edx
>(remainder) after the opcode.
>
Yes indeed, I see it using %eax and %edx afterward.
Is somebody with commit access for httpd-2.0 and APR willing
to do commit the changes into CVS?
Thanks,
--Brian
Re: [PATCH] performance fixes for number formatting
Posted by Brian Pane <bp...@pacbell.net>.
dean gaudet wrote:
>On Tue, 17 Jul 2001, Brian Pane wrote:
>
>>dean gaudet wrote:
>>
>>>you might want to disassemble the functions in gdb (or using objdump) to
>>>make sure that gcc emits a single division instruction for the "x / 10",
>>>"x % 10" expressions -- i forget the cases where it can and can't do this.
>>>the low level div instruction is a two result opcode, quotient and
>>>remainder. if it isn't doing it, then figure out how to make it do that
>>>and you'll see even more improvement :)
>>>
>>I see one just idivl call in the output of gcc on x86. I assume
>>that means it has done the optimization, right?
>>
>
>yup, rad -- you should also see it use %eax (quotient) and %edx
>(remainder) after the opcode.
>
Yes indeed, I see it using %eax and %edx afterward.
Is somebody with commit access for httpd-2.0 and APR willing
to do commit the changes into CVS?
Thanks,
--Brian
Re: [PATCH] performance fixes for number formatting
Posted by dean gaudet <de...@arctic.org>.
On Tue, 17 Jul 2001, Brian Pane wrote:
> dean gaudet wrote:
>
> >you might want to disassemble the functions in gdb (or using objdump) to
> >make sure that gcc emits a single division instruction for the "x / 10",
> >"x % 10" expressions -- i forget the cases where it can and can't do this.
> >the low level div instruction is a two result opcode, quotient and
> >remainder. if it isn't doing it, then figure out how to make it do that
> >and you'll see even more improvement :)
> >
> I see one just idivl call in the output of gcc on x86. I assume
> that means it has done the optimization, right?
yup, rad -- you should also see it use %eax (quotient) and %edx
(remainder) after the opcode.
-dean
Re: [PATCH] performance fixes for number formatting
Posted by dean gaudet <de...@arctic.org>.
On Tue, 17 Jul 2001, Brian Pane wrote:
> dean gaudet wrote:
>
> >you might want to disassemble the functions in gdb (or using objdump) to
> >make sure that gcc emits a single division instruction for the "x / 10",
> >"x % 10" expressions -- i forget the cases where it can and can't do this.
> >the low level div instruction is a two result opcode, quotient and
> >remainder. if it isn't doing it, then figure out how to make it do that
> >and you'll see even more improvement :)
> >
> I see one just idivl call in the output of gcc on x86. I assume
> that means it has done the optimization, right?
yup, rad -- you should also see it use %eax (quotient) and %edx
(remainder) after the opcode.
-dean
Re: [PATCH] performance fixes for number formatting
Posted by Brian Pane <bp...@pacbell.net>.
dean gaudet wrote:
>you might want to disassemble the functions in gdb (or using objdump) to
>make sure that gcc emits a single division instruction for the "x / 10",
>"x % 10" expressions -- i forget the cases where it can and can't do this.
>the low level div instruction is a two result opcode, quotient and
>remainder. if it isn't doing it, then figure out how to make it do that
>and you'll see even more improvement :)
>
I see one just idivl call in the output of gcc on x86. I assume
that means it has done the optimization, right?
--Brian
Re: [PATCH] performance fixes for number formatting
Posted by Brian Pane <bp...@pacbell.net>.
dean gaudet wrote:
>you might want to disassemble the functions in gdb (or using objdump) to
>make sure that gcc emits a single division instruction for the "x / 10",
>"x % 10" expressions -- i forget the cases where it can and can't do this.
>the low level div instruction is a two result opcode, quotient and
>remainder. if it isn't doing it, then figure out how to make it do that
>and you'll see even more improvement :)
>
I see one just idivl call in the output of gcc on x86. I assume
that means it has done the optimization, right?
--Brian
Re: [PATCH] performance fixes for number formatting
Posted by dean gaudet <de...@arctic.org>.
you might want to disassemble the functions in gdb (or using objdump) to
make sure that gcc emits a single division instruction for the "x / 10",
"x % 10" expressions -- i forget the cases where it can and can't do this.
the low level div instruction is a two result opcode, quotient and
remainder. if it isn't doing it, then figure out how to make it do that
and you'll see even more improvement :)
(the ancient reason for the ldiv() function was to get at both results
without the compiler being smart enough to figure it out itself.)
-dean
On Sun, 15 Jul 2001, Brian Pane wrote:
> In profiling the httpd, I've found the conv_10 function
> (used in the implementation of "%d" for the apr_*printf
> functions) to be one of the top 10 consumers of user-mode
> CPU time. There are a small number of places in the httpd
> that cause most of the calls to this function.
>
> The attached patch fixes the problem. It includes two
> changes to APR:
> * new functions apr_itoa, apr_ltoa, and apr_off_t_toa
> that provide itoa-type functionality based on pools
> * Inline code in inet_ntop4 to replace sprintf for converting
> binary IP addresses into dotted-decimal format
> and two changes to Apache:
> * use the apr_itoa functions in setting the content length,
> in place of apr_psprintf
> * use the apr_itoa functions to replace frequent uses of
> 'sprintf("%d",...)' in mod_log_config.
>
> --Brian
>
>
Re: [PATCH] performance fixes for number formatting
Posted by dean gaudet <de...@arctic.org>.
you might want to disassemble the functions in gdb (or using objdump) to
make sure that gcc emits a single division instruction for the "x / 10",
"x % 10" expressions -- i forget the cases where it can and can't do this.
the low level div instruction is a two result opcode, quotient and
remainder. if it isn't doing it, then figure out how to make it do that
and you'll see even more improvement :)
(the ancient reason for the ldiv() function was to get at both results
without the compiler being smart enough to figure it out itself.)
-dean
On Sun, 15 Jul 2001, Brian Pane wrote:
> In profiling the httpd, I've found the conv_10 function
> (used in the implementation of "%d" for the apr_*printf
> functions) to be one of the top 10 consumers of user-mode
> CPU time. There are a small number of places in the httpd
> that cause most of the calls to this function.
>
> The attached patch fixes the problem. It includes two
> changes to APR:
> * new functions apr_itoa, apr_ltoa, and apr_off_t_toa
> that provide itoa-type functionality based on pools
> * Inline code in inet_ntop4 to replace sprintf for converting
> binary IP addresses into dotted-decimal format
> and two changes to Apache:
> * use the apr_itoa functions in setting the content length,
> in place of apr_psprintf
> * use the apr_itoa functions to replace frequent uses of
> 'sprintf("%d",...)' in mod_log_config.
>
> --Brian
>
>