On Tue, 22 May 2001, Rickard Öberg wrote:

> > Hash lookup is done once per jsp page - when the jsp page is first run.
> > After that, it's basically a synchronized push / pop pair on all subsequent
> > runs of the page.  In the future we can even get rid of the synch by using
> > thread local storage... one step at a time though. :)
> 
> Yup, that might improve things. Although then it depends on how
> ThreadLocal is implemented. I guess at some point deep down it has to do
> "synchronized", although I haven't checked.

It does ! :-)

But in tomcat 3.3 we do a different trick - the thread pool is maintaining
a "local storage" for each thread, and it's passing it to the worker.

The only synchronization in tomcat is in getting a thread from the thread
pool - besides that we shouldn't need anything else. 

Right now we keep the Request/Request pair - so we have a one-to-one
relation between "main" request and thread ( in other words, the request
is allways in the same thread ). Whatever attributes/notes you store in
the request will be equivalent with thread-local data, without any sync.

> Sorry, I should have been more specific. Of course object reuse can be a
> good performance optimization. I'm just saying that you gotta balance it
> with regard to modern JVM's ability to manage memory and "new" objects.
> Optimize locally in code, and let the JVM do it globally. That's just
> IMHO though, so feel free to disagree :-)

:-)

I was thinking the reverse - optimize globally, let the VM optimize
locally, but it depends on definitions... 



Costin

Reply via email to