comp.lang.ada
 help / color / mirror / Atom feed
From: Bill Findlay <yaldnif.w@blueyonder.co.uk>
Subject: Re: A couple of quick questions
Date: Sat, 29 Dec 2012 16:32:22 +0000
Date: 2012-12-29T16:32:22+00:00	[thread overview]
Message-ID: <CD04CB96.238DC%yaldnif.w@blueyonder.co.uk> (raw)
In-Reply-To: ea507393-d4ff-4451-b1e8-4d055da9b794@googlegroups.com

On 29/12/2012 16:15, in article
ea507393-d4ff-4451-b1e8-4d055da9b794@googlegroups.com, "Shark8"
<onewingedshark@gmail.com> wrote:

> On Saturday, December 29, 2012 4:47:44 AM UTC-6, Florian Weimer wrote:
>> * Dufr:
>> 
>>> Is the efficiency of the compiled code by penalized in any way by
>>> the putative bloat of the language?
>> 
>> [...] Run-time checks (such as overflow checks and array bounds
>> checks) are typically bloat which increases instruction cache pressure
>> and decreases effective execution speed.
> 
> But you're doing Ada a bit of a disservice here: Ada compilers are typically
> smart enough to omit range-checks where the value can be guaranteed as valid,
> such as "FOR Index IN Array'Range Loop [...]", no check is needed because the
> type  of Index guarantees that it is valid.

Indeed.

Should the checking "overhead" be prohibitive in special cases, a selection
of particular checks can be suppressed over well-defined scopes.  However,
the real cost is often surprisingly small.

Here is some actual data, rather than speculation.
 
My KDF9 emulator is about 20KSLOC.  Compiled with all runtime checking
disabled, it runs 1.25% faster than when compiled with default checking.
That is 1.25 PERCENT faster, not 1.25 TIMES. 8-)
  
Interestingly, if I do not suppress absolutely all checks, but enable them
for "non-inner loop" modules, it runs a further 1.25% faster than when
completely unchecked.  More checks, but faster execution!

Another program of mine, an assembler of about 10KSLOC, runs about 1% faster
with default checking than it does with checking completely suppressed!

Such are the vagaries of performance with modern CPUs.  So for some
programs, at least, the overhead due to runtime checking is down at the
measurement noise level.

>> Code for abort deferral is
>> automatically inserted by the compiler and slows down the program,
>> even if no asynchronous transfer of control ever occurs.

Then use:

   pragma Restrictions(No_Abort_Statements);

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;




  reply	other threads:[~2012-12-29 16:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-28 15:02 A couple of quick questions Dufr
2012-12-28 15:43 ` Thomas Løcke
2012-12-28 16:46 ` Georg Bauhaus
2012-12-28 20:28 ` Dufr
2012-12-28 23:27   ` Georg Bauhaus
2012-12-28 23:36     ` Georg Bauhaus
2012-12-29  0:41   ` Yannick Duchêne (Hibou57)
2012-12-29 10:47   ` Florian Weimer
2012-12-29 16:15     ` Shark8
2012-12-29 16:32       ` Bill Findlay [this message]
2012-12-29 17:21       ` Florian Weimer
2012-12-31  8:56 ` Paul Colin Gloster
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox