Hi Will,
Here are answers to your questions,
1. This is build against the latest in subversion
2. Yes, we built and ran against all test cases
3. I will resubmit it against later with two patches then
4. No, we turn caching on so we are reusing the same template and that's
exactly how the racing condition happens because we are reusing the same
ASTDirective and ASTSetDirective objects.

Thanks.
-- Lei


Will Glass-Husain-2 wrote:
> 
> Wow!  Fabulous.  Thanks for your hard work on this.  (and to others on
> the list for ideas as well).
> 
> A couple of questions/requests:
> * Is this built against the release of Velocity 1.5?
> * Did you run ant test and did it pass?
> * Is it easy to break the patch up into two patches, one for each
> issue?  Makes it easier to track and test.  Ideally, the patch for
> memory usage should be attached to JIRA issue 223 while the other
> patch would be a separate issue.
> 
> If this is too difficult (e.g. the changes are integrated together)
> then we can handle it as one.  But it's sometimes simpler to address
> issues separately.
> 
> It surprises me we still have synchronization issues -- there were
> fixes on this for 1.5.  Are you using the same template object in your
> parsing or are you repeatedly retrieving it with a resource loader?
> 
> WILL
> 
> Can you please attach
> 
> On 3/30/07, Lei Gu <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>
>> Hi gentleman,
>>
>> We are submitting fixes for issue number 223 and fixes for newly
>> discovered
>> multi-thread concurrency issue in Velocity Engine.
>>
>> Here is a brief summary of the problem and what we did to fix it.
>>
>>
>>
>> Issue number 223, Velocity Engine uses excessive amount of memory when a
>> large number of directives and macros are used.
>>
>> When a macro or directive is used, they are parsed at run time and the
>> same
>> macro will be parsed every time it is invoked from another macro. This
>> results in an explosion of the duplicated string images. We introduce a
>> string image pool. Before a string image is returned from
>> VelocityCharStream
>> GetImage method, we simply checks against the string image pool. If the
>> string image exists in the pool, we will return the image from the pool.
>> Otherwise we simply return the image itself. We observe a 30% memory
>> footprint reduction after this.
>>
>>
>>
>> We obtained additional savings by not adding ASTComment node to the parse
>> tree, as well as removing unused member variables in SimpleNode. However,
>> these changes are not part of submitted patch.
>>
>>
>>
>> Multi-thread concurrency issue
>>
>> During our concurrency testing, we observed NullPointer exceptions being
>> thrown when two people hit the same page at the same time for the first
>> time. Upon further investigation, it turns out that we need to
>> synchronize
>> the init method on ASTDirective, ASTSetDirective, and render method on
>> ASTSetDirective, and VelocimacroProxy.
>>
>>
>>
>> Basically, the problem is introduced as the following; when two threads
>> attempts to parse and render the same template at the same time. Thread1
>> finishes parsing first and proceeds to the render method call, while
>> thread
>> 2 is still busy parsing and will overwrite the existing parse tree that
>> is
>> being used by thread 1 for rendering purpose. Thus under certainly
>> condition
>> a NullPointer exception will be thrown.
>>
>>
>>
>> I have run through all existing test cases successfully and the memory
>> saving has been verified by YourKit profiler.
>>
>> Let me know if you have any questions.
>>
>> Thanks.
>>
>> -- Lei
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> Forio Business Simulations
> 
> Will Glass-Husain
> [EMAIL PROTECTED]
> www.forio.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Fix-for-isse-number-223-and-fixes-for-multi-thread-concurrency-issue-in-Velocity-Engine-tf3494132.html#a9767895
Sent from the Velocity - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to