You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by QM <qm...@brandxdev.net> on 2005/04/18 03:30:13 UTC

Re: Reflection for custom taglibs killing performance...

On Sun, Apr 17, 2005 at 03:44:59PM -0700, Kevin Burton wrote:
: We've had a few bottlenecks in our code that have since been removed but 
: the remaining big bottleneck is Tomcat.  The JSP engine is creating 
: compiled code that is heavily relying on reflection.
: [snip]
: 
: Is there ANY way to get Tomcat to not use reflection in this situation.

How could a tag work without reflection?
For example, if you use any of the expression-language features, how is
Tomcat supposed to react to, say,

	${request.somvar.something}

without dynamic invocation?

While I doubt you could make Tomcat not use reflection (without
completely hacking the source) perhaps you could share more details of
what you're doing... that may give the rest of us insight to help you
trim the bottlenecks more.  i.e. you mention lots of looping and
tag nesting; is there any way to change how that's done?

-QM


-- 

software   -- http://www.brandxdev.net/
tech news  -- http://www.RoarNetworX.com/
code scan  -- http://www.JxRef.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
Dakota Jack wrote:

>Why don't you break it down and find out where the time is going?
>
>  
>
So in summary.. now that I'm suspicious that its a tag instantiation 
issue I'm going to load up the webapp with FULL instrumentation... its 
about 8x slower but I think I'll need that level of granularity here.

Anyway... I'm off to Thailand for 2 weeks (*woot!*) and I'll let you 
guys know the status when I get back.

Thanks!

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Dakota Jack <da...@gmail.com>.
Why don't you break it down and find out where the time is going?

On 4/18/05, Kevin Burton <bu...@rojo.com> wrote:
> QM wrote:
> 
> >On Mon, Apr 18, 2005 at 02:19:15PM -0700, Kevin Burton wrote:
> >: So its clearly not JUST reflected methods its something else on top of
> >: it....
> >
> >What does your profiler report?
> >
> >-QM
> >
> >
> >
> I can't for the life of me figure it out!
> 
> It certainly reports that doTag is taking a LOT of time but not WHY its
> taking a lot of time.
> 
> Its reporting that reflection is hurting performance but this is only
> about 200ms vs 2500ms for the tag stuff.
> 
> So I might have been wrong that Reflection is causing the problem and it
> MIGHT be a problem with the tag constructor or some other issue which is
> causing performance problems.
> 
> Are there any options or any other ways to make .tag files which could
> change this behavior?
> 
> I'm all ears...........
> 
> --
> 
> Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com.
> See irc.freenode.net #rojo if you want to chat.
> 
> Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
> 
>    Kevin A. Burton, Location - San Francisco, CA
>       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
QM wrote:

>On Mon, Apr 18, 2005 at 02:19:15PM -0700, Kevin Burton wrote:
>: So its clearly not JUST reflected methods its something else on top of 
>: it....
>
>What does your profiler report?
>
>-QM
>
>  
>
I can't for the life of me figure it out!

It certainly reports that doTag is taking a LOT of time but not WHY its 
taking a lot of time.

Its reporting that reflection is hurting performance but this is only 
about 200ms vs 2500ms for the tag stuff.

So I might have been wrong that Reflection is causing the problem and it 
MIGHT be a problem with the tag constructor or some other issue which is 
causing performance problems.

Are there any options or any other ways to make .tag files which could 
change this behavior?

I'm all ears...........

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by QM <qm...@brandxdev.net>.
On Mon, Apr 18, 2005 at 02:19:15PM -0700, Kevin Burton wrote:
: So its clearly not JUST reflected methods its something else on top of 
: it....

What does your profiler report?

-QM

-- 

software   -- http://www.brandxdev.net/
tech news  -- http://www.RoarNetworX.com/
code scan  -- http://www.JxRef.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Tim Funk <fu...@joedog.org>.
To execute a tag file requires creating some new objects which migh have an 
overhead not quite comparable to RequestDispatcher.include()

Thats probably the issue.

-Tim

Kevin Burton wrote:
> Tim Funk wrote:
> 
>> Its not reflection killing you. For example, time this:
>>
>> <%=System.currentTimeMillis()%>
>> <c:forEach begin='0' end='${param.iterations}'>
>>   ${more.cowbell}
>> </c:forEach>
>> <%=System.currentTimeMillis()%>
>>
>> Where more is any java object and cowbell is a property 
>> (getCowbell()). In simple timing trials - even where iterations is 
>> greater than 2000 - I get subsecond response time.
> 
> 
> I think something else is going on here then.  I actually rewrote the 
> above code to use a custom tag which I KNOW is slow in our system and 
> even with 10000 entries its very fast.
> 
> Though when I took our production code and converted it from .tag files 
> to jspfs it was 100x faster.
> So the issue is what has changed between the two code bases to make it 
> THAT much faster.
> 
> Its got to be some caching system or so forth.  Maybe Tomcat can only 
> cache so many methods and is recreating them.
> So its clearly not JUST reflected methods its something else on top of 
> it....
> 
> Any other ideas?
> 
> Kevin
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
Tim Funk wrote:

