You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by footh <fo...@yahoo.com> on 2008/03/17 18:57:05 UTC

Javaflow - major memory issue

I've been trying to track down a memory problem with
my Cocoon application for a long time now.  After a
period of time, maybe a week or two, the application
would die with an OutOfMemory error.  I've tried
increasing the VM memory for the servlet container
(using Tomcat 5.5) and switching to the JRockIt VM
(delayed the OOM error, but still got it).  Nothing
seemed to work.  Finally, I put my app through a
series of tests to narrow down the culprit.

After stripping layer upon layer of functionality, I
finally discovered that Javaflow seems to be the
problem.  I started with a bare-bones site and drilled
it with a load tester.  The Tomcat memory use would
remain stable.  I added more features and still no
problem.  Then, I threw in the Javaflow, and the
memory skyrocketed.  To make sure it wasn't something
I was doing in the Javaflow, I created the simplest
flow possible - a one-line "sendPage(uri)" call. 
Still the memory would blow up.

As a final test, to make sure it wasn't something I
was doing wrong, I ran the test on the sample Javaflow
application that comes with Cocoon.  I used the
calculator sample and just hit the first page.  Once
again, the memory kept rising.  If I took that page
off the test, there were no memory issues.

My next step was to profile the memory use to see if I
could find out where the memory was being allocated. 
It turns out that byte array data comprised the
majority of the allocated memory. After running a test
for 20 minutes or so, the Tomcat memory use was around
1GB with byte array data responsible for 82% of the
total.

Now, I realize that Javaflow is considered an unstable
block.  I'm wondering if anyone else using this
feature has had similar problems?  Any idea why this
might be occurring with Javaflow?  Does flowscript
have similar problems?

I now need to reconsider the MVC architecture of my
application which has been in production for several
years.  I do a lot of stuff in the Javaflow.  I'm open
to any suggestions!

Regards,

JF




      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Hello Footh,

footh pisze:
> I've been trying to track down a memory problem with
> my Cocoon application for a long time now.  After a
> period of time, maybe a week or two, the application
> would die with an OutOfMemory error.  I've tried
> increasing the VM memory for the servlet container
> (using Tomcat 5.5) and switching to the JRockIt VM
> (delayed the OOM error, but still got it).  Nothing
> seemed to work.  Finally, I put my app through a
> series of tests to narrow down the culprit.
> 
> After stripping layer upon layer of functionality, I
> finally discovered that Javaflow seems to be the
> problem.  I started with a bare-bones site and drilled
> it with a load tester.  The Tomcat memory use would
> remain stable.  I added more features and still no
> problem.  Then, I threw in the Javaflow, and the
> memory skyrocketed.  To make sure it wasn't something
> I was doing in the Javaflow, I created the simplest
> flow possible - a one-line "sendPage(uri)" call. 
> Still the memory would blow up.
> 
> As a final test, to make sure it wasn't something I
> was doing wrong, I ran the test on the sample Javaflow
> application that comes with Cocoon.  I used the
> calculator sample and just hit the first page.  Once
> again, the memory kept rising.  If I took that page
> off the test, there were no memory issues.
> 
> My next step was to profile the memory use to see if I
> could find out where the memory was being allocated. 
> It turns out that byte array data comprised the
> majority of the allocated memory. After running a test
> for 20 minutes or so, the Tomcat memory use was around
> 1GB with byte array data responsible for 82% of the
> total.
> 
> Now, I realize that Javaflow is considered an unstable
> block.  I'm wondering if anyone else using this
> feature has had similar problems?  Any idea why this
> might be occurring with Javaflow?  Does flowscript
> have similar problems?
> 
> I now need to reconsider the MVC architecture of my
> application which has been in production for several
> years.  I do a lot of stuff in the Javaflow.  I'm open
> to any suggestions!

I don't much details about javaflow internals but basic questions come to my mind:
1. Have you checked what bit of code creates these byte arrays?
2. What's stored in them?

I suggest to create an issue in JIRA and provide answers to these basic questions so devs can have a 
look and help you. If I was you I would investigate further a little bit before dropping Javaflow 
because it may turn out to be really simple problem...

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: more info

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 25, 2008, at 01:47, footh wrote:
> Thanks for the reply.  Yea, I'm not too worried about continuation  
> expiry parameter although I'd
> like to experiment with shrinking it.

Yeah ....the problem really is not the expiry parameter. It's more the  
need for a maximum kept number of continuations. Thought that had  
already been implemented. But I am not sure that really is the problem  
here.

> I think you mean sendPage vs sendPageAndWait?  I can't find  
> sendPageAndContinue.

Ups ...of course 'sendPageAndWait'

>   Anyway, both
> those methods have exactly the same code.

Not really

http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-javaflow/cocoon-javaflow-impl/src/main/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java?view=markup

see the 'Continuation.suspend()'?

> Let me try to explain my case more clearly.  I have a main  
> application with a flow that sets some
> values required for all pages (mainly in the header, footer, etc).   
> Then I have a sub-application
> that uses the same header, footer, etc. so it needs the same  
> variables set in the main flow.  But
> it also requires its own flow to do some specific logic.
>
> So, in the sitemap for this sub-application, any *.html file goes  
> through the main flow.  Then,
> the sendPage method in the main flow changes the uri to something  
> like *.html.xyz.  This hits a
> pipeline that calls the entry method in the flow for the sub- 
> application.  The sendPage in this
> method then sends the page to a pipeline that aggregates, transforms  
> and serializes.
>
> My objective behind this is to create an inheritance pattern where  
> the sub-application inherits
> the logic from the main application.  But apparently this doesn't  
> work based on the profiling I've
> done.  After two sendPage calls, the memory skyrockets and doesn't  
> clean up well.

I am really not 100% about the implementation you are  
describing ...but it somewhat sounds like you are hitting the current  
sub-pipeline restriction of javaflow. (Currently you may not call a  
sub pipeline from javaflow that has another javaflow inside) This is  
something that would need to be fixed in javaflow itself. Probably not  
even be that hard to implement. ...on the other hand if you are just  
calling 'sendPage' this *should* not really affect the javaflow  
capturing.

Since you are just calling 'sendPage' and are not really using flow  
features in the first step I would write an action and see whether  
that changes the picture.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: more info

Posted by footh <fo...@yahoo.com>.
Thanks for the reply.  Yea, I'm not too worried about continuation expiry parameter although I'd
like to experiment with shrinking it.

I think you mean sendPage vs sendPageAndWait?  I can't find sendPageAndContinue.  Anyway, both
those methods have exactly the same code.

Let me try to explain my case more clearly.  I have a main application with a flow that sets some
values required for all pages (mainly in the header, footer, etc).  Then I have a sub-application
that uses the same header, footer, etc. so it needs the same variables set in the main flow.  But
it also requires its own flow to do some specific logic.

So, in the sitemap for this sub-application, any *.html file goes through the main flow.  Then,
the sendPage method in the main flow changes the uri to something like *.html.xyz.  This hits a
pipeline that calls the entry method in the flow for the sub-application.  The sendPage in this
method then sends the page to a pipeline that aggregates, transforms and serializes.

My objective behind this is to create an inheritance pattern where the sub-application inherits
the logic from the main application.  But apparently this doesn't work based on the profiling I've
done.  After two sendPage calls, the memory skyrockets and doesn't clean up well.

I have some ideas of how to do things differently but I prefer the this way as it seems more
object-oriented.



--- Torsten Curdt <tc...@apache.org> wrote:

> 
> On Mar 20, 2008, at 20:14, footh wrote:
> > So, it appears that the continuations eventually clean up nicely.   
> > Of course, a constant load
> > would  kill the system as the continuation clean-up is too slow to  
> > keep up.  Two things to note:
> >
> > 1) The expiry parameter in cocoon.xconf did not work.  It was always  
> > 10 minutes no matter what I
> > set it to.
> 
> I remember that was reported before. Should be an easy fix.
> 
> > 2) The bottom paragraph of this page:  http://cocoon.apache.org/2.1/userdocs/flow/using.html
> > states that when using the sendPage method, no continuation is  
> > created and memory resources are
> > not used.  This does not seem to be the case as my test case uses a  
> > one-line flow with a sendPage
> > call.
> 
> Did you check the SendPage vs the SendPageAndContinue implementation?
> 
> BTW: What version are you using?
> 
> > Back to my specific case, I then went to test my full-blown  
> > application.  After running a series
> > of tests similar to the one described above, I discovered an area  
> > that appears to be a problem.  I
> > have a main application that uses a "primary" javaflow, and a sub- 
> > application of the main app that
> > needs the general logic in the primary flow and then its own logic  
> > in its own flow.  So, it runs
> > through two javaflows and thus two sendPage calls.
> 
> Not sure I get that ...I remember the limitation of javaflow not  
> behaving if you call a sub pipeline with another javaflow as the  
> continuation is (still) saved in a per-thread context.
> 
> >  To make a long story short, this seemed to
> > cause a memory leak.  Running just the main flow seemed ok, running  
> > just the sub-flow worked ok as
> > well (there appeared to be a bit of a leak, but inconclusive).   
> > However, running a page through
> > both flows showed a clear loss of memory.  The continuations did not  
> > clean up.
> >
> > So, this could very well be the source of my problems.  Based on  
> > note 2) above, I must've figured
> > this would be OK due since sendPage supposedly doesn't have a large  
> > memory footprint.  However, it
> > appears to cause a problem based on my tests.  I'm hoping the  
> > experts can chime in here:  is this
> > as bad an idea as it appears to be (running one page through  
> > multiple flows)?
> 
> Could you give an example here? I am still not sure what you mean  
> exactly by running through two flows.
> 
> Surely what is needed to make this all better and safer in a high load  
> environment is to limit the max number of continuations and not just  
> rely on the time based clean up.
> 
> cheers
> --
> Torsten
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: more info

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 20, 2008, at 20:14, footh wrote:
> So, it appears that the continuations eventually clean up nicely.   
> Of course, a constant load
> would  kill the system as the continuation clean-up is too slow to  
> keep up.  Two things to note:
>
> 1) The expiry parameter in cocoon.xconf did not work.  It was always  
> 10 minutes no matter what I
> set it to.

I remember that was reported before. Should be an easy fix.

> 2) The bottom paragraph of this page:  http://cocoon.apache.org/2.1/userdocs/flow/using.html
> states that when using the sendPage method, no continuation is  
> created and memory resources are
> not used.  This does not seem to be the case as my test case uses a  
> one-line flow with a sendPage
> call.

Did you check the SendPage vs the SendPageAndContinue implementation?

BTW: What version are you using?

> Back to my specific case, I then went to test my full-blown  
> application.  After running a series
> of tests similar to the one described above, I discovered an area  
> that appears to be a problem.  I
> have a main application that uses a "primary" javaflow, and a sub- 
> application of the main app that
> needs the general logic in the primary flow and then its own logic  
> in its own flow.  So, it runs
> through two javaflows and thus two sendPage calls.

Not sure I get that ...I remember the limitation of javaflow not  
behaving if you call a sub pipeline with another javaflow as the  
continuation is (still) saved in a per-thread context.

