This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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 libstdc++/82739] New: Sort is 30% slower compared to gcc44 on presorted array


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82739

            Bug ID: 82739
           Summary: Sort is 30% slower compared to gcc44 on presorted
                    array
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogerio.souza at gmail dot com
  Target Milestone: ---

In 2013 a bug was filed to fix a large performance degradation on
reverse-sorted array, which got fixed:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58437

However there is near 60% performance degradation with GCC 7.2.0 compared to
GCC 4.4.5, this time when running std::sort on a forward-sorted array.

Here is the testcase:

sort.cpp
=======================================================
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  const int num = 1000000000;                                                   
  std::vector<int> v;  
  v.reserve(num);

  for(int i=0;i!=num;++i) v.push_back(i);
  sort(v.begin(), v.end());
//  std::sort(std::begin(v), std::end(v));
}
=======================================================

Compilation Line: g++ -O3 sort.cpp -o sort
Run: time ./sort

# Server details
$ uname -a
Linux server 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64
x86_64 GNU/Linux

Results:

gcc version 4.1.2
real    0m25.511s
user    0m23.960s
sys     0m1.301s

gcc version 4.4.5
real    0m20.241s
user    0m18.716s
sys     0m1.328s

gcc version 4.8.3
real    0m26.742s
user    0m25.167s
sys     0m1.314s

gcc version 6.3.0
real    0m33.911s
user    0m32.312s
sys     0m1.266s

gcc version 7.2.0 
real    0m31.916s
user    0m30.308s
sys     0m1.299s

Is there any way to improve the run-time performance?

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