> Its not reflection killing you. For example, time this:
>
> <%=System.currentTimeMillis()%>
> <c:forEach begin='0' end='${param.iterations}'>
>   ${more.cowbell}
> </c:forEach>
> <%=System.currentTimeMillis()%>
>
> Where more is any java object and cowbell is a property 
> (getCowbell()). In simple timing trials - even where iterations is 
> greater than 2000 - I get subsecond response time.

I think something else is going on here then.  I actually rewrote the 
above code to use a custom tag which I KNOW is slow in our system and 
even with 10000 entries its very fast.

Though when I took our production code and converted it from .tag files 
to jspfs it was 100x faster. 

So the issue is what has changed between the two code bases to make it 
THAT much faster.

Its got to be some caching system or so forth.  Maybe Tomcat can only 
cache so many methods and is recreating them. 

So its clearly not JUST reflected methods its something else on top of 
it....

Any other ideas?

Kevin

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Tim Funk <fu...@joedog.org>.
Its not reflection killing you. For example, time this:

<%=System.currentTimeMillis()%>
<c:forEach begin='0' end='${param.iterations}'>
   ${more.cowbell}
</c:forEach>
<%=System.currentTimeMillis()%>

Where more is any java object and cowbell is a property (getCowbell()). In 
simple timing trials - even where iterations is greater than 2000 - I get 
subsecond response time.


-Tim

Kevin Burton wrote:

> Dakota Jack wrote:
> 
>> Why would you have to have an entirely new "reflection" for more than
>> one database call?  That sound like a design SNAFU to me.  Looks to me
>> like you should be having one use of reflection instead of 1000.
>>
>>  
>>
> I don't have to have it.  Tomcat is *doing* it.  Forget the DB. If I 
> have a list of 500 items.  And I call 4 taglibs for each item.  This 
> yields a HUGE page slowdown.
> 
> Very pathetic actually.   I can't believe anyone finds this acceptable.
> 
> Kevin
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


What version of Tomcat, Apache to Install

Posted by Daxin Zuo <dz...@techexcel.com>.
Hi,
 I need to install Apache, tomcat, and all related software on a UNIX
computer:
    MACHTYPE=sparc-sun-solaris2.9

What version of Tomcat, and Apache is the best match? I try to install
Apache 2.0.53. When I compile it, there is only one .so file in the modules
filder. It may be the wrong version.

There is no c compiler found. Should I download gcc-2.8.1 or gcc-3.3.2 for
the compiler?

Thanks.
Daxin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
Dakota Jack wrote:

>Why would you have to have an entirely new "reflection" for more than
>one database call?  That sound like a design SNAFU to me.  Looks to me
>like you should be having one use of reflection instead of 1000.
>
>  
>
I don't have to have it.  Tomcat is *doing* it.  Forget the DB. If I 
have a list of 500 items.  And I call 4 taglibs for each item.  This 
yields a HUGE page slowdown.

Very pathetic actually.   I can't believe anyone finds this acceptable.

Kevin

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Dakota Jack <da...@gmail.com>.
Why would you have to have an entirely new "reflection" for more than
one database call?  That sound like a design SNAFU to me.  Looks to me
like you should be having one use of reflection instead of 1000.

Jack

On 4/17/05, Kevin Burton <bu...@rojo.com> wrote:
> Dakota Jack wrote:
> 
> >1000 on a page?  Really?  That seems very odd to me given my
> >experience.  What would a page like that look like?  Do you have
> >examples?
> >
> >
> So psuedo code...
> 
> - get a list of objects from your DB..  Say 500
> - for each object
>    tag A
>    tag B
>    tag C
>    fn:length
> 
> And  so forth... Thats 2000 reflection calls and about 500ms.  REALLY
> slow.  Horribly slow in fact :-/
> 
> Kevin
> 
> --
> 
> Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com.
> See irc.freenode.net #rojo if you want to chat.
> 
> Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
> 
>    Kevin A. Burton, Location - San Francisco, CA
>       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
Dakota Jack wrote:

>1000 on a page?  Really?  That seems very odd to me given my
>experience.  What would a page like that look like?  Do you have
>examples?
>  
>
So psuedo code...

- get a list of objects from your DB..  Say 500
- for each object
   tag A
   tag B
   tag C
   fn:length

And  so forth... Thats 2000 reflection calls and about 500ms.  REALLY 
slow.  Horribly slow in fact :-/