>  To make a long story short, this seemed to
> cause a memory leak.  Running just the main flow seemed ok, running  
> just the sub-flow worked ok as
> well (there appeared to be a bit of a leak, but inconclusive).   
> However, running a page through
> both flows showed a clear loss of memory.  The continuations did not  
> clean up.
>
> So, this could very well be the source of my problems.  Based on  
> note 2) above, I must've figured
> this would be OK due since sendPage supposedly doesn't have a large  
> memory footprint.  However, it
> appears to cause a problem based on my tests.  I'm hoping the  
> experts can chime in here:  is this
> as bad an idea as it appears to be (running one page through  
> multiple flows)?

Could you give an example here? I am still not sure what you mean  
exactly by running through two flows.

Surely what is needed to make this all better and safer in a high load  
environment is to limit the max number of continuations and not just  
rely on the time based clean up.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: more info

Posted by footh <fo...@yahoo.com>.
OK, so I did a lot more digging into the Javaflow issue.  This time I would ram the server with
the load tester, and then wait to see how the continuations were cleaned up.  After running a
bunch of tests, I found out the they were cleaned up in a very regular manner.  For example, I
would run 1000 samples, the Tomcat memory would shoot up to a point, then I'd wait 10 minutes and
the continuations would for the most part clean up but Tomcat memory would stay the same.  Then I
ran 1500 samples, and Tomcat memory would remain stable until I hit somewhere around the 1000th
sample and then the memory would start going up again.  After waiting 10 minutes, the memory
appeared to clear back to the baseline (Tomcat still staying at the new 1500 sample total).  The
cycle continued on 2000 samples where Tomcat total memory wouldn't go up until hitting around 1500
samples, the memory clearing after 10 minutes, etc.

So, it appears that the continuations eventually clean up nicely.  Of course, a constant load
would  kill the system as the continuation clean-up is too slow to keep up.  Two things to note:

1) The expiry parameter in cocoon.xconf did not work.  It was always 10 minutes no matter what I
set it to.

2) The bottom paragraph of this page:  http://cocoon.apache.org/2.1/userdocs/flow/using.html
states that when using the sendPage method, no continuation is created and memory resources are
not used.  This does not seem to be the case as my test case uses a one-line flow with a sendPage
call.

Back to my specific case, I then went to test my full-blown application.  After running a series
of tests similar to the one described above, I discovered an area that appears to be a problem.  I
have a main application that uses a "primary" javaflow, and a sub-application of the main app that
needs the general logic in the primary flow and then its own logic in its own flow.  So, it runs
through two javaflows and thus two sendPage calls.  To make a long story short, this seemed to
cause a memory leak.  Running just the main flow seemed ok, running just the sub-flow worked ok as
well (there appeared to be a bit of a leak, but inconclusive).  However, running a page through
both flows showed a clear loss of memory.  The continuations did not clean up.

So, this could very well be the source of my problems.  Based on note 2) above, I must've figured
this would be OK due since sendPage supposedly doesn't have a large memory footprint.  However, it
appears to cause a problem based on my tests.  I'm hoping the experts can chime in here:  is this
as bad an idea as it appears to be (running one page through multiple flows)?

-JF

--- Antonio Gallardo <ag...@agssa.net> wrote:

> footh escribió:
> > Ok, so I applied the patch supplied by cocoon-2109.  The results appear to be the same.  After
> 10K
> > samples from the load tester, the tomcat memory was virtually identical from before and after
> the
> > patch.  Then, I ran the load tester with the profiler attached.  With the slower page response
> > time (due to the profiler) the memory *seemed* to move up slower with the new code but that is
> by
> > no means a scientific obeservation.  In the end, the memory still increased.
> >   
> I think this is expected, because if the continuation did not expire 
> (timeout), then the result is the same (with and without the patch). The 
> difference is that with the patch, all the expired continuation should 
> be garbage collected.
> 
> For testing it would be worth to set to a lower value the continuation 
> expiration time. I think it is in cocoon.xconf.
> 
> > Upon examining the profiler data, there was a difference however.  Instead of the
> > ContinuationsManagerImpl (CMI) having the greatest retained size, it was a bunch of HashMap
> > objects at the top of the list.  The one CMI object was in second place (63% on this run) but
> > about 19K HashMap objects were responsible for 92%.  I assume this is because the patch
> changes a
> > variable in CMI to a HashMap and so the retained size of the CMI object gets lopped into the
> > HashMap objects whereas pre-patch this wasn't the case.
> >   
> I cannot find a newly introduced HashMap in the patch:
> https://issues.apache.org/jira/secure/attachment/12363582/ContinuationsManagerImpl.java.patch
> > The real question I have is, why is the CMI object retained size so large?
> It has to keep the whole running environment to restore it when we call 
> again the same continuation. However, it may be worth to review the 
> memory size per continuation.
> 
> >   As the load testing
> > continues, the memory retained by CMI dominates the rest of the objects.  If the load stops,
> it is
> > eventually cleaned up, but by then it may be too late.
> >
> > If there are any other suggestions, I'm willing to put more effort into figuring this out.
> >   
> Thanks.
> 
> Best Regards,
> 
> Antonio Gallardo.
> 
> >
> > --- footh <fo...@yahoo.com> wrote:
> >
> >   
> >> Ok, I'll give the patch a shot.
> >>
> >> I'm using Tomcat version 5.5.26.  Concerning the
> >> store-janitor values, I haven't changed them from the
> >> default.
> >>
> >> In fact, as I stated in my first post, the problem
> >> occurs even on the sample javaflow calculator
> >> application (relative url: 
> >> /cocoon/samples/blocks/javaflow/calculator.do).  Try
> >> hitting that page a bunch of times with a load tester.
> >>
> >>
> >> --- Antonio Gallardo <ag...@agssa.net> wrote:
> >>
> >>     
> >>> Hi footh,
> >>>
> >>> Testing the patch is a good start. Would you provide
> >>> tomcat version and 
> >>> the parameters you use to start it?
> >>>
> >>> How do you configure cocoon.xconf, in special the
> >>> values for:
> >>>
> >>> <store-janitor logger="core.store.janitor"/>?
> >>>
> >>> Best Regards,
> >>>
> >>> Antonio Gallardo.
> >>>
> >>> footh escribió:
> >>>       
> >>>> Thanks for all the replies.  I did some more
> >>>>         
> >>> digging
> >>>       
> >>>> into the profiling data.  It turns out that the
> >>>> ContinuationsManagerImpl is at the top of the
> >>>>         
> >>> object
> >>>       
> >>>> path of the byte arrays where 
> >>>>
> >>>>         
> >> org.apache.cocoon.environment.util.BufferedOutputStream
> >>     
> >>>> is the actual parent of the arrays.
> >>>>
> >>>> Looking down the path, I can see the TreeSet and
> >>>> SortedSet that is mentioned in cocoon-2109.  I
> >>>>         
> >>> would
> >>>       
> >>>> say this issue is a likely cause for the memory
> >>>> ballooning.
> >>>>
> >>>> The load tester is simulating 5 users staggered 10
> >>>> seconds apart and only hitting a couple very
> >>>>         
> >>> simple
> >>>       
> >>>> pages.  Yet within 15 minutes, the Tomcat memory
> >>>>         
> >>> use
> >>>       
> >>>> approaches 1GB.  After stopping the load tester
> >>>>         
> >>> and
> >>>       
> >>>> examining the memory, I did notice in the profiler
> >>>> that the byte arrays eventually cleaned up. 
> >>>>         
> >>> However,
> >>>       
> >>>> looking at the Task Manger (using Windows), Tomcat
> >>>>         
> >>> was
> >>>       
> >>>> still holding the full amount of memory from when
> >>>>         
> >>> I
> >>>       
> >>>> stopped the load tester, ie. it didn't go down
> >>>>         
> >>> when
> >>>       
> >>>> the  byte arrays cleaned up.
> >>>>
> >>>> I suppose the next step is to try the patch
> >>>>         
> >>> provided
> >>>       
> >>>> in  2109.  Any other suggestions?
> >>>>
> >>>>   
> >>>>         
> >>>       
> >> ---------------------------------------------------------------------
> >>     
> >>> To unsubscribe, e-mail:
> >>> users-unsubscribe@cocoon.apache.org
> >>> For additional commands, e-mail:
> >>> users-help@cocoon.apache.org
> >>>
> >>>
> >>>       
> >>
> >>       ____________________________________________________________________________________
> >> Never miss a thing.  Make Yahoo your home page. 
> >> http://www.yahoo.com/r/hs
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >>
> >>     
> >
> >
> >
> >       ____________________________________________________________________________________
> > Be a better friend, newshound, and 
> > know-it-all with Yahoo! Mobile.  Try it now. 
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: 2109 patch results

Posted by Antonio Gallardo <ag...@agssa.net>.
footh escribió:
> Ok, so I applied the patch supplied by cocoon-2109.  The results appear to be the same.  After 10K
> samples from the load tester, the tomcat memory was virtually identical from before and after the
> patch.  Then, I ran the load tester with the profiler attached.  With the slower page response
> time (due to the profiler) the memory *seemed* to move up slower with the new code but that is by
> no means a scientific obeservation.  In the end, the memory still increased.
>   
I think this is expected, because if the continuation did not expire 
(timeout), then the result is the same (with and without the patch). The 
difference is that with the patch, all the expired continuation should 
be garbage collected.

For testing it would be worth to set to a lower value the continuation 
expiration time. I think it is in cocoon.xconf.

> Upon examining the profiler data, there was a difference however.  Instead of the
> ContinuationsManagerImpl (CMI) having the greatest retained size, it was a bunch of HashMap
> objects at the top of the list.  The one CMI object was in second place (63% on this run) but
> about 19K HashMap objects were responsible for 92%.  I assume this is because the patch changes a
> variable in CMI to a HashMap and so the retained size of the CMI object gets lopped into the
> HashMap objects whereas pre-patch this wasn't the case.
>   
I cannot find a newly introduced HashMap in the patch:
https://issues.apache.org/jira/secure/attachment/12363582/ContinuationsManagerImpl.java.patch
> The real question I have is, why is the CMI object retained size so large?
It has to keep the whole running environment to restore it when we call 
again the same continuation. However, it may be worth to review the 
memory size per continuation.

>   As the load testing
> continues, the memory retained by CMI dominates the rest of the objects.  If the load stops, it is
> eventually cleaned up, but by then it may be too late.
>
> If there are any other suggestions, I'm willing to put more effort into figuring this out.
>   
Thanks.

Best Regards,

Antonio Gallardo.

