You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2011/03/12 23:14:34 UTC
DO NOT REPLY [Bug 50919] New: potential performance waste caused by
sprintf
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
Summary: potential performance waste caused by sprintf
Product: Apache httpd-2
Version: 2.2.17
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: All
AssignedTo: bugs@httpd.apache.org
ReportedBy: songlinhai0543@gmail.com
/httpd-2.2.17/modules/loggers/mod_log_forensic.c:129
sprintf(q, "%02x", *(unsigned char *)p);
After reading apache codes, I find this code fragment. Using this method to
convert a number into a character which represents a hex number is very slow.
I give out my patch as follows:
static char hexmap[]= { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
'b', 'c', 'd', 'e', 'f' };
q = hexmap[*(unsigned char *)p];
In my unit test, my patch run as 7 times faster than the code fragment I find.
If the code fragment will be executed many times, I believe it can slow down
the whole application.
I suggest that we should fix this bug.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 50919] potential performance waste caused by
sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
--- Comment #2 from Linhai Song <so...@gmail.com> 2011-03-12 19:13:47 EST ---
(In reply to comment #1)
> It appears you have compressed 2^8 bits into 2^4 bit representation, is that
> what you meant to do?
>
> Have you tested this with mapping to hexmap[(p >> 4)& 15] . hexmap[p & 15]...
> and using a 256 char hexmap?
yes, this is what I mean
I write a wrong patch, and very sorry for the mistake.
the correct patch is
static char _dig_vec_lower[]= { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a','b', 'c', 'd', 'e', 'f' };
static void array_to_hex( char * to , const char * str , unsigned char len )
{
const char * str_end = str + len;
for( ; str != str_end ; ++ str )
{
*to++ = _dig_vec_lower[ ((unsigned char) *str) >> 4 ];
*to++ = _dig_vec_lower[ ((unsigned char) *str) & 0x0F ];
}
}
my unit test is using this patch, and it is more than 7 times faster than
calling sprintf.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 50919] potential performance waste caused by sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
Christophe JAILLET <ch...@wanadoo.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Christophe JAILLET <ch...@wanadoo.fr> ---
Backported to 2.4.x: r1455222
Will be part of 2.4.5
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 50919] potential performance waste caused by
sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
--- Comment #1 from William A. Rowe Jr. <wr...@apache.org> 2011-03-12 17:44:25 EST ---
It appears you have compressed 2^8 bits into 2^4 bit representation, is that
what you meant to do?
Have you tested this with mapping to hexmap[(p >> 4)& 15] . hexmap[p & 15]...
and using a 256 char hexmap?
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 50919] potential performance waste caused by
sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
Eric Covener <co...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 50919] potential performance waste caused by sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
Christophe JAILLET <ch...@wanadoo.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |FixedInTrunk
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 50919] potential performance waste caused by sprintf
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919
--- Comment #3 from Christophe JAILLET <ch...@wanadoo.fr> ---
Fixed in trunk.
http://svn.apache.org/viewvc?view=revision&sortby=date&revision=1429564
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org