Re: [Caml-list] More re GC hanging

2010-08-15 Thread Basile Starynkevitch
On Sun, 2010-08-15 at 15:57 +1000, Paul Steckler wrote:
 I haven't yet come up with a solution to the GC hanging problem I
 mentioned the other day.
 
 But here's something that looks funny. [..]

 After turning on the Gc verbose option, I see:

[...]
  !Sweeping 9223372036854775807 words
  Starting new major GC cycle
  Marking 9223372036854775807 words
  Subphase = 10
  Sweeping 9223372036854775807 words
 
 Those are some big mark and sweep numbers at the end!

I guess this is related to the fact that recent Linux kernel have turned
on the randomize virtual address space feature -designed to improve
system security. You could disable it by 
  echo 0  /proc/sys/kernel/randomize_va_space
but first learn more about it.

I believe recent Ocaml versions (did you try 3.12?) have GC improvements
for that.

Cheers.
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basileatstarynkevitchdotnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] More re GC hanging

2010-08-15 Thread Paul Steckler
On Sun, Aug 15, 2010 at 5:03 PM, Basile Starynkevitch
bas...@starynkevitch.net wrote:
 I guess this is related to the fact that recent Linux kernel have turned
 on the randomize virtual address space feature -designed to improve
 system security. You could disable it by
  echo 0  /proc/sys/kernel/randomize_va_space
 but first learn more about it.

Can't do that, even as root, permission denied.

 I believe recent Ocaml versions (did you try 3.12?) have GC improvements
 for that.

I installed 3.12, same hanging issue.

-- Paul

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] More re GC hanging

2010-08-15 Thread Paul Steckler
 I guess this is related to the fact that recent Linux kernel have turned
 on the randomize virtual address space feature -designed to improve
 system security. You could disable it by
  echo 0  /proc/sys/kernel/randomize_va_space
 but first learn more about it.

For some reason, I was able to edit that file using emacs, even when
echo wouldn't work.

But the hanging problem persists.

-- Paul

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] More re GC hanging

2010-08-15 Thread Basile Starynkevitch
On Sun, 2010-08-15 at 18:40 +1000, Paul Steckler wrote:
  I guess this is related to the fact that recent Linux kernel have turned
  on the randomize virtual address space feature -designed to improve
  system security. You could disable it by
   echo 0  /proc/sys/kernel/randomize_va_space
  but first learn more about it.
 
 For some reason, I was able to edit that file using emacs, even when
 echo wouldn't work.

To check that it did work as expected (which I doubt) do
   cat /proc/sys/kernel/randomize_va_space
it should give 0
 
 But the hanging problem persists.

Are you sure that you don't have badly coded C routines that you call
from your Ocaml code (don't forget correct use of CAMLparam  CAMLlocal,
read again carefully
http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html and perhaps
other material about precise garbage collectors). 

Are you sure you don't have a memory leak in your Ocaml code? This could
happen when a reference value refers to a big value you don't need
anymore.

Cheers. 
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basileatstarynkevitchdotnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Fwd: [Caml-list] More re GC hanging

2010-08-15 Thread Paul Steckler
On Sun, Aug 15, 2010 at 7:16 PM, Basile Starynkevitch
bas...@starynkevitch.net wrote:
 To check that it did work as expected (which I doubt) do
   cat /proc/sys/kernel/randomize_va_space
 it should give 0

It did work as expected.

 Are you sure that you don't have badly coded C routines that you call
 from your Ocaml code (don't forget correct use of CAMLparam  CAMLlocal,
 read again carefully
 http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html and perhaps
 other material about precise garbage collectors).

I'm not calling any C code directly.  I am using the ocaml-ssl
library, which has
some simple calls into the OpenSSL library.

 Are you sure you don't have a memory leak in your Ocaml code? This could
 happen when a reference value refers to a big value you don't need
 anymore.

Possible.  I'll try printing out some memory statistics to see how much memory
is being consumed.

-- Paul

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] More re GC hanging

2010-08-15 Thread rixed
 For some reason, I was able to edit that file using emacs, even when
 echo wouldn't work.

maybe you wrote sudo echo 0  file or something similar which perfoms the 
echo as root but the redirection as normal user ?___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] Re: Fwd: More re GC hanging

2010-08-15 Thread Sylvain Le Gall
On 15-08-2010, Paul Steckler st...@stecksoft.com wrote:
 On Sun, Aug 15, 2010 at 7:16 PM, Basile Starynkevitch
