Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Metrics on stack usage Date: Fri, 19 Sep 2014 19:57:32 -0400 Organization: Aioe.org NNTP Server Lines: 64 Message-ID: References: <541855C0.2558D27D@bytecraft.com> <5419FFEE.27412D2C@bytecraft.com> <7x8ulhzuax.fsf@ruckus.brouhaha.com> <541ab362$0$6923$e4fe514c@dreader36.news.xs4all.nl> <2014Sep19.140810@mips.complang.tuwien.ac.at> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:33448 On Fri, 19 Sep 2014 19:28:15 -0400, Elizabeth D. Rather wrote: > On 9/19/14 12:58 PM, Rod Pemberton wrote: >> On Fri, 19 Sep 2014 08:08:10 -0400, Anton Ertl >> wrote: >>> Celeros writes: >>>> I'm an extreme newbie here, but it sounds to me like stacks don't >>>> need to be very deep in order to do *most* things. >>> >>> Right. 256 stack items seems to be significantly more than enough >>> for the kinds of code I expect is run there. >>> >> >> While I've been using only 256 during development, I expected the >> actual size needed would be much larger. E.g., DJGPP (GCC for DOS) >> allocates 512KB for stack, and 32KB for interrupt stacks. So, maybe, >> the wrong question is being asked ... Instead of asking how deep a >> stack should be, maybe we should be asking if anyone has ever run >> out of stack space in Forth? If so, which Forth, which app, and >> under what conditions? > > We had to program very carefully to manage 32-byte data and return > stacks in a control application on an 8051 with 64 bytes of on-chip > memory some years ago, but we managed (it was a 16-bit implementation). > Stephen mentioned Koopman's book earlier. Koopman has some articles in Forth Dimensions magazine too, including one on the Harris RTX 32P. Koopman seems to have come to the same conclusion as you: "The right answer, then, to how big stacks should be is 16 or 32 elements, no more." This conclusion is from his Figure-Five which is a cost of register spills versus stack size simulation. Of course, it is 1990 data. Earlier in the article: " One of the big unknowns in producing the RTX 32P was how big to make the stacks. Before, I had been limited either by the need to keep chip count low or by standard high-speed memory chip sizes. On the RTX 32P, I guessed at 512 stack elements. I guessed wrong. Simulations of several Forth programs show that many progrmas never used more than four or five stack elements. Of those that used more stack elements, all showed a small variability in stack size across reasonably large periods of time. ..." -Philipp Koopman The quote is from "Design Tradeoffs in Stack Computers," Forth Dimensions, Volume 11 Number 6, March/April 1990. An article only pdf is available from Koopman: http://users.ece.cmu.edu/~koopman/forth/4thdim_11_6.pdf Rod Pemberton