caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Ocaml efficiency
@ 2003-02-17 18:03 Vincent Barichard
  2003-02-18 21:25 ` Hans Ole Rafaelsen
  2003-02-18 21:32 ` Matt Gushee
  0 siblings, 2 replies; 12+ messages in thread
From: Vincent Barichard @ 2003-02-17 18:03 UTC (permalink / raw)
  To: CAML-LIST

Hi,

I've made a caml algorithm for solving some combinatorial problems.
I've made a little user interface with camltk in order to launch many
times the solving procedure.

I ran it, and I clicked on the start button one time, the computing
time was about 30s. When I clicked a second time, the computing time
exceeded 60s !!

The programm doesn't store in any data structure the results of the run,
and all the variables values remain the same as before the run.
The outputs of the two runs are identical, just the running time is
different.

I guessed that it was a problem about memory management, garbage
collector, so I tried Gc.full_major and Gc.compact, but it didn't work.

Is anyone has any ideas or suggestions to help me ?


Thanks,

Vincent



Vincent Barichard
Métaheuristiques et Optimisation Combinatoire
Faculté des Sciences d'Angers
Tel : 02 41 73 52 06
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2003-02-17 18:03 [Caml-list] Ocaml efficiency Vincent Barichard
@ 2003-02-18 21:25 ` Hans Ole Rafaelsen
  2003-02-18 21:32 ` Matt Gushee
  1 sibling, 0 replies; 12+ messages in thread
From: Hans Ole Rafaelsen @ 2003-02-18 21:25 UTC (permalink / raw)
  To: Vincent Barichard; +Cc: CAML-LIST

Hello,

are you using some data-structures which you hold references to?  I
had a similar problem some time back.  Used a list, which I kept a
"global" reference to, I order to hold some of my data-structures.
Forgot to clear this reference between each run, and thus the list
kept growing between each run, thus making operations on it taking
longer and longer.

Just a guess.  If the problem is related to the GC and other memory
management issues, then I really don't know.

Kindest regards,

Hans Ole Rafaelsen


Vincent Barichard <barichar@info.univ-angers.fr> writes:

> Hi,
> 
> I've made a caml algorithm for solving some combinatorial problems.
> I've made a little user interface with camltk in order to launch many
> times the solving procedure.
> 
> I ran it, and I clicked on the start button one time, the computing
> time was about 30s. When I clicked a second time, the computing time
> exceeded 60s !!
> 
> The programm doesn't store in any data structure the results of the run,
> and all the variables values remain the same as before the run.
> The outputs of the two runs are identical, just the running time is
> different.
> 
> I guessed that it was a problem about memory management, garbage
> collector, so I tried Gc.full_major and Gc.compact, but it didn't work.
> 
> Is anyone has any ideas or suggestions to help me ?
> 
> 
> Thanks,
> 
> Vincent
> 
> 
> 
> Vincent Barichard
> Métaheuristiques et Optimisation Combinatoire
> Faculté des Sciences d'Angers
> Tel : 02 41 73 52 06
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2003-02-17 18:03 [Caml-list] Ocaml efficiency Vincent Barichard
  2003-02-18 21:25 ` Hans Ole Rafaelsen
@ 2003-02-18 21:32 ` Matt Gushee
  2003-02-19  0:57   ` Matt Gushee
  1 sibling, 1 reply; 12+ messages in thread
From: Matt Gushee @ 2003-02-18 21:32 UTC (permalink / raw)
  To: caml-list

On Mon, Feb 17, 2003 at 07:03:12PM +0100, Vincent Barichard wrote:
> 
> I've made a caml algorithm for solving some combinatorial problems.
> I've made a little user interface with camltk in order to launch many
> times the solving procedure.
> 
> I ran it, and I clicked on the start button one time, the computing
> time was about 30s. When I clicked a second time, the computing time
> exceeded 60s !!

Could be a Tk problem. I haven't done much work with Caml/Tk, but have a
good deal of experience with Tk in other languages, so I might be able
to help. Could you post your GUI code ... or perhaps send it directly to
me if you think it's too much for the list?

By the way, what platform are you running this on?

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2003-02-18 21:32 ` Matt Gushee
@ 2003-02-19  0:57   ` Matt Gushee
  0 siblings, 0 replies; 12+ messages in thread
From: Matt Gushee @ 2003-02-19  0:57 UTC (permalink / raw)
  To: caml-list

On Tue, Feb 18, 2003 at 02:32:58PM -0700, Matt Gushee wrote:
> On Mon, Feb 17, 2003 at 07:03:12PM +0100, Vincent Barichard wrote:
> > 
> > I've made a caml algorithm for solving some combinatorial problems.
> > I've made a little user interface with camltk in order to launch many
> > times the solving procedure.
> > 
> > I ran it, and I clicked on the start button one time, the computing
> > time was about 30s. When I clicked a second time, the computing time
> > exceeded 60s !!
> 
> Could be a Tk problem.

This has probably occurred to you already, but you might want to compile
a command-line version of your program and see if it is still slow.

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-24 12:05 ` Xavier Leroy
  2002-04-24 16:25   ` Jérôme Marant
@ 2002-04-25 16:17   ` Vitaly Lugovsky
  1 sibling, 0 replies; 12+ messages in thread
