comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Finding out minimal allocation unit
Date: Thu, 5 Apr 2007 20:40:50 -0500
Date: 2007-04-05T20:40:50-05:00	[thread overview]
Message-ID: <ev48c5$omp$1@jacob-sparre.dk> (raw)
In-Reply-To: 4ecee347d7sbellon@sbellon.de

"Stefan Bellon" <sbellon@sbellon.de> wrote in message
news:4ecee347d7sbellon@sbellon.de...
> Markus E Leypold wrote:
>
> > And I thought it would exactly be the extra padding the OP was
> > interested in?
>
> Yes, basically I'm interested in the padding which is inserted and
> wasted and which could be used without resulting in a larger allocated
> memory chunk.
>
> So, instead of doing:
>
>    type Cell1;
>
>    type List is access all Cell1;
>
>    type Cell1 is record
>       Next : List;
>       Item : Item_Type;
>    end record;
>
> We would like to do:
>
>    type Cell2 is record
>       Next  : List;
>       Used  : Natural;
>       Items : array (1 .. N) of Item_Type;
>    end record;
>
> Where N is chosen in a way that N is maximized without resulting in the
> whole Cell to require the next larger allocation size.

Right, but that obscures your algorithm and makes it harder to maintain.
It's better to write a storage pool that does the blocking, and does it
behind the scenes. (Of course, if the overhead of "Next" is contributing to
the problem, you might not have any choice.)

But, honestly, I don't see why you're so concerned about getting the
blocking factor exactly right. Just make it big enough so you're always
allocating at least 256 bytes at a time, and relax. Unless you have a huge
number of these structures, the possible waste of a couple hundred bytes per
list item isn't going to make much difference. And if they're expandable
anyway, you're probably going to be filling them up. Remember, the actual OS
memory allocator on Windows allocates in 64K chunks -- I doubt you want to
use *that* size for blocking!

So, in summary, if the insertion/deletion issues are really significant,
then use a custom storage pool, and don't mess with the top-level algorithm.
And if they're not, just allocate decent sized blocks and don't worry too
much about the waste - it's inevitable unless you write your own storage
pool (tuning as you are trying to do will only work on a single compiler
version/target operating system version; any change to either is likely to
change something - everyone is forever fiddling with their heap
implementations to improve something or other).

                                  Randy.





  reply	other threads:[~2007-04-06  1:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-03 12:43 Finding out minimal allocation unit Stefan Bellon
2007-04-03 13:22 ` Georg Bauhaus
2007-04-03 13:28   ` Stefan Bellon
2007-04-03 13:34   ` Martin Krischik
2007-04-03 13:37     ` Stefan Bellon
2007-04-03 15:17       ` Markus E Leypold
2007-04-04 17:16         ` Robert A Duff
2007-04-05  8:55           ` Markus E Leypold
2007-04-05 17:55             ` Stefan Bellon
2007-04-06  1:40               ` Randy Brukardt [this message]
2007-04-06  8:06                 ` Stefan Bellon
2007-04-06 11:06                   ` Markus E Leypold
2007-04-03 23:53     ` Randy Brukardt
2007-04-05  6:12       ` Stefan Bellon
2007-04-05  7:35         ` Martin Krischik
2007-04-05 17:58           ` Stefan Bellon
2007-04-07  9:27             ` Martin Krischik
2007-04-10 21:42             ` Robert A Duff
2007-04-05 13:07         ` Robert A Duff
2007-04-05 18:02           ` Stefan Bellon
2007-04-06  1:31             ` Randy Brukardt
2007-04-06  8:10               ` Stefan Bellon
2007-04-06 17:17                 ` Simon Wright
2007-04-06 12:38         ` Stephen Leake
2007-04-03 14:12   ` Larry Kilgallen
2007-04-03 13:48 ` Robert A Duff
2007-04-03 16:45 ` Dmitry A. Kazakov
replies disabled

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