caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Performance-question
@ 2008-02-05 13:33 Oliver Bandel
  2008-02-05 13:51 ` [Caml-list] Performance-question Jon Harrop
  2008-02-07 16:13 ` Damien Doligez
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Bandel @ 2008-02-05 13:33 UTC (permalink / raw)
  To: caml-list

Hello,

I have a concrete (non philosophical) question
on the Performance of one of my scripts.

The general behaviour: it reads data fast first,
then slows down a lot (possibly after about 1/3 of the
data; it seems to completely have stopped then), then later speeds up
again.
Ths script needs nearly complete CPU-time and the system load goes up.


Now here some data:

=====================================================

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 44.45    163.08   163.08    26627     0.01     0.01  mark_slice
 22.31    244.92    81.84    38447     0.00     0.00  sweep_slice
 14.40    297.74    52.82      131     0.40     0.61  caml_compact_heap
  3.49    310.54    12.80 372416920     0.00     0.00  invert_pointer_at
  3.40    323.02    12.48 560604006     0.00     0.00  compact_allocate
  3.12    334.45    11.43  9725772     0.00     0.00  caml_fl_allocate
  0.92    337.81     3.36    25607     0.00     0.00  caml_add_to_heap

----------------------------------------------------------------------

minor_words: 218494242
promoted_words: 38303811
major_words: 3546606791
minor_collections: 64811
major_collections: 720
heap_words: 1044480
heap_chunks: 17
top_heap_words: 47322112
live_words: 666290
live_blocks: 103159
free_words: 378186
free_blocks: 360
largest_free: 60034
fragments: 4
compactions: 131

=====================================================


For me it looks like a lot of GC-actions, but I'm not sure in that
point. What do you think is slowing down here, and how to avoid
this behaviour?

Ciao,
   Oliver


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Performance-question
  2008-02-05 13:33 Performance-question Oliver Bandel
@ 2008-02-05 13:51 ` Jon Harrop
  2008-02-05 16:18   ` Oliver Bandel
  2008-02-07 16:13 ` Damien Doligez
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Harrop @ 2008-02-05 13:51 UTC (permalink / raw)
  To: caml-list

On Tuesday 05 February 2008 13:33:53 Oliver Bandel wrote:
> For me it looks like a lot of GC-actions, but I'm not sure in that
> point. What do you think is slowing down here, and how to avoid
> this behaviour?

You need to run a memory profiler on your code to work out where it is 
allocating all of that data.

I've had the same problem and wrote my own memory profiler. I may 
commercialize it in the future...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Performance-question
  2008-02-05 13:51 ` [Caml-list] Performance-question Jon Harrop
@ 2008-02-05 16:18   ` Oliver Bandel
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Bandel @ 2008-02-05 16:18 UTC (permalink / raw)
  To: caml-list

Zitat von Jon Harrop <jon@ffconsultancy.com>:

> On Tuesday 05 February 2008 13:33:53 Oliver Bandel wrote:
> > For me it looks like a lot of GC-actions, but I'm not sure in that
> > point. What do you think is slowing down here, and how to avoid
> > this behaviour?
>
> You need to run a memory profiler on your code to work out where it
> is
> allocating all of that data.
[...]

Oh, I hope I can solve that problem otherwise.

I have some suspicious functions...
...possibly I should now switch to better datastructures/algorithms.

I hope I can solve it this way.

But thanks for your hint.

Ciao,
   Oliver


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Performance-question
  2008-02-05 13:33 Performance-question Oliver Bandel
  2008-02-05 13:51 ` [Caml-list] Performance-question Jon Harrop
@ 2008-02-07 16:13 ` Damien Doligez
  2008-02-07 16:23   ` Jon Harrop
  1 sibling, 1 reply; 5+ messages in thread
From: Damien Doligez @ 2008-02-07 16:13 UTC (permalink / raw)
  To: caml users; +Cc: Oliver Bandel


On 2008-02-05, at 14:33, Oliver Bandel wrote:

> Each sample counts as 0.01 seconds.
>  %   cumulative   self              self     total
> time   seconds   seconds    calls   s/call   s/call  name
> 44.45    163.08   163.08    26627     0.01     0.01  mark_slice
> 22.31    244.92    81.84    38447     0.00     0.00  sweep_slice
> 14.40    297.74    52.82      131     0.40     0.61  caml_compact_heap
>  3.49    310.54    12.80 372416920     0.00     0.00   
> invert_pointer_at
>  3.40    323.02    12.48 560604006     0.00     0.00  compact_allocate
>  3.12    334.45    11.43  9725772     0.00     0.00  caml_fl_allocate
>  0.92    337.81     3.36    25607     0.00     0.00  caml_add_to_heap

That's a lot of time spent in the compactor, indicating that your
program has a memory fragmentation problem.

I would be very interested in getting a copy of your program and data,
as I'm currently experimenting with new allocation policies designed
to reduce fragmentation.  This would make a good benchmark for me.

More generally, I'm looking for (small) programs that exhibit this
kind of behaviour: they call the compactor frequently and their memory
usage grows without bound when the compactor is disabled.

-- Damien


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Performance-question
  2008-02-07 16:13 ` Damien Doligez
@ 2008-02-07 16:23   ` Jon Harrop
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Harrop @ 2008-02-07 16:23 UTC (permalink / raw)
  To: caml-list

On Thursday 07 February 2008 16:13:25 Damien Doligez wrote:
> More generally, I'm looking for (small) programs that exhibit this
> kind of behaviour: they call the compactor frequently and their memory
> usage grows without bound when the compactor is disabled.

The "n"th-nearest neighbor example from OCaml for Scientists is certainly very 
allocation intensive because it makes extensive use of the Set module:

  http://www.ffconsultancy.com/products/ocaml_for_scientists/complete/

but I'm not sure that its memory use will grow unbounded if compaction is 
disabled though.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-07 16:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-05 13:33 Performance-question Oliver Bandel
2008-02-05 13:51 ` [Caml-list] Performance-question Jon Harrop
2008-02-05 16:18   ` Oliver Bandel
2008-02-07 16:13 ` Damien Doligez
2008-02-07 16:23   ` Jon Harrop

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).