caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Tom Ridge <tom.j.ridge+list@googlemail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Question about garbage collection and impact on performance
Date: Wed, 4 Dec 2013 14:48:49 +0100	[thread overview]
Message-ID: <CAPFanBHmVQdWC68H5o43gxwkAYrf6LwTPB+ddG=sj=ojKMh9Gg@mail.gmail.com> (raw)
In-Reply-To: <CABooLwP7eSJ5Zc=3uSwCqU4a8Yy6a8bSm_74fQEhN=ceEzpdVw@mail.gmail.com>

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

This was the topic of the following discussion a few years ago:

http://cstheory.stackexchange.com/questions/2720/can-the-cost-of-gc-be-neglected-when-analyzing-the-running-time-of-worst-case-da

My personal impression is that the question is not that well-posed:
- if you assume infinite memory, you don't actually need a GC (and for any
input you can tweak the GC setting to make sure no collection happens)
- if you assume finite memory, the notion of asymptotic behaviour breaks
down unless you can prove your algorithm has a finite peak memory
consumption that is below that bound
- this is independent of whether or not your language using a GC; if your
algorithm constantly allocates heap memory, you will run into compaction
issues even with malloc/free that may degrade theoretical performances

Neelk answer in the link I gave above is that if you can tune your GC to
make sure collections happen infrequently enough, you can make collection
amortized constant-time. But that means you have to accept some memory
wasted (the runtime using significantly more memory than the size of the
actually live data), possibly proportional to the running time of your
program.


On Wed, Dec 4, 2013 at 1:20 PM, Tom Ridge
<tom.j.ridge+list@googlemail.com>wrote:

> Dear caml-list,
>
> I have an OCaml program which I expect to run in time O((n^3) *
> (ln(n))) say. My expectations are based (unrealistically) on ignoring
> garbage collection completely. As inputs get large, the program
> performs worse than I expect.
>
> My question is: is it possible for OCaml's garbage collection to alter
> the time complexity of my program?
>
> If the answer is "yes", then are there any expectations I might have
> about how bad this alteration might be? For example, (without thinking
> about it too hard) it seems unreasonable for GC to turn a polytime
> program into an exponential time program, but is this actually true
> for OCaml's garbage collector?
>
> I have read some material on OCaml's GC, but I did not form any
> intuitions yet about the answers to these questions.
>
> Thanks in advance
>
> Tom
>
> --
> 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
>

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

  parent reply	other threads:[~2013-12-04 13:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 12:20 Tom Ridge
2013-12-04 12:43 ` Malcolm Matalka
2013-12-04 13:48 ` Gabriel Scherer [this message]
2013-12-19 22:47   ` Richard W.M. Jones
2013-12-22  2:25     ` Jon Harrop
2013-12-22  3:04       ` David Sheets
2013-12-22 12:43         ` Jeff Schultz
2013-12-22 10:41       ` Richard W.M. Jones
2013-12-04 18:09 ` Jon Harrop
2013-12-05  1:09 ` Jacques Garrigue
2013-12-05 10:08   ` Tom Ridge
2013-12-05 10:37     ` Malcolm Matalka
2013-12-05 10:48     ` Michael Hicks
2013-12-05 11:21       ` Tom Ridge
2013-12-05 21:09       ` Jon Harrop

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='CAPFanBHmVQdWC68H5o43gxwkAYrf6LwTPB+ddG=sj=ojKMh9Gg@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=tom.j.ridge+list@googlemail.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).