public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/58244] New: global variable: many THOUSANDS times slower execution
@ 2013-08-26 18:05 martin.konopka at stuba dot sk
  2013-08-26 18:09 ` [Bug regression/58244] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: martin.konopka at stuba dot sk @ 2013-08-26 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58244
           Summary: global variable: many THOUSANDS times slower execution
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
          Assignee: unassigned at gcc dot gnu.org
          Reporter: martin.konopka at stuba dot sk

Created attachment 30701
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30701&action=edit
sample C code to demonstrate the performance issue

* I have a very small sample code written in pure C.
* I am using 64-bit linux:
 - Linux Mint Maya with gcc 4.6.3
   (gcc and libraries same as ubuntu 12.04 LTS)
 - ubuntu 12.10  with gcc 4.7.2
 - newest Scientific Linux with compilers 4.4.7  and  4.7.3

When I declare a simple variable (auxvar , see the code) as a local one, then
the executable is about as fast as it should be.

When I declare the variable as a global one, then the executable becomes
insanely slow.

The behaviour is the same for any of the above mentioned linuxes and compiler
versions. Please see attached C code. Compile it using

gcc -O2 -Wall slowcode.c -lm

Please do NOT declare auxvar both globally and locally. Use either local or
global declaration.

Thanks.


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
@ 2013-08-26 18:09 ` pinskia at gcc dot gnu.org
  2013-08-26 18:21 ` martin.konopka at stuba dot sk
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-08-26 18:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Why do you think this is a bug?


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
  2013-08-26 18:09 ` [Bug regression/58244] " pinskia at gcc dot gnu.org
@ 2013-08-26 18:21 ` martin.konopka at stuba dot sk
  2013-08-26 18:36 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: martin.konopka at stuba dot sk @ 2013-08-26 18:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Konôpka <martin.konopka at stuba dot sk> ---
It it is confirmed, it is a very serious performance issue. In my test the code
with the global declaration executed about 60000 times slower than the code
with the local declaration.

For people doing HPC this is a bug because it turns the compiled binary being
unusable for codes affected by the issue. (60000 times slower is simply no go.)

Large C codes often use global variables, otherwise the lists of function
parameters would become enormously long.
>From gcc-bugs-return-428402-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 26 18:24:25 2013
Return-Path: <gcc-bugs-return-428402-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23771 invoked by alias); 26 Aug 2013 18:24:25 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 23738 invoked by uid 48); 26 Aug 2013 18:24:22 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug regression/58244] global variable: many THOUSANDS times slower execution
Date: Mon, 26 Aug 2013 18:24:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: regression
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58244-4-eIghjIasXw@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58244-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-08/txt/msg01326.txt.bz2
Content-length: 616

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX244

--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
With auxval local, the compiler knows that computing suma, etc is useless and
removes all that code, including the calls to sin. So you would like the
compiler to do the same for a global auxval? That requires the compiler to know
that no other TU may access auxval (maybe something along the lines of
-fwhole-program or -flto). Let's add "static" to the declaration of auxval.
Then it does indeed miss the optimization. But still I doubt that your goal was
for the compiler to remove all your code.


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
  2013-08-26 18:09 ` [Bug regression/58244] " pinskia at gcc dot gnu.org
  2013-08-26 18:21 ` martin.konopka at stuba dot sk
@ 2013-08-26 18:36 ` schwab@linux-m68k.org
  2013-08-26 18:46 ` martin.konopka at stuba dot sk
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2013-08-26 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
gcc was able to optimize your code to make it 6000 times faster.  How is that a
regression?


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
                   ` (2 preceding siblings ...)
  2013-08-26 18:36 ` schwab@linux-m68k.org
@ 2013-08-26 18:46 ` martin.konopka at stuba dot sk
  2013-08-26 18:59 ` martin.konopka at stuba dot sk
  2013-09-07 14:18 ` glisse at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: martin.konopka at stuba dot sk @ 2013-08-26 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Konôpka <martin.konopka at stuba dot sk> ---
I do not fully understand the question. In both cases I used the same
optimisation (-O2).  My other comment a while ago was lost. I must retype it.
>From gcc-bugs-return-428405-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 26 18:55:50 2013
Return-Path: <gcc-bugs-return-428405-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 18885 invoked by alias); 26 Aug 2013 18:55:50 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 18829 invoked by uid 48); 26 Aug 2013 18:55:47 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58208] deque<std::string> 32-bit "-O3" bug
Date: Mon, 26 Aug 2013 18:55:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-58208-4-quLQQewep9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58208-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58208-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-08/txt/msg01329.txt.bz2
Content-length: 551

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX208

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is user error.  You need yum install glibc-devel.i686 libstdc++-devel.i686
libgcc.i686 at least to compile 32-bit programs.  By default 32-bit packages
aren't installed.


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
                   ` (3 preceding siblings ...)
  2013-08-26 18:46 ` martin.konopka at stuba dot sk
@ 2013-08-26 18:59 ` martin.konopka at stuba dot sk
  2013-09-07 14:18 ` glisse at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: martin.konopka at stuba dot sk @ 2013-08-26 18:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Martin Konôpka <martin.konopka at stuba dot sk> ---
(I am sorry that I do not understand internals of compilers.)

I first hit the issue in a bigger code having more than 11000 lines. First I
did not understand at all what is going on. I started to isolate the issue by
cutting away more and more lines and finally arriving at the (almost) smallest
possible code demonstrating the issue.

Of course, evaluation of auxvar in the sample code is otherwise useless.
>From gcc-bugs-return-428407-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 26 19:21:19 2013
Return-Path: <gcc-bugs-return-428407-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 32765 invoked by alias); 26 Aug 2013 19:21:19 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 32728 invoked by uid 48); 26 Aug 2013 19:21:15 -0000
From: "schwab@linux-m68k.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug regression/58244] global variable: many THOUSANDS times slower execution
Date: Mon, 26 Aug 2013 19:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: regression
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: schwab@linux-m68k.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58244-4-F3Z61YxMCX@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58244-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-08/txt/msg01331.txt.bz2
Content-length: 147

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX244

--- Comment #7 from Andreas Schwab <schwab@linux-m68k.org> ---
Now try the same code with -O0.


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

* [Bug regression/58244] global variable: many THOUSANDS times slower execution
  2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
                   ` (4 preceding siblings ...)
  2013-08-26 18:59 ` martin.konopka at stuba dot sk
@ 2013-09-07 14:18 ` glisse at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-09-07 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

Marc Glisse <glisse at gcc dot gnu.org> changed:

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

--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> ---
OP said there was no bug.


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

end of thread, other threads:[~2013-09-07 14:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-26 18:05 [Bug regression/58244] New: global variable: many THOUSANDS times slower execution martin.konopka at stuba dot sk
2013-08-26 18:09 ` [Bug regression/58244] " pinskia at gcc dot gnu.org
2013-08-26 18:21 ` martin.konopka at stuba dot sk
2013-08-26 18:36 ` schwab@linux-m68k.org
2013-08-26 18:46 ` martin.konopka at stuba dot sk
2013-08-26 18:59 ` martin.konopka at stuba dot sk
2013-09-07 14:18 ` glisse at gcc dot gnu.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).