caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Teller <d.o.teller@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Would it be possible to add automatic, region-based memory management to OCaml?
Date: Sun, 15 Apr 2018 18:16:10 +0200	[thread overview]
Message-ID: <587a5888-629b-1257-2035-4fefc0308ab5@gmail.com> (raw)
In-Reply-To: <6618a201557cf5ede5aaf15eb0ed21d8@starynkevitch.net>

I seem to remember that the relative performance of GC vs. manual memory
allocation depends a lot of how much additional memory the allocator can
use in addition to the memory actually allocated to the mutator (i.e.
the program). From the top of my head, even with a pretty good GC, you
need to be at ~100% additional memory for the allocator before the
performance of the GC breaks even with good manual allocation.

Now, I don't remember where this number comes from, so I could be wrong.

In addition, region-based resource management can have a number of other
benefits, such as predictable destructors, as in Rust.

There is a recent paper on extending OCalm with, basically, the Rust
ownership model by Jonathan Goodwin:
http://jondgoodwin.com/pling/gmm.pdf . In this paper, you need to
explicitly differentiate between owned data and gc-ed data, as there are
differences in both typing (owned data has affine types) and semantics
(owned data has destructors, rather than finalizers).

Cheers,
 David

On 09/04/2018 14:26, Basile Starynkevitch wrote:
> This is naive. GC is not "lost time", it is acceptable run-time overhead.
> 
> Imagine you rewrite your code in e.g. Rust or C++. Then you still need
> to allocate (and deallocate) heap memory. And that cost CPU time and
> memory overhead.
> 
> So, even if by magic you replace the GC by some region-based memory
> allocation, you won't win in practice 20%
> 
> To say it otherwise, even C malloc or C++ ::operator new have some
> measurable overhead; in some programs it is more than 20%.
> 
> In practice, Ocaml's GC is very well written and is one of the most
> competitive ones. And the GC is intimately tied to the code generator,
> so changing the GC would require significant compiler changes.
> 
> There is no silver bullet. https://en.wikipedia.org/wiki/No_Silver_Bullet
> 
> A good tutorial on GC is http://gchandbook.org/
> 
> Cheers.
> 
> 

-- 
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:[~2018-04-15 16:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09  5:20 ligand
2018-04-09 12:26 ` Basile Starynkevitch
2018-04-15 16:16   ` David Teller [this message]
2018-04-16 15:31     ` Bruno Blanchet
2018-04-17 10:10     ` [Caml-list] Would it be possible to add automatic, region-based Oleg

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=587a5888-629b-1257-2035-4fefc0308ab5@gmail.com \
    --to=d.o.teller@gmail.com \
    --cc=caml-list@inria.fr \
    /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).