caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Malcolm Matalka <mmatalka@gmail.com>
To: Tom Ridge <tom.j.ridge+list@googlemail.com>
Cc: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>,
	 OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Question about garbage collection and impact on performance
Date: Thu, 05 Dec 2013 10:37:11 +0000	[thread overview]
Message-ID: <87pppbr3c8.fsf@gmail.com> (raw)
In-Reply-To: <CABooLwPTEORE8U4R+n4JSsNyUhEP009VJi=1St0eRJnjUFboKg@mail.gmail.com> (Tom Ridge's message of "Thu, 5 Dec 2013 10:08:27 +0000")

Perhaps posting some experiments would help people help you.  In
particular it would be nice to see:

- The actual timings of what you consider a good run and a bad run

- Those runs with verbose gc turned on

- Amount of memory consumption

- The timings for if you jack up the amount of memory that the runtime
  system is allowed to use on both a good run and a bad run to determine
  the system

In short, the answer to your question seems to be "maybe".  But enough
information has not been provided to suggest if it's responsible for
what you're seeing or just a theoretical possibility.

Tom Ridge <tom.j.ridge+list@googlemail.com> writes:

> On 5 December 2013 01:09, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>> 2013/12/04 21:20, Tom Ridge <tom.j.ridge+list@googlemail.com>:
>>
>>> 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?
>>
>> I would say that, on a program that is already O(n^3), that would be very surprising.
>
> Surprising, but not impossible?
>
>> What kind of measure did you do?
>
> A rather basic measurement of the time the program takes (using /usr/bin/time).
>
>> If your program uses lots of memory, swapping may be a major slowdown,
>> using a GC or not (but a badly tuned GC may cause more swapping).
>
> Having played around with GC settings, I now get the expected
> behaviour. I don't think the previous version was swapping, but I'm
> not sure (and will look into this).
>
> I take Scherer's point that the question is not well-posed, so I am
> thinking about how to phrase the question better.
>
> I am slightly worried that, if the GC were mark and sweep (and OCaml's
> GC is partly mark and sweep, as I understand it) and if the GC is
> invoked sufficiently often, then indeed the performance may change.
> For example, a program that runs for n steps, and allocates a
> fixed-size chunk of memory (that is kept live) at each step, is
> naively O(n). If each step of the program is followed by a mark+sweep
> GC, then the time cost of the GC is roughly O(n^2). So with GC the
> program may perform as O(n^2). Of course, what actually happens is
> that GC does not run after each step, and a real analysis would be
> sensitive to the size of the live set (relative to the memory
> available), the amount of garbage produced etc.
>
> Are there any pointers to analyses (not specific to OCaml) along these lines?
>
>
>
>>
>> Jacques Garrigue

  reply	other threads:[~2013-12-05 10:37 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
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 [this message]
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=87pppbr3c8.fsf@gmail.com \
    --to=mmatalka@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    --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).