caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <brian.hurt@qlogic.com>
To: "Harrison, John R" <johnh@ichips.intel.com>
Cc: <caml-list@inria.fr>
Subject: RE: [Caml-list] @, List.append, and tail recursion
Date: Fri, 31 Jan 2003 15:04:23 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0301311450330.3577-100000@eagle.ancor.com> (raw)
In-Reply-To: <FD2423AA68A7D511A5A20002A50729E12C119C@orsmsx115.jf.intel.com>

On Fri, 31 Jan 2003, Harrison, John R wrote:

> How about the following policy?
> 
>   Don't place any limit on stack growth
> 
> The stack, like the heap, should be capable of expanding to
> fill all available memory. I don't know much about the OS issues
> involved in stack extension, but some such policy seems preferable
> to building in a hard limit.

We need some way to find infinitely recursive functions.  The hard limit 
is a good idea.  Especially considering some OSs (Linux) do not deal well 
with OOM errors.  Linux freely over commits memory- allowing you to 
"allocate" way more memory than exists.  When you first touch the memory 
is when the memory is really allocated.  And if the memory isn't there to 
be allocated, it segfaults.  In practice, this means that when you run out 
of memory on Linux, random processes start to segfault.  Including 
possibly init.

I agree this is a bad design decision.  It is, however, how Linux works.

In fact, I'd argue that the hard limit is too large.  I'd put the limit 
somewhere between 1024 and 8192 deep.  If you are doing O(n) recursion, 
I'd rather find out about it sooner rather than later- it's a lot more 
likely to be hit in testing that way, and fixed.  Note that I'm thinking 
here of the maximum *number* of levels, not the maximum stack size.

Or settable either in the runtime environment, or by the program itself 
(Sys.set_stack_limit()?).

> 
> Users would then be free to write relatively inefficient and
> stack-hungry recursive functions, 

Actually, recursion seems to be very cheap- the recursive append function 
is signifigantly faster than the reversing append, and almost as fast as 
the set_cdr function.

> and at least the implementation
> would do its best to carry recursions as far as possible. The only
> reason I can see for placing a limit on the stack size is that users
> become aware of trivially looping recursions more quickly. But this
> doesn't seem a particularly strong argument.

I like becoming aware of problems in my code as quickly as possible.  It 
lets me fix them quicker.

Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-01-31 20:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-31 19:58 Harrison, John R
2003-01-31 21:04 ` Brian Hurt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-31 22:27 Harrison, John R
2003-01-31 17:32 Diego Olivier Fernandez Pons
2003-01-24 15:35 Andrew Kennedy
2003-01-30  1:44 ` brogoff
2003-01-30  9:57   ` Christophe Raffalli
2003-01-30 16:03     ` Brian Hurt
2003-01-31 10:33     ` Mattias Waldau
2003-01-24  0:48 Brian Hurt
2003-01-30 18:10 ` Olivier Andrieu
2003-01-30 19:46   ` Brian Hurt
2003-01-30 20:52     ` Olivier Andrieu
2003-01-30 21:57       ` Brian Hurt
2003-01-31  2:16         ` james woodyatt
2003-01-31 17:05           ` Diego Olivier Fernandez Pons
2003-01-31 19:52             ` Brian Hurt
2003-01-31 21:34             ` Issac Trotts
2003-01-31 17:13           ` Brian Hurt
2003-01-31 17:42             ` brogoff
2003-01-31 19:18             ` Russ Ross
2003-01-31 19:32               ` Alexander V. Voinov
2003-02-01  2:30               ` brogoff
2003-01-31 23:12             ` Issac Trotts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.33.0301311450330.3577-100000@eagle.ancor.com \
    --to=brian.hurt@qlogic.com \
    --cc=caml-list@inria.fr \
    --cc=johnh@ichips.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).