>
> --- footh <fo...@yahoo.com> wrote:
>
>   
>> Ok, I'll give the patch a shot.
>>
>> I'm using Tomcat version 5.5.26.  Concerning the
>> store-janitor values, I haven't changed them from the
>> default.
>>
>> In fact, as I stated in my first post, the problem
>> occurs even on the sample javaflow calculator
>> application (relative url: 
>> /cocoon/samples/blocks/javaflow/calculator.do).  Try
>> hitting that page a bunch of times with a load tester.
>>
>>
>> --- Antonio Gallardo <ag...@agssa.net> wrote:
>>
>>     
>>> Hi footh,
>>>
>>> Testing the patch is a good start. Would you provide
>>> tomcat version and 
>>> the parameters you use to start it?
>>>
>>> How do you configure cocoon.xconf, in special the
>>> values for:
>>>
>>> <store-janitor logger="core.store.janitor"/>?
>>>
>>> Best Regards,
>>>
>>> Antonio Gallardo.
>>>
>>> footh escribió:
>>>       
>>>> Thanks for all the replies.  I did some more
>>>>         
>>> digging
>>>       
>>>> into the profiling data.  It turns out that the
>>>> ContinuationsManagerImpl is at the top of the
>>>>         
>>> object
>>>       
>>>> path of the byte arrays where 
>>>>
>>>>         
>> org.apache.cocoon.environment.util.BufferedOutputStream
>>     
>>>> is the actual parent of the arrays.
>>>>
>>>> Looking down the path, I can see the TreeSet and
>>>> SortedSet that is mentioned in cocoon-2109.  I
>>>>         
>>> would
>>>       
>>>> say this issue is a likely cause for the memory
>>>> ballooning.
>>>>
>>>> The load tester is simulating 5 users staggered 10
>>>> seconds apart and only hitting a couple very
>>>>         
>>> simple
>>>       
>>>> pages.  Yet within 15 minutes, the Tomcat memory
>>>>         
>>> use
>>>       
>>>> approaches 1GB.  After stopping the load tester
>>>>         
>>> and
>>>       
>>>> examining the memory, I did notice in the profiler
>>>> that the byte arrays eventually cleaned up. 
>>>>         
>>> However,
>>>       
>>>> looking at the Task Manger (using Windows), Tomcat
>>>>         
>>> was
>>>       
>>>> still holding the full amount of memory from when
>>>>         
>>> I
>>>       
>>>> stopped the load tester, ie. it didn't go down
>>>>         
>>> when
>>>       
>>>> the  byte arrays cleaned up.
>>>>
>>>> I suppose the next step is to try the patch
>>>>         
>>> provided
>>>       
>>>> in  2109.  Any other suggestions?
>>>>
>>>>   
>>>>         
>>>       
>> ---------------------------------------------------------------------
>>     
>>> To unsubscribe, e-mail:
>>> users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail:
>>> users-help@cocoon.apache.org
>>>
>>>
>>>       
>>
>>       ____________________________________________________________________________________
>> Never miss a thing.  Make Yahoo your home page. 
>> http://www.yahoo.com/r/hs
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>     
>
>
>
>       ____________________________________________________________________________________
> Be a better friend, newshound, and 
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue: 2109 patch results

Posted by footh <fo...@yahoo.com>.
Ok, so I applied the patch supplied by cocoon-2109.  The results appear to be the same.  After 10K
samples from the load tester, the tomcat memory was virtually identical from before and after the
patch.  Then, I ran the load tester with the profiler attached.  With the slower page response
time (due to the profiler) the memory *seemed* to move up slower with the new code but that is by
no means a scientific obeservation.  In the end, the memory still increased.

Upon examining the profiler data, there was a difference however.  Instead of the
ContinuationsManagerImpl (CMI) having the greatest retained size, it was a bunch of HashMap
objects at the top of the list.  The one CMI object was in second place (63% on this run) but
about 19K HashMap objects were responsible for 92%.  I assume this is because the patch changes a
variable in CMI to a HashMap and so the retained size of the CMI object gets lopped into the
HashMap objects whereas pre-patch this wasn't the case.

The real question I have is, why is the CMI object retained size so large?  As the load testing
continues, the memory retained by CMI dominates the rest of the objects.  If the load stops, it is
eventually cleaned up, but by then it may be too late.

If there are any other suggestions, I'm willing to put more effort into figuring this out.


--- footh <fo...@yahoo.com> wrote:

> Ok, I'll give the patch a shot.
> 
> I'm using Tomcat version 5.5.26.  Concerning the
> store-janitor values, I haven't changed them from the
> default.
> 
> In fact, as I stated in my first post, the problem
> occurs even on the sample javaflow calculator
> application (relative url: 
> /cocoon/samples/blocks/javaflow/calculator.do).  Try
> hitting that page a bunch of times with a load tester.
> 
> 
> --- Antonio Gallardo <ag...@agssa.net> wrote:
> 
> > Hi footh,
> > 
> > Testing the patch is a good start. Would you provide
> > tomcat version and 
> > the parameters you use to start it?
> > 
> > How do you configure cocoon.xconf, in special the
> > values for:
> > 
> > <store-janitor logger="core.store.janitor"/>?
> > 
> > Best Regards,
> > 
> > Antonio Gallardo.
> > 
> > footh escribió:
> > > Thanks for all the replies.  I did some more
> > digging
> > > into the profiling data.  It turns out that the
> > > ContinuationsManagerImpl is at the top of the
> > object
> > > path of the byte arrays where 
> > >
> >
> org.apache.cocoon.environment.util.BufferedOutputStream
> > > is the actual parent of the arrays.
> > >
> > > Looking down the path, I can see the TreeSet and
> > > SortedSet that is mentioned in cocoon-2109.  I
> > would
> > > say this issue is a likely cause for the memory
> > > ballooning.
> > >
> > > The load tester is simulating 5 users staggered 10
> > > seconds apart and only hitting a couple very
> > simple
> > > pages.  Yet within 15 minutes, the Tomcat memory
> > use
> > > approaches 1GB.  After stopping the load tester
> > and
> > > examining the memory, I did notice in the profiler
> > > that the byte arrays eventually cleaned up. 
> > However,
> > > looking at the Task Manger (using Windows), Tomcat
> > was
> > > still holding the full amount of memory from when
> > I
> > > stopped the load tester, ie. it didn't go down
> > when
> > > the  byte arrays cleaned up.
> > >
> > > I suppose the next step is to try the patch
> > provided
> > > in  2109.  Any other suggestions?
> > >
> > >   
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail:
> > users-help@cocoon.apache.org
> > 
> > 
> 
> 
> 
>       ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Ok, I'll give the patch a shot.

I'm using Tomcat version 5.5.26.  Concerning the
store-janitor values, I haven't changed them from the
default.

In fact, as I stated in my first post, the problem
occurs even on the sample javaflow calculator
application (relative url: 
/cocoon/samples/blocks/javaflow/calculator.do).  Try
hitting that page a bunch of times with a load tester.


--- Antonio Gallardo <ag...@agssa.net> wrote:

> Hi footh,
> 
> Testing the patch is a good start. Would you provide
> tomcat version and 
> the parameters you use to start it?
> 
> How do you configure cocoon.xconf, in special the
> values for:
> 
> <store-janitor logger="core.store.janitor"/>?
> 
> Best Regards,
> 
> Antonio Gallardo.
> 
> footh escribió:
> > Thanks for all the replies.  I did some more
> digging
> > into the profiling data.  It turns out that the
> > ContinuationsManagerImpl is at the top of the
> object
> > path of the byte arrays where 
> >
>
org.apache.cocoon.environment.util.BufferedOutputStream
> > is the actual parent of the arrays.
> >
> > Looking down the path, I can see the TreeSet and
> > SortedSet that is mentioned in cocoon-2109.  I
> would
> > say this issue is a likely cause for the memory
> > ballooning.
> >
> > The load tester is simulating 5 users staggered 10
> > seconds apart and only hitting a couple very
> simple
> > pages.  Yet within 15 minutes, the Tomcat memory
> use
> > approaches 1GB.  After stopping the load tester
> and
> > examining the memory, I did notice in the profiler
> > that the byte arrays eventually cleaned up. 
> However,
> > looking at the Task Manger (using Windows), Tomcat
> was
> > still holding the full amount of memory from when
> I
> > stopped the load tester, ie. it didn't go down
> when
> > the  byte arrays cleaned up.
> >
> > I suppose the next step is to try the patch
> provided
> > in  2109.  Any other suggestions?
> >
> >   
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Antonio Gallardo <ag...@agssa.net>.
Hi footh,

Testing the patch is a good start. Would you provide tomcat version and 
the parameters you use to start it?

How do you configure cocoon.xconf, in special the values for:

<store-janitor logger="core.store.janitor"/>?

Best Regards,

Antonio Gallardo.

footh escribió:
> Thanks for all the replies.  I did some more digging
> into the profiling data.  It turns out that the
> ContinuationsManagerImpl is at the top of the object
> path of the byte arrays where 
> org.apache.cocoon.environment.util.BufferedOutputStream
> is the actual parent of the arrays.
>
> Looking down the path, I can see the TreeSet and
> SortedSet that is mentioned in cocoon-2109.  I would
> say this issue is a likely cause for the memory
> ballooning.
>
> The load tester is simulating 5 users staggered 10
> seconds apart and only hitting a couple very simple
> pages.  Yet within 15 minutes, the Tomcat memory use
> approaches 1GB.  After stopping the load tester and
> examining the memory, I did notice in the profiler
> that the byte arrays eventually cleaned up.  However,
> looking at the Task Manger (using Windows), Tomcat was
> still holding the full amount of memory from when I
> stopped the load tester, ie. it didn't go down when
> the  byte arrays cleaned up.
>
> I suppose the next step is to try the patch provided
> in  2109.  Any other suggestions?
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
>>> Without completely rewriting it the only thing I did was to remove  
>>> the data in the ContinuationContext that is not necessary. I do  
>>> this by an extra call to ContinuationContext.onSuspend() in  
>>> AbstractContinuable since Continuation is not aware of the  
>>> implementation of its context (it's just an Object).
>>>
>>> Please review my changes [1] because I'm not really sure about them.
>> Not a fan of the Collections.synchronizedMap(new HashMap()) change  
>> - but
>
> Just curious, any reason for this? Is it not "as optimized"?

Well, of course you pay a runtime penalty for another method  
invocation ....unless the hotspots is able to optimize that away. Not  
sure.

But it's less about optimization - more about keeping the  
synchronization more visible. But as long as the access to the hashmap  
is simple like it is right now I would not argue about it :)

>> other than that they look OK on the first glance :)
>>> They work for the normal case, but what happens in an error case?  
>>> I can't see what's really going on except that the method is left  
>>> on Continuation.suspend() ... It was very interesting to debug it  
>>> when AbstractContinuable.sendPageAndWait(..) was actually hit twice.
>> :) ...what error case do you mean?
>
> Not sure, originally you proposed to put it into a try finally block.

Just to have it as post condition. You never know.

>>> I guess this handling is different in 2.2. There a clean  
>>> ContinuationContext is created on both callFunction(..) and  
>>> handleContinuation(..).
>> Indeed ...that would be another fix ...porting it from 2.2 :)
>
> That's really beyond what I want to do ;-) Let's leave the good  
> stuff for 2.2.

+1

