--00151757089441e73b04611f21eb
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On Thu, Jan 22, 2009 at 4:09 PM, Brent Roman <brent / mbari.org> wrote:

>
> Michael,
> I'm glad you are taking this on.  Thanks.  It must have been a tedious job.
> See comments below --->
>

At my company we are running several copies of 2 Rails applications which we
have to restart on a regular basis because of the Ruby memory leak. This
patch has the capability of ending that. Tedious or not it is worth the
effort. The memory savings is an added bonus the may let us run more copies.

I am also working with a copy of 1.8.6 patched with a GC stats patch
discussed here: http://blog.pluron.com/2008/02/memory-profilin.html to aid
in performance testing and profiling our applications. And I have also been
investigating Phusion's Ruby Enterprise Edition, the changes to make the GC
copy-on-write friendly could give us a benefit.

Combining all these patches gets a little tricky in a couple places, if I
need to I will use a GC stats patched MRI for performance and profiling and
MBARI patched for production to save memory. The REE copy-on-write is just
an added bonus.


>
> Michael King-2 wrote:
> >
> > I have applied the MBARI patches to 1.8.6 p287. About half the hunks had
> > to
> > be applied by hand. In doing so I noticed 1 hunk that looked odd. The
> hunk
> > was in gc.c, in the function ruby_xmalloc, the odd line is:
> >    if ((malloc_increase+ze) > malloc_limit) {
> >
> > was is intended to change the value of malloc_increase in the if
> > statement?
> >
> > --->  Yes, that is the intent.  You will see this in ruby_xrealloc() and
> > ruby_xmalloc()
> >         Doing it this way saves a jump at the machine code level.


Ok, this was the only instance that I saw and I know I have done code like
this when I wasn't intending to, so I wanted to double check.

>
> >
> > When running test/runner.rb for the patched Ruby I am seeing the follwing
> > error and failure:
> >
> >   1) Failure:
> > test_should_propagate_signaled(TestBeginEndBlock)
> > [./test/ruby/test_beginendblock.rb:82]:
> > <""> expected to be > > </Interrupt$/>.
> >
> > --->  I see this quite often with both patched and unpatched Ruby.
> >         Does anyone know why?
> >
> >
> >   2) Error:
> > test_object_id_collision(YAML_Unit_Tests):
> > RuntimeError: id collision in ordered map
> >     ./test/yaml/test_yaml.rb:1281:in `test_object_id_collision'
> >
> > --->  This one is worrisome.  I've never seen it.
> >         I've never run tests against unpatched 1.8.6
> >         Do either of these failures occur there?


I have done multiple runs now with my unpatched copy of Ruby 1.8.6 and I
have seen 0 failures and 0 errors.

I also did a run of 1.8.7 patched and unpatched and both had 0 error and 0
failure.

I am doing this round of compiling and testing on Ubuntu 8.04 with gcc
4.2.4. I have tried compilations with the CFLAGS listed with the code and no
CFLAGS, doesn't change the outcome. our deployment environment is Ubuntu
6.06 so I will be running the tests there as well.

>
>
> Monitor the process size while running the test suite.
> If MBARI7 is working properly, you should observe that the size of the main
> test process
> near the end of its run is about 30MB less than when running with unpatched
> 1.8.6.
>
> - brent
>

This is interesting.... I will rerun the tests tomorrow, I'm done for
tonight.

Unpatched Ruby 1.8.6 capped out at 94M
Ruby 1.8.6 patched with MBARI and GC-stats capped out at 42M
Ruby 1.8.6 patched with MBARI capped out at 53M


- Michael

--00151757089441e73b04611f21eb
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br><div class="gmail_quote">On Thu, Jan 22, 2009 at 4:09 PM, Brent Roman <span dir="ltr">&lt;<a href="mailto:brent / mbari.org" target="_blank">brent / mbari.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
Michael,<br>
I&#39;m glad you are taking this on. &nbsp;Thanks. &nbsp;It must have been a tedious job.<br>
See comments below ---&gt;<br>
<div></div></blockquote><div><br>At my company we are running several copies of 2 Rails applications which we have to restart on a regular basis because of the Ruby memory leak. This patch has the capability of ending that. Tedious or not it is worth the effort. The memory savings is an added bonus the may let us run more copies.<br>

<br>I am also working with a copy of 1.8.6 patched with a GC stats patch discussed here: <a href="http://blog.pluron.com/2008/02/memory-profilin.html" target="_blank">http://blog.pluron.com/2008/02/memory-profilin.html</a> to aid in performance testing and profiling our applications. And I have also been investigating Phusion&#39;s Ruby Enterprise Edition, the changes to make the GC copy-on-write friendly could give us a benefit.<br>

<br>Combining all these patches gets a little tricky in a couple places, ifeed to I will use a GC stats patched MRI for performance and profiling and MBARI patched for production to save memory. The REE copy-on-write is just an added bonus.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solidgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
<br>
<br>
Michael King-2 wrote:<br>
&gt;<br>
&gt; I have applied the MBARI patches to 1.8.6 p287. About half the hunks had<br>
&gt; to<br>
&gt; be applied by hand. In doing so I noticed 1 hunk that looked odd. The hunk<br>
&gt; was in gc.c, in the function ruby_xmalloc, the odd line is:<br>
&gt; &nbsp; &nbsp;if ((malloc_increase+=size) &gt; malloc_limit) {<br>
&gt;<br>
&gt; was is intended to change the value of malloc_increase in the if<br>
&gt; statement?<br>
&gt;<br>
</div>&gt; ---&gt; &nbsp;Yes, that is the intent. &nbsp;You will see this in ruby_xrealloc() and<br>
&gt; ruby_xmalloc()<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Doing it this way saves a jump at the machine code level.</blockquote><div><br>Ok, this was the only instance that I saw and I know I have done code like this when I wasn&#39;t intending to, so I wanted to double check. <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div>&gt;<br>
&gt; When running test/runner.rb for the patched Ruby I am seeing the follwing<br>
&gt; error and failure:<br>
&gt;<br>
&gt; &nbsp; 1) Failure:<br>
&gt; test_should_propagate_signaled(TestBeginEndBlock)<br>
&gt; [./test/ruby/test_beginendblock.rb:82]:<br>
&gt; &lt;&quot;&quot;&gt; expected to be =~<br>
&gt; &lt;/Interrupt$/&gt;.<br>
&gt;<br>
</div>&gt; ---&gt; &nbsp;I see this quite often with both patched and unpatched Ruby.<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Does anyone know why?<br>
<div>&gt;<br>
&gt;<br>
&gt; &nbsp; 2) Error:<br>
&gt; test_object_id_collision(YAML_Unit_Tests):<br>
&gt; RuntimeError: id collision in ordered map<br>
&gt; &nbsp; &nbsp; ./test/yaml/test_yaml.rb:1281:in `test_object_id_collision&#39;<br>
&gt;<br>
</div>&gt; ---&gt; &nbsp;This one is worrisome. &nbsp;I&#39;ve never seen it.<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; I&#39;ve never run tests against unpatched.8.6<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Do either of these failures occur there?</blockquote><div><br>I have done multiple runs now with my unpatched copy ofuby 1.8.6 and I have seen 0 failures and 0 errors.<br><br>I also did a run of 1.8.7 patched and unpatched and both had 0 error and 0 failure.<br>

<br>I am doing this round of compiling and testing on Ubuntu 8.04 with gcc 4.2.4. I have tried compilations with the CFLAGS listed with the code and no CFLAGS, doesn&#39;t change the outcome. our deployment environment is Ubuntu 6.06 so I will be running the tests there as well.&nbsp;<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>
<br>
</div>Monitor the process size while running the test suite.<br>
If MBARI7 is working properly, you should observe that the size of the main<br>
test process<br>
near the end of its run is about 30MB less than when running with unpatched<br>
1.8.6.<br>
<br>
- brent<br>
<font color="#888888"></font></blockquote><div><br>This is interesting.... I will rerun the tests tomorrow, I&#39;m done for tonight.<br><br>Unpatched Ruby 1.8.6 capped out at 94M<br>Ruby 1.8.6 patched with MBARI and GC-stats capped out at 42M<br>
Ruby 1.8.6 patched with MBARI capped out at 53M<br><br>
<br>- Michael<br></div></div><br>

--00151757089441e73b04611f21eb--