httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 50919] New: potential performance waste caused by sprintf
Date Sat, 12 Mar 2011 22:14:34 GMT
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


Mime
View raw message