This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/15884] New: Big performance regression in strcoll


http://sourceware.org/bugzilla/show_bug.cgi?id=15884

            Bug ID: 15884
           Summary: Big performance regression in strcoll
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: neleai at seznam dot cz
                CC: drepper.fsp at gmail dot com

Hi, 
After looking to strcoll code I noticed glaring performance problems. 
Consider following program:

#include <locale.h>
#include <string.h>
#include <stdlib.h>
int foo(char *a,char *b){
  return strcoll(a,b);
}

int main(){
  setlocale(LC_ALL, "en_US.UTF8");
  int i,f=0;
  char *a=malloc(1000000);
  char *b=malloc(1000000);
  memset(a,32,N); a[N]=0;
  memset(b,33,N); a[N]=0;

  for (i=0;i<1000000;i++)
        f+=foo(a,b);
  return f;
}

As a and b differ in first character we should get O(1) performance, yet I got:

ondra@neklekam:~$ gcc -DN=1 strcoll.c ; time ./a.out

real    0m0.078s
user    0m0.077s
sys    0m0.000s
ondra@neklekam:~$ gcc -DN=10 strcoll.c ; time ./a.out

real    0m0.283s
user    0m0.283s
sys    0m0.000s
ondra@neklekam:~$ gcc -DN=100 strcoll.c ; time ./a.out

real    0m2.016s
user    0m2.013s
sys    0m0.003s

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]