bas...@starynkevitch.net wrote:

 Are you sure that you don't have badly coded C routines that you call
 from your Ocaml code (don't forget correct use of CAMLparam  CAMLlocal,
 read again carefully
 http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html and perhaps
 other material about precise garbage collectors).

 I'm not calling any C code directly.  I am using the ocaml-ssl
 library, which has
 some simple calls into the OpenSSL library.


Maybe it has nothing todo, but you talked about ocaml-ssl possibly and
your application hanging, it reminds me:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591891

ocaml-ssl and ocaml-dbus are involved, so maybe the guilty party is
ocaml-ssl -- this is just a guess, not sure about anything.

Regards,
Sylvain Le Gall

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] More re GC hanging

2010-08-15 Thread Adrien
Hi,

I recently had similar output from the GC (huge count of words) which
I noticed after my program started to exit with an out-of-memory
error. It doesn't seem to be happening anymore but I'm not sure I
fixed it. There are three things I thought of to get rid of it.
(btw, I'm on 64bit linux)

First, remove all non-tail-rec functions: no more List.map, @ or
List.concat. All lists were pretty short (definitely less than 1000
elements) but maybe the amount of calls generated garbage or something
like that: I couldn't get much infos about the problem so I tried what
I could think of and being tail-rec couldn't be a bad thing anyway.
The idea was to create less values since I first suspected a memory
fragmentation issue (iirc I had thousands of fragments), so I also
memoized some functions.

Then, as Basile mentionned, call something like Gc.compact ()
regularly. The overhead is actually pretty small, especially if ran
regularly.

Finally, C bindings. I created a few while not having access to the
internet and they are quite dirty. I highly doubt they play perfectly
well with the garbage collector: they seem ok but probably aren't
perfect. That's definitely something to check, even if the bindings
were written by someone else because working nicely with the GC can be
quite hard.

Now, the problem seems to be gone but I can't say for sure. One really
annoying thing was that adding a line like 'print_endline pouet;'
would make the out-of-memory problem go away! Same when getting stats
from the GC.


As for the problem with randomize_va_space on 64bit, I thought it had
been fixed in 3.11 so I haven't looked at it (and in the absence of
internet access, I was unable to get details for that problem). I just
tried about a hundred run with VA-space-randomization on and without
Gc.compact calls and ran without problem. Hopefully everything is
tracked in git so I can get the older and non-working code if needed.

Also, on my computer, I have the following behaviour:
11:44 ~ % sudo echo 0  /proc/sys/kernel/randomize_va_space
zsh: permission denied: /proc/sys/kernel/randomize_va_space
r...@jarjar:~# echo 0  /proc/sys/kernel/randomize_va_space
r...@jarjar:~#
I can't use sudo to write to most files in /proc or /sys: I have to
log in as root ('su -' does the job just fine).


Hope this helps.

 ---

Adrien Nader

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


RE: [Caml-list] More re GC hanging

2010-08-15 Thread David Allsopp
Adrien wrote:
 Hi,

snip

 Also, on my computer, I have the following behaviour:
 11:44 ~ % sudo echo 0  /proc/sys/kernel/randomize_va_space
 zsh: permission denied: /proc/sys/kernel/randomize_va_space
 r...@jarjar:~# echo 0  /proc/sys/kernel/randomize_va_space
 r...@jarjar:~#
 I can't use sudo to write to most files in /proc or /sys: I have to log in
 as root ('su -' does the job just fine).

The redirection ( /proc/sys...) is not part of the sudo invocation, it's a 
separate instruction to the *shell* to redirect output of the previous part of 
the command to a file and so it runs with *your* uid. There are two ways to 
achieve what you're after - one verbose one described in the sudo man page 
(essentially you pass the whole command line to sudo quoted) or the easier way:

echo 0| sudo tee /proc/sys/kernel/randomize_va_space

You can add  /dev/null if tee's outputting of the 0 to stdout is for some 
reason annoying.


David

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Re: Fwd: More re GC hanging

2010-08-15 Thread Vincent Hanquez
On Sun, Aug 15, 2010 at 10:41:44AM +, Sylvain Le Gall wrote:
 Maybe it has nothing todo, but you talked about ocaml-ssl possibly and
 your application hanging, it reminds me:
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591891
 
 ocaml-ssl and ocaml-dbus are involved, so maybe the guilty party is
 ocaml-ssl -- this is just a guess, not sure about anything.

As i said to the bug reporter, ocaml-dbus is not thread friendly at all; it
never drop the ocaml lock through the caml_enter_blocking_section /
caml_leave_blocking_section, so if any calls block they would block the whole
application using it.

This thread doesn't seems to involves ocaml-dbus here though, so there could
be bugs in ocaml-ssl bindings too.

-- 
Vincent

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs