You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Olle Hallin <ol...@hit.se> on 2009/12/08 14:08:38 UTC

Lock contention in PerthreadManagerImpl

Hi!

We are load testing our new high volume site before soft launch, and we have
noticed that we have two sources of severe lock contention.
Of 300 threads, in average 165 are waiting for one of these two locks.

One is in ZipFile (caused by  @IncudeJavaScriptLibrary("classpath:...")) and
the other is in
org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl

The ZipFile bottleneck is harmless, since we will use a CDN in production.
The second one is harder to work-around, since it is caused by
RequestGlobals.storeServletRequestResponse().

I have browsed PerthreadManagerImpl.java, and have found two cases where a
lock on "this" is requested.

In both cases the lock is requested before accessing a ThreadLocal
(ThreadLocal.get() and ThreadLocal.remove()).
Since ThreadLocal is thread-safe, external locking is uneeded.

Shall I file a JIRA issue, or have I missed something?

We use T5 5.1.0.5

Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin

Re: Lock contention in PerthreadManagerImpl

Posted by Olle Hallin <ol...@hit.se>.
JIRA https://issues.apache.org/jira/browse/TAP5-945 created

Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin



2009/12/8 Thiago H. de Paula Figueiredo <th...@gmail.com>

> Em Tue, 08 Dec 2009 11:08:38 -0200, Olle Hallin <ol...@hit.se>
> escreveu:
>
>  Hi!
>>
>
> Hi!
>
>
>  Shall I file a JIRA issue, or have I missed something?
>>
>
> I'm no expert at concurrency, but please post it so the committers with the
> required knowledge can take a look at it. ;)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Lock contention in PerthreadManagerImpl

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 08 Dec 2009 11:08:38 -0200, Olle Hallin <ol...@hit.se>  
escreveu:

> Hi!

Hi!

> Shall I file a JIRA issue, or have I missed something?

I'm no expert at concurrency, but please post it so the committers with  
the required knowledge can take a look at it. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: Lock contention in PerthreadManagerImpl

Posted by Howard Lewis Ship <hl...@gmail.com>.
I've put some comments into the issue itself.

On Tue, Dec 8, 2009 at 1:48 PM, Massimo Lusetti <ml...@gmail.com> wrote:
> On Tue, Dec 8, 2009 at 4:03 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
>
>> Unfortunately, ThreadLocal.get()/remove() was buggy and not thread
>> safe in JDK 1.5.
>
> Do you actually mean 'is' not 'was' ?
>
> Couldn't this be (re)written without using syncronized blocks?
> --
> Massimo
> http://meridio.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Lock contention in PerthreadManagerImpl

Posted by Massimo Lusetti <ml...@gmail.com>.
On Tue, Dec 8, 2009 at 4:03 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Unfortunately, ThreadLocal.get()/remove() was buggy and not thread
> safe in JDK 1.5.

Do you actually mean 'is' not 'was' ?

Couldn't this be (re)written without using syncronized blocks?
-- 
Massimo
http://meridio.blogspot.com

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


Re: Lock contention in PerthreadManagerImpl

Posted by Howard Lewis Ship <hl...@gmail.com>.
On Tue, Dec 8, 2009 at 5:08 AM, Olle Hallin <ol...@hit.se> wrote:
> Hi!
>
> We are load testing our new high volume site before soft launch, and we have
> noticed that we have two sources of severe lock contention.
> Of 300 threads, in average 165 are waiting for one of these two locks.
>
> One is in ZipFile (caused by  @IncudeJavaScriptLibrary("classpath:...")) and
> the other is in
> org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl
>
> The ZipFile bottleneck is harmless, since we will use a CDN in production.
> The second one is harder to work-around, since it is caused by
> RequestGlobals.storeServletRequestResponse().
>
> I have browsed PerthreadManagerImpl.java, and have found two cases where a
> lock on "this" is requested.
>
> In both cases the lock is requested before accessing a ThreadLocal
> (ThreadLocal.get() and ThreadLocal.remove()).
> Since ThreadLocal is thread-safe, external locking is uneeded.
>

Unfortunately, ThreadLocal.get()/remove() was buggy and not thread
safe in JDK 1.5.


> Shall I file a JIRA issue, or have I missed something?
>
> We use T5 5.1.0.5
>
> Olle Hallin
> Senior Java Developer and Architect
> olle.hallin@crisp.se
> www.crisp.se
> http://www.linkedin.com/in/ollehallin
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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