>> Thanks for looking into that.
>
> It was really interesting to see how a Java method is cut into two  
> pieces. Suddenly the debugger stops stepping, but just leaves the  
> methods. And on the next call it just jumps to the appropriate  
> places in the code. Once you get used to it it's easy to debug. I  
> have never tried it before but now I like it better than flowscript.

Yeah, it's interesting isn't it? :)

cheers
--
Torsten

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 30.03.2008 07:35, Torsten Curdt wrote:

> There is no need to really obtain that value from the parent. If 
> handleContinuation would have also the function parameter it could use 
> the same initialization as in callFuntion.

Yes, if the function name would have been available ... This was beyond 
what I wanted to do. But since you confirmed it now I risked this change.

> Actually a way of fixing this 
> would be to add two Strings to the Continuation class. One holding the 
> classname, the other holding the method name. And then do
> 
> context.setObject(userScopes.get(parentContinuation.getScopeName()));
> context.setMethod(methods.get(parentContinuation.getFunctionName()));

The scopes are by Class. Therefore I only stored the function name and 
retrieved the method.

> in handleContinuation. Then the cleaning of the context should be fine.

Yes, it's better now.

>> Without completely rewriting it the only thing I did was to remove the 
>> data in the ContinuationContext that is not necessary. I do this by an 
>> extra call to ContinuationContext.onSuspend() in AbstractContinuable 
>> since Continuation is not aware of the implementation of its context 
>> (it's just an Object).
>>
>> Please review my changes [1] because I'm not really sure about them.
> 
> Not a fan of the Collections.synchronizedMap(new HashMap()) change - but 

Just curious, any reason for this? Is it not "as optimized"?

> other than that they look OK on the first glance :)
> 
>> They work for the normal case, but what happens in an error case? I 
>> can't see what's really going on except that the method is left on 
>> Continuation.suspend() ... It was very interesting to debug it when 
>> AbstractContinuable.sendPageAndWait(..) was actually hit twice.
> 
> :) ...what error case do you mean?

Not sure, originally you proposed to put it into a try finally block.

>> I guess this handling is different in 2.2. There a clean 
>> ContinuationContext is created on both callFunction(..) and 
>> handleContinuation(..).
> 
> Indeed ...that would be another fix ...porting it from 2.2 :)

That's really beyond what I want to do ;-) Let's leave the good stuff 
for 2.2.

> Thanks for looking into that.

It was really interesting to see how a Java method is cut into two 
pieces. Suddenly the debugger stops stepping, but just leaves the 
methods. And on the next call it just jumps to the appropriate places in 
the code. Once you get used to it it's easy to debug. I have never tried 
it before but now I like it better than flowscript.

Joerg

Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 30, 2008, at 09:43, Joerg Heinicke wrote:
> On 28.03.2008 04:55, Torsten Curdt wrote:
>
>>> The output I showed pointed to  
>>> org.apache.cocoon.components.flow.java.Continuation which only  
>>> seems to exist in Cocoon 2.1. Nothing unsets the context there.
>> Hah - well spotted!
>>> Having a look into the code continuations are only handled by  
>>> JavaInterpreter. There are two methods callFunction(..) and  
>>> handleContinuation(..) calling Continuation.registerThread() and  
>>> deregisterThread() in a finally block. From a brief look I have no  
>>> idea if I can just unset the ContinuationContext there as well.  
>>> You might know more about it.
>> We should add a try/finally block in Continuation.suspend() that  
>> clears the context after a suspend. That should fix it.
>
> Unfortunately, it is not possible to unset the ContinuationContext  
> completely. It's needed in JavaInterpreter.handleContinuation(..)  
> when a child continuation is created:
>
>  Continuation parentContinuation =
>      (Continuation) parentwk.getContinuation();
>  ContinuationContext parentContext =
>      (ContinuationContext) parentContinuation.getContext();
>  ContinuationContext context = new ContinuationContext();
>  context.setObject(parentContext.getObject());
>  context.setMethod(parentContext.getMethod());

There is no need to really obtain that value from the parent. If  
handleContinuation would have also the function parameter it could use  
the same initialization as in callFuntion. Actually a way of fixing  
this would be to add two Strings to the Continuation class. One  
holding the classname, the other holding the method name. And then do

context.setObject(userScopes.get(parentContinuation.getScopeName()));
context.setMethod(methods.get(parentContinuation.getFunctionName()));

in handleContinuation. Then the cleaning of the context should be fine.

> Without completely rewriting it the only thing I did was to remove  
> the data in the ContinuationContext that is not necessary. I do this  
> by an extra call to ContinuationContext.onSuspend() in  
> AbstractContinuable since Continuation is not aware of the  
> implementation of its context (it's just an Object).
>
> Please review my changes [1] because I'm not really sure about them.

Not a fan of the Collections.synchronizedMap(new HashMap()) change -  
but other than that they look OK on the first glance :)

> They work for the normal case, but what happens in an error case? I  
> can't see what's really going on except that the method is left on  
> Continuation.suspend() ... It was very interesting to debug it when  
> AbstractContinuable.sendPageAndWait(..) was actually hit twice.

:) ...what error case do you mean?

> I guess this handling is different in 2.2. There a clean  
> ContinuationContext is created on both callFunction(..) and  
> handleContinuation(..).

Indeed ...that would be another fix ...porting it from 2.2 :)

Thanks for looking into that.

cheers
--
Torsten

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 28.03.2008 04:55, Torsten Curdt wrote:

>> The output I showed pointed to 
>> org.apache.cocoon.components.flow.java.Continuation which only seems 
>> to exist in Cocoon 2.1. Nothing unsets the context there.
> 
> Hah - well spotted!
> 
>> Having a look into the code continuations are only handled by 
>> JavaInterpreter. There are two methods callFunction(..) and 
>> handleContinuation(..) calling Continuation.registerThread() and 
>> deregisterThread() in a finally block. From a brief look I have no 
>> idea if I can just unset the ContinuationContext there as well. You 
>> might know more about it.
> 
> We should add a try/finally block in Continuation.suspend() that clears 
> the context after a suspend. That should fix it.

Unfortunately, it is not possible to unset the ContinuationContext 
completely. It's needed in JavaInterpreter.handleContinuation(..) when a 
child continuation is created:

   Continuation parentContinuation =
       (Continuation) parentwk.getContinuation();
   ContinuationContext parentContext =
       (ContinuationContext) parentContinuation.getContext();
   ContinuationContext context = new ContinuationContext();
   context.setObject(parentContext.getObject());
   context.setMethod(parentContext.getMethod());

Without completely rewriting it the only thing I did was to remove the 
data in the ContinuationContext that is not necessary. I do this by an 
extra call to ContinuationContext.onSuspend() in AbstractContinuable 
since Continuation is not aware of the implementation of its context 
(it's just an Object).

Please review my changes [1] because I'm not really sure about them. 
They work for the normal case, but what happens in an error case? I 
can't see what's really going on except that the method is left on 
Continuation.suspend() ... It was very interesting to debug it when 
AbstractContinuable.sendPageAndWait(..) was actually hit twice.

I guess this handling is different in 2.2. There a clean 
ContinuationContext is created on both callFunction(..) and 
handleContinuation(..).

Joerg

[1] http://svn.apache.org/viewvc?rev=642694&view=rev

Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 28, 2008, at 04:29, Joerg Heinicke wrote:
> On 27.03.2008 10:33, Torsten Curdt wrote:
>
>>>>> Just have a look at the quote from the original. It gives the  
>>>>> object
>>>>> relationships in the memory. BufferedOutputStream takes 50% and is
>>>>> hold in HttpEnvironment which is hold in TreeProcessorRedirector
>>>>> which is hold in ContinuationContext. I wondered why it is there.
>>>>
>>>> Ah ...well, the ContinuationContext should be short living. Maybe
>>>> there is a dangling reference to it?
>>>
>>> Ah, getting closer :)
>>>
>>> It's the Continuation that holds the ContinuationContext [1]:
>> Hm... it should set clear the reference in 'finally'. See the  
>> execute method
>> http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java?revision=560660&view=markup
>
> The output I showed pointed to  
> org.apache.cocoon.components.flow.java.Continuation which only seems  
> to exist in Cocoon 2.1. Nothing unsets the context there.

Hah - well spotted!

> Having a look into the code continuations are only handled by  
> JavaInterpreter. There are two methods callFunction(..) and  
> handleContinuation(..) calling Continuation.registerThread() and  
> deregisterThread() in a finally block. From a brief look I have no  
> idea if I can just unset the ContinuationContext there as well. You  
> might know more about it.

We should add a try/finally block in Continuation.suspend() that  
clears the context after a suspend. That should fix it.

cheers
--
Torsten

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.03.2008 10:33, Torsten Curdt wrote:

>>>> Just have a look at the quote from the original. It gives the object
>>>> relationships in the memory. BufferedOutputStream takes 50% and is
>>>> hold in HttpEnvironment which is hold in TreeProcessorRedirector
>>>> which is hold in ContinuationContext. I wondered why it is there.
>>>
>>> Ah ...well, the ContinuationContext should be short living. Maybe
>>> there is a dangling reference to it?
>>
>> Ah, getting closer :)
>>
>> It's the Continuation that holds the ContinuationContext [1]:
> 
> Hm... it should set clear the reference in 'finally'. See the execute 
> method
> 
> http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java?revision=560660&view=markup 

The output I showed pointed to 
org.apache.cocoon.components.flow.java.Continuation which only seems to 
exist in Cocoon 2.1. Nothing unsets the context there.

Having a look into the code continuations are only handled by 
JavaInterpreter. There are two methods callFunction(..) and 
handleContinuation(..) calling Continuation.registerThread() and 
deregisterThread() in a finally block. From a brief look I have no idea 
if I can just unset the ContinuationContext there as well. You might 
know more about it.

Joerg

Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 15:33, Torsten Curdt wrote:
>
> On Mar 27, 2008, at 15:13, Joerg Heinicke wrote:
>> Torsten Curdt <tcurdt <at> apache.org> writes:
>>
>>>> Just have a look at the quote from the original. It gives the  
>>>> object
>>>> relationships in the memory. BufferedOutputStream takes 50% and is
>>>> hold in HttpEnvironment which is hold in TreeProcessorRedirector
>>>> which is hold in ContinuationContext. I wondered why it is there.
>>>
>>> Ah ...well, the ContinuationContext should be short living. Maybe
>>> there is a dangling reference to it?
>>
>> Ah, getting closer :)
>>
>> It's the Continuation that holds the ContinuationContext [1]:
>
> Hm... it should set clear the reference in 'finally'. See the  
> execute method
>
> http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java?revision=560660&view=markup
>
> Weird...

What cocoon version are we talking about anyway?


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 15:13, Joerg Heinicke wrote:
> Torsten Curdt <tcurdt <at> apache.org> writes:
>
>>> Just have a look at the quote from the original. It gives the object
>>> relationships in the memory. BufferedOutputStream takes 50% and is
>>> hold in HttpEnvironment which is hold in TreeProcessorRedirector
>>> which is hold in ContinuationContext. I wondered why it is there.
>>
>> Ah ...well, the ContinuationContext should be short living. Maybe
>> there is a dangling reference to it?
>
> Ah, getting closer :)
>
> It's the Continuation that holds the ContinuationContext [1]:

Hm... it should set clear the reference in 'finally'. See the execute  
method

http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java?revision=560660&view=markup

Weird...

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
Torsten Curdt <tcurdt <at> apache.org> writes:

> > Just have a look at the quote from the original. It gives the object  
> > relationships in the memory. BufferedOutputStream takes 50% and is  
> > hold in HttpEnvironment which is hold in TreeProcessorRedirector  
> > which is hold in ContinuationContext. I wondered why it is there.
> 
> Ah ...well, the ContinuationContext should be short living. Maybe  
> there is a dangling reference to it?

Ah, getting closer :)

It's the Continuation that holds the ContinuationContext [1]:

org.apache.cocoon.util.BufferedOutputStream
secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
env of
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor
    $TreeProcessorRedirector
redirector of  org.apache.cocoon.components.flow.java.ContinuationContext
context of  org.apache.cocoon.components.flow.java.Continuation
continuation of  org.apache.cocoon.components.flow.WebContinuation

Joerg

[1] http://marc.info/?l=xml-cocoon-users&m=120582409910104&w=4


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 13:18, Joerg Heinicke wrote:
> On 27.03.2008 04:39, Torsten Curdt wrote:
>
>>>> Sure, here is the hierarchy from bottom to top.  At this point, I  
>>>> ran the test for about five
>>>> minutes (running longer would increase the percentage) and the  
>>>> retained size of the one
>>>> ContinuationsManagerImpl object is 58% of the total.  The  
>>>> BufferedOutputStream is 50% of the
>>>> total, so the other 8% is consumed by the objects in between.
>>>> org.apache.cocoon.util.BufferedOutputStream
>>>> secureOutputStream of   
>>>> org.apache.cocoon.environment.http.HttpEnvironment
>>>> env of   
>>>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor 
>>>> $TreeProcessorRedirector redirector of   
>>>> org.apache.cocoon.components.flow.java.ContinuationContext
>>>
>>> What I was so much concerned about here was the fact of storing  
>>> the whole environment in the continuation, especially since we  
>>> have this non-flushing BufferedOutputStream at the end. Is there  
>>> any point in storing the environment? Do we get anything useful  
>>> out of it after continueing the continuation?
>> What do you mean by "environment" ...it's not like the whole jvm is  
>> stored but only the flow. External resources should be injected (vs  
>> stored) as much as possible.
>
> Just have a look at the quote from the original. It gives the object  
> relationships in the memory. BufferedOutputStream takes 50% and is  
> hold in HttpEnvironment which is hold in TreeProcessorRedirector  
> which is hold in ContinuationContext. I wondered why it is there.

Ah ...well, the ContinuationContext should be short living. Maybe  
there is a dangling reference to it?

(Let's stop cross posting and move over to the dev list)

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 13:18, Joerg Heinicke wrote:
> On 27.03.2008 04:39, Torsten Curdt wrote:
>
>>>> Sure, here is the hierarchy from bottom to top.  At this point, I  
>>>> ran the test for about five
>>>> minutes (running longer would increase the percentage) and the  
>>>> retained size of the one
>>>> ContinuationsManagerImpl object is 58% of the total.  The  
>>>> BufferedOutputStream is 50% of the
>>>> total, so the other 8% is consumed by the objects in between.
>>>> org.apache.cocoon.util.BufferedOutputStream
>>>> secureOutputStream of   
>>>> org.apache.cocoon.environment.http.HttpEnvironment
>>>> env of   
>>>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor 
>>>> $TreeProcessorRedirector redirector of   
>>>> org.apache.cocoon.components.flow.java.ContinuationContext
>>>
>>> What I was so much concerned about here was the fact of storing  
>>> the whole environment in the continuation, especially since we  
>>> have this non-flushing BufferedOutputStream at the end. Is there  
>>> any point in storing the environment? Do we get anything useful  
>>> out of it after continueing the continuation?
>> What do you mean by "environment" ...it's not like the whole jvm is  
>> stored but only the flow. External resources should be injected (vs  
>> stored) as much as possible.
>
> Just have a look at the quote from the original. It gives the object  
> relationships in the memory. BufferedOutputStream takes 50% and is  
> hold in HttpEnvironment which is hold in TreeProcessorRedirector  
> which is hold in ContinuationContext. I wondered why it is there.

Ah ...well, the ContinuationContext should be short living. Maybe  
there is a dangling reference to it?

(Let's stop cross posting and move over to the dev list)

cheers
--
Torsten

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.03.2008 04:39, Torsten Curdt wrote:

>>> Sure, here is the hierarchy from bottom to top.  At this point, I ran 
>>> the test for about five
>>> minutes (running longer would increase the percentage) and the 
>>> retained size of the one
>>> ContinuationsManagerImpl object is 58% of the total.  The 
>>> BufferedOutputStream is 50% of the
>>> total, so the other 8% is consumed by the objects in between.
>>> org.apache.cocoon.util.BufferedOutputStream
>>> secureOutputStream of  
>>> org.apache.cocoon.environment.http.HttpEnvironment
>>> env of  
>>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector 
>>> redirector of  
>>> org.apache.cocoon.components.flow.java.ContinuationContext
>>
>> What I was so much concerned about here was the fact of storing the 
>> whole environment in the continuation, especially since we have this 
>> non-flushing BufferedOutputStream at the end. Is there any point in 
>> storing the environment? Do we get anything useful out of it after 
>> continueing the continuation?
> 
> What do you mean by "environment" ...it's not like the whole jvm is 
> stored but only the flow. External resources should be injected (vs 
> stored) as much as possible.

Just have a look at the quote from the original. It gives the object 
relationships in the memory. BufferedOutputStream takes 50% and is hold 
in HttpEnvironment which is hold in TreeProcessorRedirector which is 
hold in ContinuationContext. I wondered why it is there.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.03.2008 04:39, Torsten Curdt wrote:

>>> Sure, here is the hierarchy from bottom to top.  At this point, I ran 
>>> the test for about five
>>> minutes (running longer would increase the percentage) and the 
>>> retained size of the one
>>> ContinuationsManagerImpl object is 58% of the total.  The 
>>> BufferedOutputStream is 50% of the
>>> total, so the other 8% is consumed by the objects in between.
>>> org.apache.cocoon.util.BufferedOutputStream
>>> secureOutputStream of  
>>> org.apache.cocoon.environment.http.HttpEnvironment
>>> env of  
>>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector 
>>> redirector of  
>>> org.apache.cocoon.components.flow.java.ContinuationContext
>>
>> What I was so much concerned about here was the fact of storing the 
>> whole environment in the continuation, especially since we have this 
>> non-flushing BufferedOutputStream at the end. Is there any point in 
>> storing the environment? Do we get anything useful out of it after 
>> continueing the continuation?
> 
> What do you mean by "environment" ...it's not like the whole jvm is 
> stored but only the flow. External resources should be injected (vs 
> stored) as much as possible.

Just have a look at the quote from the original. It gives the object 
relationships in the memory. BufferedOutputStream takes 50% and is hold 
in HttpEnvironment which is hold in TreeProcessorRedirector which is 
hold in ContinuationContext. I wondered why it is there.

Joerg

Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 05:31, Joerg Heinicke wrote:
> On 18.03.2008 03:07, footh wrote:
>
>> Sure, here is the hierarchy from bottom to top.  At this point, I  
>> ran the test for about five
>> minutes (running longer would increase the percentage) and the  
>> retained size of the one
>> ContinuationsManagerImpl object is 58% of the total.  The  
>> BufferedOutputStream is 50% of the
>> total, so the other 8% is consumed by the objects in between.
>> org.apache.cocoon.util.BufferedOutputStream
>> secureOutputStream of   
>> org.apache.cocoon.environment.http.HttpEnvironment
>> env of   
>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor 
>> $TreeProcessorRedirector
>> redirector of   
>> org.apache.cocoon.components.flow.java.ContinuationContext
>
> What I was so much concerned about here was the fact of storing the  
> whole environment in the continuation, especially since we have this  
> non-flushing BufferedOutputStream at the end. Is there any point in  
> storing the environment? Do we get anything useful out of it after  
> continueing the continuation?

What do you mean by "environment" ...it's not like the whole jvm is  
stored but only the flow. External resources should be injected (vs  
stored) as much as possible.

cheers
--
Torsten

Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
footh <footh <at> yahoo.com> writes:

> Ok, I applied all the changes in order.  Since some changes affect the same
> class, I'm assuming the latter change contains any changes from a previous
> revision.

I don't know how exactly you mean this, but one *change* does definitely not
include the former changes since it is always a diff against the latest
revision. If I were you I would just grab the latest revisions of the mentioned
files. Those ones also have all the former changes. There should be no
incompatibility introduced between 2.1.10 and latest code in the 2.1 SVN branch.

> I'm getting this error when building:
> 
> \src\java\org\apache\cocoon\components
> \flow\ContinuationsManagerImpl.java:538: clone() has protected access in
> java.lang.Object
>             clonedRootWebContinuations.add(rootContinuation.clone());
> 
> Did I mess up applying the changes?  Have you successfully built the revised
> version?

That's more or less my fault. I made another commit where I did not separate
clearly the issues and part of the fixes you are actually interested in got into
that commit. It's http://svn.apache.org/viewvc?rev=643294&view=rev, but what you
actually only need from this commit are part of the changes to WebContinuation:
add Cloneable to its implements list, get the two methods toString() and
clone(). Leave the rest just as it is if you are not interested in Flowscript.

Hope this helps,

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Ok, I applied all the changes in order.  Since some changes affect the same class, I'm assuming
the latter change contains any changes from a previous revision.

I'm getting this error when building:

\src\java\org\apache\cocoon\components
\flow\ContinuationsManagerImpl.java:538: clone() has protected access in java.lang.Object
            clonedRootWebContinuations.add(rootContinuation.clone());

Did I mess up applying the changes?  Have you successfully built the revised version?

Concerning your other question, I've waited as long as 30 minutes or more to see if the memory
would free up but it did not.

--- Joerg Heinicke <jo...@gmx.de> wrote:

> On 02.04.2008 12:24, footh wrote:
> 
> > Yes, I only applied 642694 as it was the only the link in your previous post.  I altered the
> three
> > files:
> > 
> > AbstractContinuable.java
> > Continuation.java
> > ContinuationContext.java
> > 
> > to the files in the links and rebuilt Cocoon, only switching out the javaflow library on my
> test
> > instance.  Nothing else changed in my test environment from the calculable results I got last
> > time.  I'm using YourKit profiler and the Apache JMeter testing tool with debugging turned
> off.
> > 
> > Should I have applied all the fixes you described below?
> 
> 642694 was supposed to give you the first improvements by limiting the 
> continuation's memory footprint. 642756 is a better fix for the same 
> problem cleaning up even more. In the latter revision I reverted the 
> changes to AbstractContinuable and ContinuationContext and made new 
> changes to Continuation and JavaInterpreter (as outlined below in more 
> details).
> 
> The other fixes are not necessary and I don't know if you would see 
> improvements from them. BUT your version of the ContinuationsManagerImpl 
> has serious threading issues. Depending on your tests it might happen 
> that you shoot the "expired continuations clean up" thread by creating 
> new continuation at the same time (leads to 
> ConcurrentModificationException). Again for more details read below.
> 
> COCOON-2109 solves another problem with cleaning up the expired 
> continuations. If this one has effects depends on your actual tests. And 
> again for more details read below :)
> 
> The best is to have all fixes, yes. Otherwise a certain test run could 
> just have "bad luck" and does not show the improvements. Also do you 
> wait exactly 10 minutes? That's only the time when the first 
> continuations get invalidated, so the clean up thread had hardly any 
> chance to jump in. Do you have better results waiting let's say 15 or 20 
> minutes?
> 
> Joerg
> 
> > --- Joerg Heinicke <jo...@gmx.de> wrote:
> > 
> >> On 01.04.2008 18:52, footh wrote:
> >>
> >>> Just ran a very simple test using the changes from revision 642694 and had unusual results.
> >>>
> >>> Byte arrays, and consequently the BufferedOutputStream still took up large amounts of
> retained
> >>> space in the total memory usage.  So, this didn't change.
> >>>
> >>> However, the memory did not clean up neatly like it did before...after about 10 minutes. 
> >> Before,
> >>> I would do, say 1000 samples, and total Tomcat memory would balloon to a point.  Then I'd
> wait
> >> 10
> >>> minutes and would observe the byte array data cleaning up in the profiler with total Tomcat
> >> memory
> >>> staying the same.  After that, I'd run another 1000 samples and the total Tomcat memory
> would
> >> not
> >>> increase again until hitting around the 1000th sample and the cycle would repeat.
> >>>
> >>> With these new changes, the memory cleaned up a little bit, but not nearly as much as
> before. 
> >> And
> >>> the total memory would start increasing before I hit the control sample size.
> >>>
> >>> The BufferedOutputStream path appears to be the same as well - flowing up to
> >>> ContinuationsManagerImpl.  Perhaps I'm doing something wrong?  I did make this changes to
> >> version
> >>> 2.1.10 NOT 2.1.11 since I haven't upgraded my site to the new version yet.
> >> That's no good news :( And I can't see how this should be possible.
> >>
> >> Which changes exactly did you apply? Only rev 642694 [1]? The actual two 
> >> files changed are ContinuationContext (added method onSuspend()) and 
> >> AbstractContinuable (calling context.onSuspend() right before 
> >> Continuation.suspend()). The method only nulls out some values, so I 
> >> can't see how this should have worsen the situation. Both files had not 
> >> changed between 2.1.10 and 2.1.11, so this can neither be a reason.
> >>
> >> Second, this was only the first approach. After Torsten's review I did a 
> >> more "brave" approach setting the complete context to null before the 
> >> continuation gets suspended [2]. Here I reverted the above 2 changes to 
> >> AbstractContiuable and ContinuationsContext. The fix went into 
> >> Continuation (storing functionName and setting context to null in 
> >> suspend()) and JavaInterpreter (instantiating Continuation with 
> >> functionName and retrieving it from there later on). Again I can't see 
> >> how this should have worsen the situation. Both files had again not 
> >> changed since 2.1.10.
> >>
> >> Then in order to fix COCOON-2109 [3] I applied another fix [4]. If that 
> >> one helps you at all pretty much depends on whether you access old 
> >> continuations or not (when using a wizard you not only go forward along 
> >> the expected path (page 1, page 2, etc.) but also go back).
> >>
> >> The last important fix is for synchronization issues in 
> >> ContinuationsManagerImpl [5]. This definitely has some impact, it's 
> >> usually unlikely that fixing synchronization improves performance. If 
> >> you don't have this fix I can imagine that the situation is as bad as 
> >> you describe it for the following reasons: If something creates a new 
> >> continuation while the clean up thread for removing expired 
> >> continuations is active it kicks the latter one with a 
> >> ConcurrentModificationException - and the clean up just stops. This 
> >> would mean though that it was just bad luck in your new test.
> >>
> >> I don't know how exactly you profiled your system. You should definitely 
> >> NOT run on debug log level. I fixed the synchronization issues in favor 
> >> of the debug log level: There are no longer two sets maintained but the 
> >> second set (which was for debugging purposes only) gets recreated "on 
> >> demand", i.e. debug log level, which locks the manager for that time. 
> >> But it should improve the overall situation though.
> >>
> >> Joerg
> >>
> >> [1] http://svn.apache.org/viewvc?view=rev&revision=642694
> >> [2] http://svn.apache.org/viewvc?view=rev&revision=642756
> >> [3] https://issues.apache.org/jira/browse/COCOON-2109
> >> [4] http://svn.apache.org/viewvc?view=rev&revision=642843
> >> [5] http://svn.apache.org/viewvc?view=rev&revision=643295
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 02.04.2008 12:24, footh wrote:

> Yes, I only applied 642694 as it was the only the link in your previous post.  I altered the three
> files:
> 
> AbstractContinuable.java
> Continuation.java
> ContinuationContext.java
> 
> to the files in the links and rebuilt Cocoon, only switching out the javaflow library on my test
> instance.  Nothing else changed in my test environment from the calculable results I got last
> time.  I'm using YourKit profiler and the Apache JMeter testing tool with debugging turned off.
> 
> Should I have applied all the fixes you described below?

642694 was supposed to give you the first improvements by limiting the 
continuation's memory footprint. 642756 is a better fix for the same 
problem cleaning up even more. In the latter revision I reverted the 
changes to AbstractContinuable and ContinuationContext and made new 
changes to Continuation and JavaInterpreter (as outlined below in more 
details).

The other fixes are not necessary and I don't know if you would see 
improvements from them. BUT your version of the ContinuationsManagerImpl 
has serious threading issues. Depending on your tests it might happen 
that you shoot the "expired continuations clean up" thread by creating 
new continuation at the same time (leads to 
ConcurrentModificationException). Again for more details read below.

COCOON-2109 solves another problem with cleaning up the expired 
continuations. If this one has effects depends on your actual tests. And 
again for more details read below :)

