public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Fredrik Hederstierna <fredrik.hederstierna@verisure.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Question about GCC benchmarks and uninitialized variables
Date: Tue, 24 Jul 2018 09:04:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.20.13.1807241109400.2267@monopod.intra.ispras.ru> (raw)
In-Reply-To: <DB6PR1001MB102963EA708E5211EEF4F451EF550@DB6PR1001MB1029.EURPRD10.PROD.OUTLOOK.COM>

On Tue, 24 Jul 2018, Fredrik Hederstierna wrote:

> So my question is how to approach this problems when doing benchmarking,
> ofcourse we want the benchmark to mirror as near as 'real life' code as
> possible.  But if code contains real bugs, and issues that could cause
> unpredictable code generation, should such code be banned from benchmarking,
> since results might be misleading?

Well, all benchmarks are going to be imperfect reflections of real-life
workloads in the first place, so their bugs just increase the degree to
which they are misleading.

When a new compiler version starts to treat some undefined piece of code
differently, it can cause a range of effects from code size perturbations
as in your case, to completely invalidating the benchmark as in spec2k6
x264 benchmark's case (where GCC exploited undefined behavior in a loop,
turning it to an infinite loop that eventually segfaulted).

Perhaps even though results on individual benchmarks can vary wildly,
aggregated results across a wide range of non-toy benchmarks may be
indicative of ... something, because they are unlikely to all exhibit
the same "bugs".

> On the other hand, the compiler should
> generate best code for any input?

Engineering effort is limited, so it's probably better to go for generating
good code for inputs that are likely to resemble actively used code (and in
actively used&maintained code, bugs can be reported and fixed) :)
 
> What do you think, should benchmarking code not being allowed to have eg
> warnings like -Wuninitialized and maybe -Wmaybe-uninitialized?  Are there more
> warnings that indicate unpredictable code generations due to bad code, or are
> the root cause that these are 'bugs', and we should not allow real bugs at all
> in benchmarking code?

A blanket ban on warnings won't work, they have false positives (especially the
-Wmaybe- one), and there exist code that validly uses uninitialized data. I
don't have such a striking example for scalar variables, but for uninitialized
arrays there's this sparse set algorithm (which GCC itself also uses):
https://research.swtch.com/sparse

I think good benchmarks sets should be able to evolve to account for newly
discovered bugs, rather then remain frozen (which sounds like a reason to
become obsolete sooner rather than later).

Alexander

  reply	other threads:[~2018-07-24  8:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24  8:48 Fredrik Hederstierna
2018-07-24  9:04 ` Alexander Monakov [this message]
2018-07-24 12:17 ` David Brown
2019-05-30  9:13 ` Question about GCC not warning for some noncompliant SEI CERT C code examples Fredrik Hederstierna
2019-05-30 14:28   ` Martin Sebor
2019-05-30 14:48     ` Jeff Law
2019-06-01 23:35   ` ARM peephole2 from 2003 never merged, still valid Fredrik Hederstierna
2019-06-01 23:41     ` Fredrik Hederstierna
2019-06-02 12:28       ` Segher Boessenkool
2019-06-05 23:03         ` Jeff Law
2019-06-05 23:46           ` Segher Boessenkool
2019-06-06  9:13             ` Richard Earnshaw (lists)
2019-06-06 14:02               ` Segher Boessenkool
2019-06-06 14:55                 ` Fredrik Hederstierna
2019-06-06 16:06                   ` Richard Earnshaw (lists)
2019-06-06 16:49                     ` Segher Boessenkool
2019-07-08  6:41                       ` Fredrik Hederstierna
2019-07-09 19:13                         ` Jeff Law
2019-06-14 20:30                     ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.20.13.1807241109400.2267@monopod.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=fredrik.hederstierna@verisure.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).