comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: sub-optimal code for packed boolean arrays -- bug or inherent limitation
Date: Sun, 08 Jul 2007 18:53:11 -0400
Date: 2007-07-08T18:53:11-04:00	[thread overview]
Message-ID: <wccodim33u0.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: PGwii.192991$_c5.68933@attbi_s22

"Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org> writes:

> You should also be aware that you're sending the compiler conflicting
> messages. Packing the array indicates that you want the compiler to
> minimize storage, even at the expense of speed,...

Well, sort of.  Pack means to minimize storage even at the (possible)
expense of speed of accessing the components.  Speed overall can be
improved by packing.  For example, speed of copying and comparing the
whole packed object, and passing it around as parameters, will typically
be improved by packing.

And of course using less memory will typically improve cache and paging
performance.

So on a desktop computer with "plenty" of memory, packing is mainly used
to improve speed -- there's no "time/space" tradeoff.  A small embedded
system might have such tradeoffs.

>... while "pragma Optimize
> (Time);" indicates that you want to minimize time, even at the expense
> of storage. Obtaining speed often requires wasting storage; the fastest
                              ^^^^^

I'd say, "sometimes", nor "often".  Usually, wasting storage means
wasting time.

> implementation might be to not pack the array. I don't know how many of
> these you have, but with the large memories on modern machines, you
> might be better off with the additional 56 bytes per array. Again, you
> won't know for sure until you have a working version you can measure.

Measurement is a Good Thing.

- Bob



  parent reply	other threads:[~2007-07-08 22:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 19:34 sub-optimal code for packed boolean arrays -- bug or inherent limitation Alinabi
2007-07-02 20:08 ` Ludovic Brenta
2007-07-03  1:01 ` Jeffrey R. Carter
2007-07-03  7:22   ` Harald Korneliussen
2007-07-03  8:37     ` Georg Bauhaus
2007-07-03  7:59 ` gautier_niouzes
2007-07-03  9:25 ` Stefan Lucks
2007-07-03 12:40   ` Stefan Lucks
2007-07-03 15:42 ` Adam Beneschan
2007-07-03 18:04 ` Alinabi
2007-07-03 18:09   ` Alinabi
2007-07-03 18:17     ` Alinabi
2007-07-10  2:06       ` Randy Brukardt
2007-07-03 18:36   ` Jeffrey R. Carter
2007-07-03 19:42     ` Alinabi
2007-07-04  1:12       ` Jeffrey R. Carter
2007-07-04 10:15         ` Jeffrey Creem
2007-07-04 18:28           ` Jeffrey R. Carter
2007-07-04  3:22       ` Steve
2007-07-04  6:31         ` Harald Korneliussen
2007-07-08 22:53     ` Robert A Duff [this message]
2007-07-09  6:09       ` tmoran
2007-07-04  9:00   ` Jean-Pierre Rosen
2007-07-04 18:27     ` tmoran
2007-07-04 19:16       ` Pascal Obry
2007-07-05  1:45         ` tmoran
2007-07-05  4:53       ` Jeffrey R. Carter
2007-07-04 18:51     ` tmoran
2007-07-08 22:58 ` Robert A Duff
replies disabled

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