The best is to have all fixes, yes. Otherwise a certain test run could 
just have "bad luck" and does not show the improvements. Also do you 
wait exactly 10 minutes? That's only the time when the first 
continuations get invalidated, so the clean up thread had hardly any 
chance to jump in. Do you have better results waiting let's say 15 or 20 
minutes?

Joerg

> --- Joerg Heinicke <jo...@gmx.de> wrote:
> 
>> On 01.04.2008 18:52, footh wrote:
>>
>>> Just ran a very simple test using the changes from revision 642694 and had unusual results.
>>>
>>> Byte arrays, and consequently the BufferedOutputStream still took up large amounts of retained
>>> space in the total memory usage.  So, this didn't change.
>>>
>>> However, the memory did not clean up neatly like it did before...after about 10 minutes. 
>> Before,
>>> I would do, say 1000 samples, and total Tomcat memory would balloon to a point.  Then I'd wait
>> 10
>>> minutes and would observe the byte array data cleaning up in the profiler with total Tomcat
>> memory
>>> staying the same.  After that, I'd run another 1000 samples and the total Tomcat memory would
>> not
>>> increase again until hitting around the 1000th sample and the cycle would repeat.
>>>
>>> With these new changes, the memory cleaned up a little bit, but not nearly as much as before. 
>> And
>>> the total memory would start increasing before I hit the control sample size.
>>>
>>> The BufferedOutputStream path appears to be the same as well - flowing up to
>>> ContinuationsManagerImpl.  Perhaps I'm doing something wrong?  I did make this changes to
>> version
>>> 2.1.10 NOT 2.1.11 since I haven't upgraded my site to the new version yet.
>> That's no good news :( And I can't see how this should be possible.
>>
>> Which changes exactly did you apply? Only rev 642694 [1]? The actual two 
>> files changed are ContinuationContext (added method onSuspend()) and 
>> AbstractContinuable (calling context.onSuspend() right before 
>> Continuation.suspend()). The method only nulls out some values, so I 
>> can't see how this should have worsen the situation. Both files had not 
>> changed between 2.1.10 and 2.1.11, so this can neither be a reason.
>>
>> Second, this was only the first approach. After Torsten's review I did a 
>> more "brave" approach setting the complete context to null before the 
>> continuation gets suspended [2]. Here I reverted the above 2 changes to 
>> AbstractContiuable and ContinuationsContext. The fix went into 
>> Continuation (storing functionName and setting context to null in 
>> suspend()) and JavaInterpreter (instantiating Continuation with 
>> functionName and retrieving it from there later on). Again I can't see 
>> how this should have worsen the situation. Both files had again not 
>> changed since 2.1.10.
>>
>> Then in order to fix COCOON-2109 [3] I applied another fix [4]. If that 
>> one helps you at all pretty much depends on whether you access old 
>> continuations or not (when using a wizard you not only go forward along 
>> the expected path (page 1, page 2, etc.) but also go back).
>>
>> The last important fix is for synchronization issues in 
>> ContinuationsManagerImpl [5]. This definitely has some impact, it's 
>> usually unlikely that fixing synchronization improves performance. If 
>> you don't have this fix I can imagine that the situation is as bad as 
>> you describe it for the following reasons: If something creates a new 
>> continuation while the clean up thread for removing expired 
>> continuations is active it kicks the latter one with a 
>> ConcurrentModificationException - and the clean up just stops. This 
>> would mean though that it was just bad luck in your new test.
>>
>> I don't know how exactly you profiled your system. You should definitely 
>> NOT run on debug log level. I fixed the synchronization issues in favor 
>> of the debug log level: There are no longer two sets maintained but the 
>> second set (which was for debugging purposes only) gets recreated "on 
>> demand", i.e. debug log level, which locks the manager for that time. 
>> But it should improve the overall situation though.
>>
>> Joerg
>>
>> [1] http://svn.apache.org/viewvc?view=rev&revision=642694
>> [2] http://svn.apache.org/viewvc?view=rev&revision=642756
>> [3] https://issues.apache.org/jira/browse/COCOON-2109
>> [4] http://svn.apache.org/viewvc?view=rev&revision=642843
>> [5] http://svn.apache.org/viewvc?view=rev&revision=643295

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Yes, I only applied 642694 as it was the only the link in your previous post.  I altered the three
files:

AbstractContinuable.java
Continuation.java
ContinuationContext.java

to the files in the links and rebuilt Cocoon, only switching out the javaflow library on my test
instance.  Nothing else changed in my test environment from the calculable results I got last
time.  I'm using YourKit profiler and the Apache JMeter testing tool with debugging turned off.

Should I have applied all the fixes you described below?

--- Joerg Heinicke <jo...@gmx.de> wrote:

