caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "\"Mark Adams\"" <mark@proof-technologies.com>
To: <helmut.brandl@gmx.net>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Performance penalty of exception handling
Date: Wed, 16 Sep 2015 20:26:47 +0100	[thread overview]
Message-ID: <1442431607294@names.co.uk> (raw)

One problem is if your function that traps the exception is recursive - it
cannot be made tail recursive if the recursive call is within the 'try' ..
'with', which can cause stack overflow if it recurses thousands of times.

Mark Adams.

on 16/9/15 8:08 PM, Helmut Brandl <helmut.brandl@gmx.net> wrote:

> Hi all,
>
> I use exeption handling quite frequently even in inner loops. A common
> pattern:
>
> let some_function ... =
> ...
> if cannot_compute then raise Not_found else value
>
> try
> let value = some_function ... in
> ...
> with Not_found ->
> handle_exception
>
> I use this pattern even if the direct caller of "some_function" handles
> the exception. In many cases I could design "some_function" in a way
> that it returns an optional value and check the optional value in the
> caller. Is this significantly (at least 10%) faster? If not, I would
> stay with my present design. However I am pressed for performance in the
> inner loops (I am only interested in compilation to native).
>
> Is there any information available on the preformance penalty of
> exception handling? Any hints? Thanks in advance.
>
> Regards
> Helmut
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>

             reply	other threads:[~2015-09-16 19:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 19:26 "Mark Adams" [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-09-16 19:08 Helmut Brandl
2015-09-16 19:15 ` John Whitington
     [not found]   ` <CAKR7PS9iibAcWVMbjahdkVn6KBXUZa0U88KwZEkqc-LzfaBUKg@mail.gmail.com>
2015-09-16 19:51     ` Milan Stanojević
2015-09-16 20:00 ` David Rajchenbach-Teller

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=1442431607294@names.co.uk \
    --to=mark@proof-technologies.com \
    --cc=caml-list@inria.fr \
    --cc=helmut.brandl@gmx.net \
    /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).