Bug 123148

Summary: performance defect of snprintf in glibc
Product: Red Hat Enterprise Linux 3 Reporter: Yiyang Dai <yiyang.dai>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-02 01:57:32 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 106771, 122950    

Description Yiyang Dai 2004-05-12 22:44:02 EDT
Description of problem:
compare to RH AS 2.1 the performance of snprintf is really 
unacceptable in RHEL3(RHEL-U2 has the same problem)

Version-Release number of selected component (if applicable):
RHEL3 U2 
KERNEL 2.4.21-15.EL
glibc-2.3.2-95.20

How reproducible:
a simple testing program
---------------sprintf.c-------------------
#include "stdio.h"
#include "unistd.h"
#include "sys/time.h"


unsigned int GetTickCount()
{
        struct timespec tp;
        unsigned int tt;
        clock_gettime(&tp);
        tt = tp.tv_sec*1000+tp.tv_nsec/1000000;
        return(tt);
}
int clock_gettime( struct timespec *tp)
{
        struct timeval tv;
        gettimeofday(&tv, NULL);
        tp->tv_sec = tv.tv_sec;
        tp->tv_nsec = tv.tv_usec*1000;
        return 0;
}



main(){
        char buf[1024];
        int x=234234;
        unsigned int count1,count2,count3;
        int i;

        count1=GetTickCount();
        for (i=0;i<1000000;i++)
        sprintf
(buf,"sfsdfasdfasdfasdfas;ja;sdjf;lakjsdfkasfkasasdofas;fw.nxzvohpowsy
erqnwoirhasknfasdfhoaudfoizxcvnfasdfasfasdfasdfasdfasdf%d",x);

        count2=GetTickCount();
        count3=count2-count1;

        printf("%u msec used\n",count3);
}

---------------sprintf.c-------------------
Steps to Reproduce:
compile with gcc or intel's icc

results:
on RH AS 2.1 the result is 1395 msec
but on RHEL3 & RHEL3-U2 the result is 5243 msec

on RH AS 2.1 if compile the testing code with -static ( static link 
the glibc-2.2.4-29.2 ) , and move the binary to RHEL3 , the result 
will be 1385 msec which seems ok.




Additional info:

both RH AS2.1 & RHEL3(RHEL3-U2) running on hp rx26000 (2x1.5GHz 
Itanium2 )
Comment 2 Yiyang Dai 2004-05-16 20:39:17 EDT
have tried , about 5x performance improved . when will this be 
mergered to officical release ? U3 ?
Comment 3 Jakub Jelinek 2004-05-17 03:13:43 EDT
Should go into FC3, RHEL3/U3 and RHEL4 b1.
Comment 5 Jakub Jelinek 2004-06-24 15:06:04 EDT
The patch is in glibc-2.3.2-95.21.
Comment 6 Jay Turner 2004-08-20 08:10:02 EDT
Performance with 2.3.2-95.26 is vastly improved.  Moving to modified
and will release as part of the U3 errata.
Comment 7 Jay Turner 2004-09-02 01:57:32 EDT
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-384.html