Tim Bradshaw <tfb@cley.com> wrote:
+---------------
| But I think I'm assuming that the whole increment-and-test part of
| heap (or `general' stack) allocation is incredibly cheap compared to
| the process of actually initializing memory, since it's likely that
| the pointer and bound will be either in registers or 1st-level cache
| at worst, while the memory will generally not be. In fact I'd argue
| -- based on the assumption that everything except memory access is
| basically free on a modern machine -- that stack allocation's win
| should be that it has better cache behaviour.
+---------------
Not necessarily. See Ungar's papers on generational collectors with
a fixed "nursery" or "ephemeral" area of size chosen to fit in the
secondary cache. You get the same reuse of memory "hot" in the cache
as with a stack.
[For those not familiar, the idea is that all fresh allocations are done
in the nursery area, which is a *single* space, not a pair of semi-spaces.
When the nursery area fills up, a minor collection is done which copies
all the live data from the nursery area into the active semi-space of the
next generation, and then the whole nursery area is *reused* for more
new allocations.]
-Rob
-----
Rob Warnock, 31-2-510 rpw3@sgi.com
SGI Network Engineering http://reality.sgi.com/rpw3/
1600 Amphitheatre Pkwy. Phone: 650-933-1673
Mountain View, CA 94043 PP-ASEL-IA