Kevin

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Dakota Jack <da...@gmail.com>.
1000 on a page?  Really?  That seems very odd to me given my
experience.  What would a page like that look like?  Do you have
examples?



On 4/17/05, Kevin Burton <bu...@rojo.com> wrote:
> QM wrote:
> 
> >On Sun, Apr 17, 2005 at 03:44:59PM -0700, Kevin Burton wrote:
> >: We've had a few bottlenecks in our code that have since been removed but
> >: the remaining big bottleneck is Tomcat.  The JSP engine is creating
> >: compiled code that is heavily relying on reflection.
> >: [snip]
> >:
> >: Is there ANY way to get Tomcat to not use reflection in this situation.
> >
> >How could a tag work without reflection?
> >For example, if you use any of the expression-language features, how is
> >Tomcat supposed to react to, say,
> >
> >       ${request.somvar.something}
> >
> >without dynamic invocation?
> >
> >
> >
> I'm not sure about this mechanism but if you take a function like:
> 
> <c:set var="test" value="${foo:bar()}" />
> 
> and rewrite it to use
> 
> <c:set var="test">
>     <foo:bar/>
> </c:set>
> 
> Then it won't use reflection.
> 
> This is why c:set and c:choose and so forth work so well.
> 
> There isn't a perf penalty here.
> 
> So this means I'll have to rewrite all my function calls to elements
> that are in tight loops.
> 
> There's also no reason that it MUST use reflection. I mean its a CODE
> generator so all you have to do is generate code that doesn't use
> reflection and calls the methods directly.
> 
> There.s about a .5ms overhead for reflected functions and if you have
> 1000 on a page (EASY!) then it will be DOG slow.
> 
> >While I doubt you could make Tomcat not use reflection (without
> >completely hacking the source) perhaps you could share more details of
> >what you're doing... that may give the rest of us insight to help you
> >trim the bottlenecks more.  i.e. you mention lots of looping and
> >tag nesting; is there any way to change how that's done?
> >
> >
> >
> Well I think I'm going to have to review all forms of code that cause
> this and rewrite them.
> 
> The BIGGEST problem as I currently see it is with .tag files.  These use
> reflection but I can't figure out a way to rewrite them.
> 
> I think if i were to do this it would yield DRAMATIC performance
> improvements.
> 
> The REAL issue is that enabling developers to shoot themselves in the
> foot like this is really irresponsible and probably needs to be removed
> or a HUGE warning be placed before examples.
> 
> Kevin
> 
> --
> 
> Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com.
> See irc.freenode.net #rojo if you want to chat.
> 
> Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
> 
>    Kevin A. Burton, Location - San Francisco, CA
>       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Reflection for custom taglibs killing performance...

Posted by Kevin Burton <bu...@rojo.com>.
QM wrote:

>On Sun, Apr 17, 2005 at 03:44:59PM -0700, Kevin Burton wrote:
>: We've had a few bottlenecks in our code that have since been removed but 
>: the remaining big bottleneck is Tomcat.  The JSP engine is creating 
>: compiled code that is heavily relying on reflection.
>: [snip]
>: 
>: Is there ANY way to get Tomcat to not use reflection in this situation.
>
>How could a tag work without reflection?
>For example, if you use any of the expression-language features, how is
>Tomcat supposed to react to, say,
>
>	${request.somvar.something}
>
>without dynamic invocation?
>
>  
>
I'm not sure about this mechanism but if you take a function like:

<c:set var="test" value="${foo:bar()}" />

and rewrite it to use

<c:set var="test">
    <foo:bar/>
</c:set>

Then it won't use reflection.

This is why c:set and c:choose and so forth work so well.

There isn't a perf penalty here.

So this means I'll have to rewrite all my function calls to elements 
that are in tight loops.

There's also no reason that it MUST use reflection. I mean its a CODE 
generator so all you have to do is generate code that doesn't use 
reflection and calls the methods directly.

There.s about a .5ms overhead for reflected functions and if you have 
1000 on a page (EASY!) then it will be DOG slow.

>While I doubt you could make Tomcat not use reflection (without
>completely hacking the source) perhaps you could share more details of
>what you're doing... that may give the rest of us insight to help you
>trim the bottlenecks more.  i.e. you mention lots of looping and
>tag nesting; is there any way to change how that's done?
>
>  
>
Well I think I'm going to have to review all forms of code that cause 
this and rewrite them.

The BIGGEST problem as I currently see it is with .tag files.  These use 
reflection but I can't figure out a way to rewrite them.

I think if i were to do this it would yield DRAMATIC performance 
improvements.

The REAL issue is that enabling developers to shoot themselves in the 
foot like this is really irresponsible and probably needs to be removed 
or a HUGE warning be placed before examples.

Kevin

-- 


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

   Kevin A. Burton, Location - San Francisco, CA
      AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org