> On 01.04.2008 18:52, footh wrote:
> 
> > Just ran a very simple test using the changes from revision 642694 and had unusual results.
> > 
> > Byte arrays, and consequently the BufferedOutputStream still took up large amounts of retained
> > space in the total memory usage.  So, this didn't change.
> > 
> > However, the memory did not clean up neatly like it did before...after about 10 minutes. 
> Before,
> > I would do, say 1000 samples, and total Tomcat memory would balloon to a point.  Then I'd wait
> 10
> > minutes and would observe the byte array data cleaning up in the profiler with total Tomcat
> memory
> > staying the same.  After that, I'd run another 1000 samples and the total Tomcat memory would
> not
> > increase again until hitting around the 1000th sample and the cycle would repeat.
> > 
> > With these new changes, the memory cleaned up a little bit, but not nearly as much as before. 
> And
> > the total memory would start increasing before I hit the control sample size.
> > 
> > The BufferedOutputStream path appears to be the same as well - flowing up to
> > ContinuationsManagerImpl.  Perhaps I'm doing something wrong?  I did make this changes to
> version
> > 2.1.10 NOT 2.1.11 since I haven't upgraded my site to the new version yet.
> 
> That's no good news :( And I can't see how this should be possible.
> 
> Which changes exactly did you apply? Only rev 642694 [1]? The actual two 
> files changed are ContinuationContext (added method onSuspend()) and 
> AbstractContinuable (calling context.onSuspend() right before 
> Continuation.suspend()). The method only nulls out some values, so I 
> can't see how this should have worsen the situation. Both files had not 
> changed between 2.1.10 and 2.1.11, so this can neither be a reason.
> 
> Second, this was only the first approach. After Torsten's review I did a 
> more "brave" approach setting the complete context to null before the 
> continuation gets suspended [2]. Here I reverted the above 2 changes to 
> AbstractContiuable and ContinuationsContext. The fix went into 
> Continuation (storing functionName and setting context to null in 
> suspend()) and JavaInterpreter (instantiating Continuation with 
> functionName and retrieving it from there later on). Again I can't see 
> how this should have worsen the situation. Both files had again not 
> changed since 2.1.10.
> 
> Then in order to fix COCOON-2109 [3] I applied another fix [4]. If that 
> one helps you at all pretty much depends on whether you access old 
> continuations or not (when using a wizard you not only go forward along 
> the expected path (page 1, page 2, etc.) but also go back).
> 
> The last important fix is for synchronization issues in 
> ContinuationsManagerImpl [5]. This definitely has some impact, it's 
> usually unlikely that fixing synchronization improves performance. If 
> you don't have this fix I can imagine that the situation is as bad as 
> you describe it for the following reasons: If something creates a new 
> continuation while the clean up thread for removing expired 
> continuations is active it kicks the latter one with a 
> ConcurrentModificationException - and the clean up just stops. This 
> would mean though that it was just bad luck in your new test.
> 
> I don't know how exactly you profiled your system. You should definitely 
> NOT run on debug log level. I fixed the synchronization issues in favor 
> of the debug log level: There are no longer two sets maintained but the 
> second set (which was for debugging purposes only) gets recreated "on 
> demand", i.e. debug log level, which locks the manager for that time. 
> But it should improve the overall situation though.
> 
> Joerg
> 
> [1] http://svn.apache.org/viewvc?view=rev&revision=642694
> [2] http://svn.apache.org/viewvc?view=rev&revision=642756
> [3] https://issues.apache.org/jira/browse/COCOON-2109
> [4] http://svn.apache.org/viewvc?view=rev&revision=642843
> [5] http://svn.apache.org/viewvc?view=rev&revision=643295
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 01.04.2008 18:52, footh wrote:

> Just ran a very simple test using the changes from revision 642694 and had unusual results.
> 
> Byte arrays, and consequently the BufferedOutputStream still took up large amounts of retained
> space in the total memory usage.  So, this didn't change.
> 
> However, the memory did not clean up neatly like it did before...after about 10 minutes.  Before,
> I would do, say 1000 samples, and total Tomcat memory would balloon to a point.  Then I'd wait 10
> minutes and would observe the byte array data cleaning up in the profiler with total Tomcat memory
> staying the same.  After that, I'd run another 1000 samples and the total Tomcat memory would not
> increase again until hitting around the 1000th sample and the cycle would repeat.
> 
> With these new changes, the memory cleaned up a little bit, but not nearly as much as before.  And
> the total memory would start increasing before I hit the control sample size.
> 
> The BufferedOutputStream path appears to be the same as well - flowing up to
> ContinuationsManagerImpl.  Perhaps I'm doing something wrong?  I did make this changes to version
> 2.1.10 NOT 2.1.11 since I haven't upgraded my site to the new version yet.

That's no good news :( And I can't see how this should be possible.

Which changes exactly did you apply? Only rev 642694 [1]? The actual two 
files changed are ContinuationContext (added method onSuspend()) and 
AbstractContinuable (calling context.onSuspend() right before 
Continuation.suspend()). The method only nulls out some values, so I 
can't see how this should have worsen the situation. Both files had not 
changed between 2.1.10 and 2.1.11, so this can neither be a reason.

Second, this was only the first approach. After Torsten's review I did a 
more "brave" approach setting the complete context to null before the 
continuation gets suspended [2]. Here I reverted the above 2 changes to 
AbstractContiuable and ContinuationsContext. The fix went into 
Continuation (storing functionName and setting context to null in 
suspend()) and JavaInterpreter (instantiating Continuation with 
functionName and retrieving it from there later on). Again I can't see 
how this should have worsen the situation. Both files had again not 
changed since 2.1.10.

Then in order to fix COCOON-2109 [3] I applied another fix [4]. If that 
one helps you at all pretty much depends on whether you access old 
continuations or not (when using a wizard you not only go forward along 
the expected path (page 1, page 2, etc.) but also go back).

The last important fix is for synchronization issues in 
ContinuationsManagerImpl [5]. This definitely has some impact, it's 
usually unlikely that fixing synchronization improves performance. If 
you don't have this fix I can imagine that the situation is as bad as 
you describe it for the following reasons: If something creates a new 
continuation while the clean up thread for removing expired 
continuations is active it kicks the latter one with a 
ConcurrentModificationException - and the clean up just stops. This 
would mean though that it was just bad luck in your new test.

I don't know how exactly you profiled your system. You should definitely 
NOT run on debug log level. I fixed the synchronization issues in favor 
of the debug log level: There are no longer two sets maintained but the 
second set (which was for debugging purposes only) gets recreated "on 
demand", i.e. debug log level, which locks the manager for that time. 
But it should improve the overall situation though.

Joerg

[1] http://svn.apache.org/viewvc?view=rev&revision=642694
[2] http://svn.apache.org/viewvc?view=rev&revision=642756
[3] https://issues.apache.org/jira/browse/COCOON-2109
[4] http://svn.apache.org/viewvc?view=rev&revision=642843
[5] http://svn.apache.org/viewvc?view=rev&revision=643295

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Just ran a very simple test using the changes from revision 642694 and had unusual results.

Byte arrays, and consequently the BufferedOutputStream still took up large amounts of retained
space in the total memory usage.  So, this didn't change.

However, the memory did not clean up neatly like it did before...after about 10 minutes.  Before,
I would do, say 1000 samples, and total Tomcat memory would balloon to a point.  Then I'd wait 10
minutes and would observe the byte array data cleaning up in the profiler with total Tomcat memory
staying the same.  After that, I'd run another 1000 samples and the total Tomcat memory would not
increase again until hitting around the 1000th sample and the cycle would repeat.

With these new changes, the memory cleaned up a little bit, but not nearly as much as before.  And
the total memory would start increasing before I hit the control sample size.

The BufferedOutputStream path appears to be the same as well - flowing up to
ContinuationsManagerImpl.  Perhaps I'm doing something wrong?  I did make this changes to version
2.1.10 NOT 2.1.11 since I haven't upgraded my site to the new version yet.



--- footh <fo...@yahoo.com> wrote:

> Thanks Joerg...I was actually lurking this thread on the dev list to check on the progress.
> 
> I'll check out the new code and report back here with the results.
> 
> 
> --- Joerg Heinicke <jo...@gmx.de> wrote:
> 
> > On 27.03.2008 00:31, Joerg Heinicke wrote:
> > 
> > >> Sure, here is the hierarchy from bottom to top.  At this point, I ran 
> > >> the test for about five
> > >> minutes (running longer would increase the percentage) and the 
> > >> retained size of the one
> > >> ContinuationsManagerImpl object is 58% of the total.  The 
> > >> BufferedOutputStream is 50% of the
> > >> total, so the other 8% is consumed by the objects in between.
> > >>
> > >> org.apache.cocoon.util.BufferedOutputStream
> > >> secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
> > >> env of  
> > >> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector 
> > >>
> > >> redirector of  org.apache.cocoon.components.flow.java.ContinuationContext
> > > 
> > > What I was so much concerned about here was the fact of storing the 
> > > whole environment in the continuation, especially since we have this 
> > > non-flushing BufferedOutputStream at the end. Is there any point in 
> > > storing the environment? Do we get anything useful out of it after 
> > > continueing the continuation?
> > 
> > I committed a fix [1] that limits the data that is stored with the 
> > ContinuationContext which at least removes the redirector and so the 
> > BufferedOutputStream instances from the Continuation's memory footprint. 
> > This should give you a big improvement if the BufferedOutputStream took 
> > 50% of the memory for you.
> > 
> > Joerg
> > 
> > [1] http://svn.apache.org/viewvc?view=rev&revision=642694
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> 
> 
> 
>       ____________________________________________________________________________________
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. 
> 
> http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Thanks Joerg...I was actually lurking this thread on the dev list to check on the progress.

I'll check out the new code and report back here with the results.


--- Joerg Heinicke <jo...@gmx.de> wrote:

> On 27.03.2008 00:31, Joerg Heinicke wrote:
> 
> >> Sure, here is the hierarchy from bottom to top.  At this point, I ran 
> >> the test for about five
> >> minutes (running longer would increase the percentage) and the 
> >> retained size of the one
> >> ContinuationsManagerImpl object is 58% of the total.  The 
> >> BufferedOutputStream is 50% of the
> >> total, so the other 8% is consumed by the objects in between.
> >>
> >> org.apache.cocoon.util.BufferedOutputStream
> >> secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
> >> env of  
> >> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector 
> >>
> >> redirector of  org.apache.cocoon.components.flow.java.ContinuationContext
> > 
> > What I was so much concerned about here was the fact of storing the 
> > whole environment in the continuation, especially since we have this 
> > non-flushing BufferedOutputStream at the end. Is there any point in 
> > storing the environment? Do we get anything useful out of it after 
> > continueing the continuation?
> 
> I committed a fix [1] that limits the data that is stored with the 
> ContinuationContext which at least removes the redirector and so the 
> BufferedOutputStream instances from the Continuation's memory footprint. 
> This should give you a big improvement if the BufferedOutputStream took 
> 50% of the memory for you.
> 
> Joerg
> 
> [1] http://svn.apache.org/viewvc?view=rev&revision=642694
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.03.2008 00:31, Joerg Heinicke wrote:

