comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Resizing Charles Map
Date: Wed, 29 Sep 2004 13:13:26 GMT
Date: 2004-09-29T13:13:26+00:00	[thread overview]
Message-ID: <uoejprtkn.fsf@earthlink.net> (raw)
In-Reply-To: 415A9A01.9050909@mailinator.com

"Alex R. Mosteo" <devnull@mailinator.com> writes:

> I'm using a Charles Map (Hashed strings) to hold a monotonic
> increasing collection of objects. It will contain thousands of them,
> and while the upper limit is unknown, I think that it rarely will
> reach, for example, a million. Is there something that makes not
> recommendable to issue a Resize (Map, Natural'Last) at start?

That will preallocate the hash table array to a length of >=
Natural'Last.  That's very big, so there's a good chance the allocation
will fail.

If you think the upper limit is around 1 million, then you'd be better
off specifying that as the resize value.

Better yet, if your map can contain thousands of items, then just use a
resize value of 1000 or 10_000 or 50_000 or whatever.  And then let the
map expand automatically in the rare case of more items than that.

Realize that expansion is automatic, so you don't need to manually
resize unless you're trying to optimize away expansion (which is
admittedly expensive, if the number of items is large).  On the other
hand, if you allocate a very large hash table, then that requires a
large chunk of contiguous virtual memory addresses.  So you have to find
the right balance between too many rehashing events, and too much
memory.

I recommend you join the charles.tigris.org mailing lists, and post
questions like this there.



      reply	other threads:[~2004-09-29 13:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-29 11:18 Resizing Charles Map Alex R. Mosteo
2004-09-29 13:13 ` Matthew Heaney [this message]
replies disabled

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