From: Vitaly Lugovsky @ 2002-04-25 16:17 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list

On Wed, 24 Apr 2002, Xavier Leroy wrote:

> In both cases, OCaml will not only give you lower performance than
> say C, Fortran or assembly, but the OCaml code will not be
> cleaner nor easier to write than the C or Fortran code.

 Btw., many of the numerical algorithms can be very well explained
in Caml when Fortran code is not readable at all.

 So, it's good for number crunching even when its efficiency
is much more poor then Fortran or C.


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-24 12:05 ` Xavier Leroy
@ 2002-04-24 16:25   ` Jérôme Marant
  2002-04-25 16:17   ` Vitaly Lugovsky
  1 sibling, 0 replies; 12+ messages in thread
From: Jérôme Marant @ 2002-04-24 16:25 UTC (permalink / raw)
  To: caml-list

Xavier Leroy <xavier.leroy@inria.fr> writes:


> One example is software components that take a low-level view of the
> memory (as an untyped collection of bytes or words accessed via
> addresses): memory managers, garbage collectors, device drivers, and
> to some extent virtual machine interpreters.

...

> Caml/C conversions on other data types can be more expensive, though.
> Still, as long as the C function does some real work (e.g. 1000 cycles
> of computation), the overhead of calling it from Caml should be
> negligible.

  Many thanks for all those accurate explainations.

  Cheers,

-- 
Jérôme Marant

http://marant.org
              
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-20 10:03 Jérôme Marant
  2002-04-20 14:51 ` Vitaly Lugovsky
@ 2002-04-24 12:05 ` Xavier Leroy
  2002-04-24 16:25   ` Jérôme Marant
  2002-04-25 16:17   ` Vitaly Lugovsky
  1 sibling, 2 replies; 12+ messages in thread
From: Xavier Leroy @ 2002-04-24 12:05 UTC (permalink / raw)
  To: Jérôme Marant; +Cc: caml-list

>   Some people are sometimes writing or thinking about writing
>   applications in OCaml without knowing it OCaml is suitable
>   for the kind of applications they're writing.
> 
>   So my question is for what kind of applications isn't OCaml
>   suitable for and better written in a lower lever language?

One example is software components that take a low-level view of the
memory (as an untyped collection of bytes or words accessed via
addresses): memory managers, garbage collectors, device drivers, and
to some extent virtual machine interpreters.

Another example is heavy-duty number crunching, either on floats
(simple, brute-force numerical methods on dense matrixes; signal
processing) or integers (cryptography, compression, signal processing).

In both cases, OCaml will not only give you lower performance than
say C, Fortran or assembly, but the OCaml code will not be
cleaner nor easier to write than the C or Fortran code.

Caml becomes interesting again as soon as your application manipulates
higher-level data structures, or performs significant amounts of
dynamic allocation, though.

>   What is the real cost (in CPU) of interfaces to C libraries
>   since some processing have to be performed in order to convert
>   lower level types to Caml types?

You probably need to do your own measurements here, but the cost can
be quite low.  For instance, consider a C function that is the
identity on Caml integers, i.e. it takes a Caml integer, converts it
to a native integer, then back to a Caml integer, and returns this.
One call from OCaml to this function takes approximately 16 cycles
on a Pentium III and 50 cycles on an Alpha 21164.  (The Alpha suffers
from a more expensive Caml/C context switch and a less efficient
branch prediction engine.)

Caml/C conversions on other data types can be more expensive, though.
Still, as long as the C function does some real work (e.g. 1000 cycles
of computation), the overhead of calling it from Caml should be
negligible.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-22 19:48     ` Warp
@ 2002-04-23 17:29       ` Jérôme Marant
  0 siblings, 0 replies; 12+ messages in thread
From: Jérôme Marant @ 2002-04-23 17:29 UTC (permalink / raw)
  To: caml-list

"Warp" <warplayer@free.fr> writes:
> All I can say for sure - to my mind - is that OCaml worth it.

No doubt ;-)

-- 
Jérôme Marant

http://marant.org
              
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-20 15:38   ` Jérôme Marant
@ 2002-04-22 19:48     ` Warp
  2002-04-23 17:29       ` Jérôme Marant
  0 siblings, 1 reply; 12+ messages in thread
