public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27077]  New: [x86, 4.1] builtin strlen poor performance
@ 2006-04-07 19:06 rdabrowa at poczta dot onet dot pl
  2006-04-07 19:12 ` [Bug target/27077] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rdabrowa at poczta dot onet dot pl @ 2006-04-07 19:06 UTC (permalink / raw)
  To: gcc-bugs

Code below, when compiled with -fno-builtin option works 5 times faster:
    #include <stdio.h>
    #include <string.h>

    int main(int argc, char *argv[])
    {
        char s[20] = "";
        int i, len;

        memset(s, 'a', sizeof(s)-1);
        for(i = 0; i < 10000000; ++i)
            len = strlen(s);
        printf("len: %d\n", len);
        return 0;
    }

My machine is Pentium IV


-- 
           Summary: [x86, 4.1] builtin strlen poor performance
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rdabrowa at poczta dot onet dot pl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/27077] [x86, 4.1] builtin strlen poor performance
  2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
@ 2006-04-07 19:12 ` pinskia at gcc dot gnu dot org
  2006-04-07 20:07 ` rdabrowa at poczta dot onet dot pl
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-07 19:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-04-07 19:12 -------
Your benchmark only deals with one sized strings, you should try with multiple
different sized strings like include one which is zero lengthed, one which is
2k-2M in length and try bechmarking that.  You might get a different result, it
might be GCC's builtin one is better for shorter lengths strings than what your
current benchmark does.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/27077] [x86, 4.1] builtin strlen poor performance
  2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
  2006-04-07 19:12 ` [Bug target/27077] " pinskia at gcc dot gnu dot org
@ 2006-04-07 20:07 ` rdabrowa at poczta dot onet dot pl
  2006-06-01 21:37 ` christophe dot jaillet at wanadoo dot fr
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rdabrowa at poczta dot onet dot pl @ 2006-04-07 20:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rdabrowa at poczta dot onet dot pl  2006-04-07 20:07 -------
Execution times (in seconds) for different lengths:

string                from
length    builtin     library
------------------------------
0         0.48        0.07
5         0.57        0.11
10        0.65        0.14
20        0.82        0.17
50        1.33        0.28
100       2.16        0.58
200       3.84        0.93
500       8.88        2.05
1000      17.28       3.92
2000      34.07       7.55
5000      84.46       18.59

and further, with loop count reduced 100 times:

string                from
length    builtin     library
------------------------------
10000     1.68        0.37
20000     3.36        0.75
50000     8.40        1.86
100000    16.80       3.69
200000    33.62       7.37


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/27077] [x86, 4.1] builtin strlen poor performance
  2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
  2006-04-07 19:12 ` [Bug target/27077] " pinskia at gcc dot gnu dot org
  2006-04-07 20:07 ` rdabrowa at poczta dot onet dot pl
@ 2006-06-01 21:37 ` christophe dot jaillet at wanadoo dot fr
  2006-08-08  6:35 ` hubicka at gcc dot gnu dot org
  2008-01-26 13:30 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: christophe dot jaillet at wanadoo dot fr @ 2006-06-01 21:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from christophe dot jaillet at wanadoo dot fr  2006-06-01 21:37 -------
On my AMD Athlon and current HEAD and, I have other results, i.e. 2 or 3 times
FASTER :

(using your 19 bytes long 'aaa..' string)

string                from
length    builtin     library
          (-O2)       (-fno-builtin -O2)
----------------------------------------
19        0.484        1.172


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/27077] [x86, 4.1] builtin strlen poor performance
  2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
                   ` (2 preceding siblings ...)
  2006-06-01 21:37 ` christophe dot jaillet at wanadoo dot fr
@ 2006-08-08  6:35 ` hubicka at gcc dot gnu dot org
  2008-01-26 13:30 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2006-08-08  6:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hubicka at gcc dot gnu dot org  2006-08-08 06:35 -------
The strlen inlining depends on the -mtune switch.  -mtune=athlon,generic and
i686
unrolls the strlen by in-line loop, while -mtune=pentium4 use the rep
operation.
Would be possible to benchmark both -mtune=generic and -mtune=pentium4 on the
chips?
If the -mtune=generic don't work well, we will need to revisit the loop.

Honza


-- 

hubicka at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/27077] [x86, 4.1] builtin strlen poor performance
  2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
                   ` (3 preceding siblings ...)
  2006-08-08  6:35 ` hubicka at gcc dot gnu dot org
@ 2008-01-26 13:30 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-26 13:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-01-26 12:37 -------
I think this benchmark is dubious, it likely depends on the library and
whatnot.
Also the benchmarks are out-of-date.  Closing as invalid.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-01-26 12:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07 19:06 [Bug c/27077] New: [x86, 4.1] builtin strlen poor performance rdabrowa at poczta dot onet dot pl
2006-04-07 19:12 ` [Bug target/27077] " pinskia at gcc dot gnu dot org
2006-04-07 20:07 ` rdabrowa at poczta dot onet dot pl
2006-06-01 21:37 ` christophe dot jaillet at wanadoo dot fr
2006-08-08  6:35 ` hubicka at gcc dot gnu dot org
2008-01-26 13:30 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).