>> Sure, here is the hierarchy from bottom to top.  At this point, I ran 
>> the test for about five
>> minutes (running longer would increase the percentage) and the 
>> retained size of the one
>> ContinuationsManagerImpl object is 58% of the total.  The 
>> BufferedOutputStream is 50% of the
>> total, so the other 8% is consumed by the objects in between.
>>
>> org.apache.cocoon.util.BufferedOutputStream
>> secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
>> env of  
>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector 
>>
>> redirector of  org.apache.cocoon.components.flow.java.ContinuationContext
> 
> What I was so much concerned about here was the fact of storing the 
> whole environment in the continuation, especially since we have this 
> non-flushing BufferedOutputStream at the end. Is there any point in 
> storing the environment? Do we get anything useful out of it after 
> continueing the continuation?

I committed a fix [1] that limits the data that is stored with the 
ContinuationContext which at least removes the redirector and so the 
BufferedOutputStream instances from the Continuation's memory footprint. 
This should give you a big improvement if the BufferedOutputStream took 
50% of the memory for you.

Joerg

[1] http://svn.apache.org/viewvc?view=rev&revision=642694

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
On Mar 27, 2008, at 05:31, Joerg Heinicke wrote:
> On 18.03.2008 03:07, footh wrote:
>
>> Sure, here is the hierarchy from bottom to top.  At this point, I  
>> ran the test for about five
>> minutes (running longer would increase the percentage) and the  
>> retained size of the one
>> ContinuationsManagerImpl object is 58% of the total.  The  
>> BufferedOutputStream is 50% of the
>> total, so the other 8% is consumed by the objects in between.
>> org.apache.cocoon.util.BufferedOutputStream
>> secureOutputStream of   
>> org.apache.cocoon.environment.http.HttpEnvironment
>> env of   
>> org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor 
>> $TreeProcessorRedirector
>> redirector of   
>> org.apache.cocoon.components.flow.java.ContinuationContext
>
> What I was so much concerned about here was the fact of storing the  
> whole environment in the continuation, especially since we have this  
> non-flushing BufferedOutputStream at the end. Is there any point in  
> storing the environment? Do we get anything useful out of it after  
> continueing the continuation?

What do you mean by "environment" ...it's not like the whole jvm is  
stored but only the flow. External resources should be injected (vs  
stored) as much as possible.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 18.03.2008 03:07, footh wrote:

> Sure, here is the hierarchy from bottom to top.  At this point, I ran the test for about five
> minutes (running longer would increase the percentage) and the retained size of the one
> ContinuationsManagerImpl object is 58% of the total.  The BufferedOutputStream is 50% of the
> total, so the other 8% is consumed by the objects in between.
> 
> org.apache.cocoon.util.BufferedOutputStream
> secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
> env of  org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector
> redirector of  org.apache.cocoon.components.flow.java.ContinuationContext

What I was so much concerned about here was the fact of storing the 
whole environment in the continuation, especially since we have this 
non-flushing BufferedOutputStream at the end. Is there any point in 
storing the environment? Do we get anything useful out of it after 
continueing the continuation?

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 18.03.2008 03:07, footh wrote:

> Sure, here is the hierarchy from bottom to top.  At this point, I ran the test for about five
> minutes (running longer would increase the percentage) and the retained size of the one
> ContinuationsManagerImpl object is 58% of the total.  The BufferedOutputStream is 50% of the
> total, so the other 8% is consumed by the objects in between.
> 
> org.apache.cocoon.util.BufferedOutputStream
> secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
> env of  org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector
> redirector of  org.apache.cocoon.components.flow.java.ContinuationContext

What I was so much concerned about here was the fact of storing the 
whole environment in the continuation, especially since we have this 
non-flushing BufferedOutputStream at the end. Is there any point in 
storing the environment? Do we get anything useful out of it after 
continueing the continuation?

Joerg

Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Sure, here is the hierarchy from bottom to top.  At this point, I ran the test for about five
minutes (running longer would increase the percentage) and the retained size of the one
ContinuationsManagerImpl object is 58% of the total.  The BufferedOutputStream is 50% of the
total, so the other 8% is consumed by the objects in between.

org.apache.cocoon.util.BufferedOutputStream
secureOutputStream of  org.apache.cocoon.environment.http.HttpEnvironment
env of  org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreeProcessorRedirector
redirector of  org.apache.cocoon.components.flow.java.ContinuationContext
context of  org.apache.cocoon.components.flow.java.Continuation
continuation of  org.apache.cocoon.components.flow.WebContinuation
key of  java.util.TreeMap$Entry
root of  java.util.TreeMap
m of  java.util.TreeSet
ss of  java.util.Collections$SynchronizedSortedSet
expirations of  org.apache.cocoon.components.flow.ContinuationsManagerImpl
this$0 of  org.apache.cocoon.components.flow.ContinuationsManagerImpl$1
m_command of  org.apache.cocoon.components.thread.DefaultRunnableManager$ExecutionInfo
key of  java.util.TreeMap$Entry
root of  java.util.TreeMap
m of  java.util.TreeSet [Stack Local]


--- Joerg Heinicke <jo...@gmx.de> wrote:

> On 17.03.2008 20:50, footh wrote:
> > Thanks for all the replies.  I did some more digging
> > into the profiling data.  It turns out that the
> > ContinuationsManagerImpl is at the top of the object
> > path of the byte arrays where 
> > org.apache.cocoon.environment.util.BufferedOutputStream
> > is the actual parent of the arrays.
> 
> Wait, does the ContinuationsManagerImpl store the complete pipeline 
> output? That's the only usage of Cocoon's BufferedOutputStream. Can you 
> show the object hierarchy?
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Joerg Heinicke <jo...@gmx.de>.
On 17.03.2008 20:50, footh wrote:
> Thanks for all the replies.  I did some more digging
> into the profiling data.  It turns out that the
> ContinuationsManagerImpl is at the top of the object
> path of the byte arrays where 
> org.apache.cocoon.environment.util.BufferedOutputStream
> is the actual parent of the arrays.

Wait, does the ContinuationsManagerImpl store the complete pipeline 
output? That's the only usage of Cocoon's BufferedOutputStream. Can you 
show the object hierarchy?

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by footh <fo...@yahoo.com>.
Thanks for all the replies.  I did some more digging
into the profiling data.  It turns out that the
ContinuationsManagerImpl is at the top of the object
path of the byte arrays where 
org.apache.cocoon.environment.util.BufferedOutputStream
is the actual parent of the arrays.

Looking down the path, I can see the TreeSet and
SortedSet that is mentioned in cocoon-2109.  I would
say this issue is a likely cause for the memory
ballooning.

The load tester is simulating 5 users staggered 10
seconds apart and only hitting a couple very simple
pages.  Yet within 15 minutes, the Tomcat memory use
approaches 1GB.  After stopping the load tester and
examining the memory, I did notice in the profiler
that the byte arrays eventually cleaned up.  However,
looking at the Task Manger (using Windows), Tomcat was
still holding the full amount of memory from when I
stopped the load tester, ie. it didn't go down when
the  byte arrays cleaned up.

I suppose the next step is to try the patch provided
in  2109.  Any other suggestions?






--- Antonio Gallardo <ag...@agssa.net> wrote:

> Hi,
> 
> Could it be this
> https://issues.apache.org/jira/browse/COCOON-2109 ?
> 
> Best Regards,
> 
> Antonio Gallardo.
> 
> Torsten Curdt escribió:
> > I would have a look into the continuation
> management infrastructure in 
> > cocoon and then start digging from there. I am
> wondering if limiting 
> > and expiring the continuations works well enough
> for you. (It was on 
> > my TODO to improve this part in cocoon - but I
> never got around to it 
> > and moved on)
> >
> > cheers
> > -- 
> > Torsten
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Antonio Gallardo <ag...@agssa.net>.
Hi,

Could it be this https://issues.apache.org/jira/browse/COCOON-2109 ?

Best Regards,

Antonio Gallardo.

Torsten Curdt escribió:
> I would have a look into the continuation management infrastructure in 
> cocoon and then start digging from there. I am wondering if limiting 
> and expiring the continuations works well enough for you. (It was on 
> my TODO to improve this part in cocoon - but I never got around to it 
> and moved on)
>
> cheers
> -- 
> Torsten


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Javaflow - major memory issue

Posted by Torsten Curdt <tc...@apache.org>.
Hm... not sure - javaflow instrumentation should be fairly  
lightweight and this might be a simple bug that turns out bad ...but  
frankly the huge amount of byte arrays doesn't ring a bell yet. I  
would need to look into the javaflow code.

As a general note though: Keep in mind that any continuation based  
webapp will have an ever increasing amount of memory unless you add  
some limitations and clean up code. Every connection means a new  
continuation (more or less) and some memory that needs to be kept on  
the server side. This can only remotely scale if you limit the total  
number of continuations ....similar like it is for sessions.

I would have a look into the continuation management infrastructure  
in cocoon and then start digging from there. I am wondering if  
limiting and expiring the continuations works well enough for you.  
(It was on my TODO to improve this part in cocoon - but I never got  
around to it and moved on)

cheers
--
Torsten

On 17.03.2008, at 18:57, footh wrote:

> I've been trying to track down a memory problem with
> my Cocoon application for a long time now.  After a
> period of time, maybe a week or two, the application
> would die with an OutOfMemory error.  I've tried
> increasing the VM memory for the servlet container
> (using Tomcat 5.5) and switching to the JRockIt VM
> (delayed the OOM error, but still got it).  Nothing
> seemed to work.  Finally, I put my app through a
> series of tests to narrow down the culprit.
>
> After stripping layer upon layer of functionality, I
> finally discovered that Javaflow seems to be the
> problem.  I started with a bare-bones site and drilled
> it with a load tester.  The Tomcat memory use would
> remain stable.  I added more features and still no
> problem.  Then, I threw in the Javaflow, and the
> memory skyrocketed.  To make sure it wasn't something
> I was doing in the Javaflow, I created the simplest
> flow possible - a one-line "sendPage(uri)" call.
> Still the memory would blow up.
>
> As a final test, to make sure it wasn't something I
> was doing wrong, I ran the test on the sample Javaflow
> application that comes with Cocoon.  I used the
> calculator sample and just hit the first page.  Once
> again, the memory kept rising.  If I took that page
> off the test, there were no memory issues.
>
> My next step was to profile the memory use to see if I
> could find out where the memory was being allocated.
> It turns out that byte array data comprised the
> majority of the allocated memory. After running a test
> for 20 minutes or so, the Tomcat memory use was around
> 1GB with byte array data responsible for 82% of the
> total.
>
> Now, I realize that Javaflow is considered an unstable
> block.  I'm wondering if anyone else using this
> feature has had similar problems?  Any idea why this
> might be occurring with Javaflow?  Does flowscript
> have similar problems?
>
> I now need to reconsider the MVC architecture of my
> application which has been in production for several
> years.  I do a lot of stuff in the Javaflow.  I'm open
> to any suggestions!
>
> Regards,
>
> JF
>
>
>
>
>        
> ______________________________________________________________________ 
> ______________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http:// 
> mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org