From: Warp @ 2002-04-22 19:48 UTC (permalink / raw)
  To: caml-list, Jérôme Marant

> >>   What is the real cost (in CPU) of interfaces to C libraries
> >>   since some processing have to be performed in order to convert
> >>   lower level types to Caml types?
> >
> >  I think, that there is no formal answer to your question.
> > Use profiler to find out the bottleneck...
>
>   Sure. But maybe experienced coders have good point of view
>   about this.
>

Although that kind of question cannot be really answered - because it
depends of your needs , the usage you're making , your knowledge of the
compiler , etc... - all I can say is that OCaml is fast, fast enough to be
used in many kind of applications, even using bytecode compilation. If you
want some benchwark , you can watch the Doug's Bagley's ones at
http://www.bagley.org/~doug/shootout/

All I can say for sure - to my mind - is that OCaml worth it.

Nicolas Cannasse
www.motion-twin.com

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-20 14:51 ` Vitaly Lugovsky
@ 2002-04-20 15:38   ` Jérôme Marant
  2002-04-22 19:48     ` Warp
  0 siblings, 1 reply; 12+ messages in thread
From: Jérôme Marant @ 2002-04-20 15:38 UTC (permalink / raw)
  To: caml-list

Vitaly Lugovsky <vsl@ontil.ihep.su> writes:

>>   What is the real cost (in CPU) of interfaces to C libraries
>>   since some processing have to be performed in order to convert
>>   lower level types to Caml types?
>
>  I think, that there is no formal answer to your question.
> Use profiler to find out the bottleneck...

  Sure. But maybe experienced coders have good point of view
  about this.

-- 
Jérôme Marant

http://marant.org
              
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Ocaml efficiency
  2002-04-20 10:03 Jérôme Marant
@ 2002-04-20 14:51 ` Vitaly Lugovsky
  2002-04-20 15:38   ` Jérôme Marant
  2002-04-24 12:05 ` Xavier Leroy
  1 sibling, 1 reply; 12+ messages in thread
From: Vitaly Lugovsky @ 2002-04-20 14:51 UTC (permalink / raw)
  To: Jérôme Marant; +Cc: caml-list

On Sat, 20 Apr 2002, [iso-8859-1] JИrТme Marant wrote:

> 
> Hi,
> 
>   Some people are sometimes writing or thinking about writing
>   applications in OCaml without knowing it OCaml is suitable
>   for the kind of applications they're writing.
> 
>   So my question is for what kind of applications isn't OCaml
>   suitable for and better written in a lower lever language?
> 
>   What is the real cost (in CPU) of interfaces to C libraries
>   since some processing have to be performed in order to convert
>   lower level types to Caml types?

 I think, that there is no formal answer to your question.
Use profiler to find out the bottleneck...


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Ocaml efficiency
@ 2002-04-20 10:03 Jérôme Marant
  2002-04-20 14:51 ` Vitaly Lugovsky
  2002-04-24 12:05 ` Xavier Leroy
  0 siblings, 2 replies; 12+ messages in thread
From: Jérôme Marant @ 2002-04-20 10:03 UTC (permalink / raw)
  To: caml-list


Hi,

  Some people are sometimes writing or thinking about writing
  applications in OCaml without knowing it OCaml is suitable
  for the kind of applications they're writing.

  So my question is for what kind of applications isn't OCaml
  suitable for and better written in a lower lever language?

  What is the real cost (in CPU) of interfaces to C libraries
  since some processing have to be performed in order to convert
  lower level types to Caml types?

  Thanks.

  Regards,  

-- 
Jérôme Marant

http://marant.org
              
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2003-02-19  0:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-17 18:03 [Caml-list] Ocaml efficiency Vincent Barichard
2003-02-18 21:25 ` Hans Ole Rafaelsen
2003-02-18 21:32 ` Matt Gushee
2003-02-19  0:57   ` Matt Gushee
  -- strict thread matches above, loose matches on Subject: below --
2002-04-20 10:03 Jérôme Marant
2002-04-20 14:51 ` Vitaly Lugovsky
2002-04-20 15:38   ` Jérôme Marant
2002-04-22 19:48     ` Warp
2002-04-23 17:29       ` Jérôme Marant
2002-04-24 12:05 ` Xavier Leroy
2002-04-24 16:25   ` Jérôme Marant
2002-04-25 16:17   ` Vitaly Lugovsky

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