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: Tue, 16 Sep 2014 18:55:28 -0400 Organization: Aioe.org NNTP Server Lines: 50 Message-ID: References: <541855C0.2558D27D@bytecraft.com> <3a80ad9d-4b38-4db4-96c6-e3adcffefacb@googlegroups.com> 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:33397 On Tue, 16 Sep 2014 11:47:20 -0400, wrote: > On Tuesday, September 16, 2014 8:21:35 AM UTC-7, Walter Banks wrote: >> I am working on a code generator for a stack processor. >> Who better to ask about real stack requirements than a forth group. >> >> The question is what is the expected stack requirements for a >> forth implementation? >> >> Is there any benchmark code that test stack usage? >> >> Many Thanks >> >> w.. > > The bewildering variety of possible applications makes a simple > answer difficult. Perhaps the best way would be to write a > simulator, initialize a large stack space with a unique bit > pattern, and feed it the heaviest program you can find. A > post-mortem stack dump should give you your answer. My friend > Garth did that for his embedded 65802 work-bench computer, and > came to the conclusion that 256 bytes was way more than enough > for each of his two forth stacks, but he wasn't doing GUIs or > anything fancy. > I'd like to know what a decent size is for a Forth stack too. I've asked about this in the past. I use 256 bytes for my Forth interpreter which is under development, i.e., I haven't executed any large or serious apps on it. I have run John Hayes core test without stack overflow. Also, I know that 256 bytes is way too small for recursive words in Forth. As mentioned by the person with the "rickman" monicker, you should be able to measure this. You can redefine : (colon) and ; (semicol) in Forth. Usually, this is used for a custom word, like TRACE , which shows which words are being executed as the app is executing. There are past posts in c.l.f. on this, and IIRC articles in Forth Dimensions magazine too. So, you should be able to redefine them and use DEPTH to get the stack length per word. This value can be used to determine the peak stack length and compute the average stack length per executed word. You'd just need a really representative set of apps to test. Someone else will have to propose redifinitions of : and ; for him. I'm not spending the time today. Rod Pemberton