Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Milan Stanojević" <milanst@gmail.com>
To: John Whitington <john@coherentgraphics.co.uk>,
	Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Performance penalty of exception handling
Date: Wed, 16 Sep 2015 15:51:36 -0400	[thread overview]
Message-ID: <CAKR7PS_MY8-Z5EqLPb-3LTWxeysMBxuNNn+zjE1j2FiY=E66HA@mail.gmail.com> (raw)
In-Reply-To: <CAKR7PS9iibAcWVMbjahdkVn6KBXUZa0U88KwZEkqc-LzfaBUKg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 793 bytes --]

(correctly sending to the list)

> > Optional values often require allocation (and, therefore, garbage
collection). Unless your process is so short-lived that the garbage
collector never runs, exceptions are going to be faster. So, if you
benchmark this, make sure your benchmarks run for a while.
> >
> > Someone who knows the compiler better than I will be able to tell you
if (Some x) when immediately pattern-matched across a function call causes
an allocation.
> >
> > Constant exception constructors like Not_found, I believe, require no
allocation in recent versions of OCaml.
> >
>

The cost of an exception is not just its allocation. You also need to setup
the exception handler. Also, backtrace recording is not cheap, so one
should use raise_notrace primitive for cases like this.

[-- Attachment #2: Type: text/html, Size: 924 bytes --]

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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ć [this message]
2015-09-16 20:00 ` David Rajchenbach-Teller
2015-09-16 19:26 "Mark Adams"

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='CAKR7PS_MY8-Z5EqLPb-3LTWxeysMBxuNNn+zjE1j2FiY=E66HA@mail.gmail.com' \
    --to=milanst@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=john@coherentgraphics.co.uk \
    /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