D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3696 - SuperStack
Summary: SuperStack
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-11 17:32 UTC by Chad Joan
Modified: 2015-06-09 01:27 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Chad Joan 2010-01-11 17:32:03 UTC
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=79746

Quoted from Andrei:
> This entire discussion gets me thinking - could an alternate stack be a
> good (or even better) solution? Consider a global per-thread
> "superstack" - a growable region that allocates memory in large chunks
> and makes sub-chunks accessible in a strictly LIFO manner. The
> primitives of the superstack are as follows:
> void* SuperStack.allocate(size_t bytes);
> void SuperStack.free(size_t bytes);
> size_t SuperStack.slack();
> The SuperStack's management is a singly-linked list of large blocks. The
> slack function returns how many bytes are left over in the current
> chunk. If you request more than slack bytes, a new chunk is allocated
> etc. A SuperStack can grow indefinitely (and is susceptible to leaks).
> Some convenience functions complete the picture:
> T[] SuperStack.array(T)(size_t objects);
> enum Uninitialized { yeahIKnow }
> T[] SuperStack.array(T)(size_t objects, Uninitialized);
> Freeing chunks should not be done immediately in order to avoid
> pathological behavior when a function repeatedly allocates and frees a
> chunk just to fulfill some small data needs.
> With the SuperStack in place, code could look like this:
> void foo(in size_t s)
> {
>      auto a = SuperStack.array(int)(s, Uninitialized.yeahIKnow);
>      scope(exit) SuperStack.free(s);
>      ... play with a ...
> }
> Is there interest for such a thing?
> Andrei
Comment 1 Alex Rønne Petersen 2012-10-09 18:42:22 UTC
Let's open an issue if there is actual interest or someone provides a patch.
Comment 2 Chad Joan 2012-10-09 19:08:23 UTC
(In reply to comment #1)
> Let's open an issue if there is actual interest or someone provides a patch.

I still want this.  I don't know how to implement it efficiently and I haven't used it because it doesn't exist :/
Comment 3 Alex Rønne Petersen 2012-10-09 19:19:20 UTC
Well, at some point, we have to close enhancement requests because nobody's worked on them. The 'WONTFIX' resolution was not to say it can't/shouldn't be done, but just a reflection of the fact that any core developers are unlikely to work on this (at least right now).

By all means, reopen if someone starts work on this. :)

(Besides, this should probably be filed against Phobos, not DRuntime.)
Comment 4 Chad Joan 2012-10-09 19:21:01 UTC
(In reply to comment #3)
> Well, at some point, we have to close enhancement requests because nobody's
> worked on them. The 'WONTFIX' resolution was not to say it can't/shouldn't be
> done, but just a reflection of the fact that any core developers are unlikely
> to work on this (at least right now).
> 
> By all means, reopen if someone starts work on this. :)
> 
> (Besides, this should probably be filed against Phobos, not DRuntime.)

Makes sense.  Thank you.
Comment 5 Dmitry Olshansky 2012-10-10 00:31:39 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Well, at some point, we have to close enhancement requests because nobody's
> > worked on them. The 'WONTFIX' resolution was not to say it can't/shouldn't be
> > done, but just a reflection of the fact that any core developers are unlikely
> > to work on this (at least right now).
> > 
> > By all means, reopen if someone starts work on this. :)
> > 
> > (Besides, this should probably be filed against Phobos, not DRuntime.)
> 
> Makes sense.  Thank you.

It's here. Name's RegionAllocator.
Was proposed for allocator proposal about a year ago. Currently the most recent version is part of dstats:
http://dsimcha.github.com/dstats/docs/alloc.html
https://github.com/dsimcha/dstats/blob/master/alloc.d