QeelwaEtech / omnifaces

Automatically exported from code.google.com/p/omnifaces
0 stars 1 forks source link

[PERFORMANCE] EL function, formatDate() #170

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add the following to a menubar.xhtml:

<h:outputText escape="false" value="Server (re)started: 
#{of:formatDate(startup, 'yyyy-MM-dd hh:mm a')}"/>

2. Open/render a really large xhtml page, where the large xhtml page != 
menubar.xhtml (above), but both xhtml pages are included via ui:include 
src="..."

What is the expected output?

OmniFaces EL function, formatDate(), 'is not' a hot spot in Java Visual VM.

What do you see instead?

OmniFaces EL function, formatDate(), 'is' a hot spot in Java Visual VM.

What OmniFaces version are you using?

omnifaces-1.5-SNAPSHOT-20130407.jar

What JSF impl/version are you using?

MyFaces Core 2.1.11

What servletcontainer impl/version are you using?

TomEE-plus 1.6.0 SNAPSHOT (2013-03-27); can use any version, afterwards; my app 
works with TomEE-plus 1.5.1 SNAPSHOT (and all later versions).

If any, what JSF component library impl/version are you using?

PrimeFaces 3.5 release

Please provide any additional information below.

Attached, is a screen capture for 'earlier' this morning (on my development 
server), but I just repeated test steps (above) on production server, and 
formatDate() 'is not' a hot spot in Java Visual VM.

Feel free to mark this as invalid, if you like, but I just wanted to report 
this, and/or ask an explanation for this EL function showing up as a hot spot 
in Java Visual VM.

Original issue reported on code.google.com by smithh03...@gmail.com on 22 Apr 2013 at 12:22

Attachments:

GoogleCodeExporter commented 9 years ago
Related: http://bugs.sun.com/view_bug.do?bug_id=4692504
Fixed: 
https://code.google.com/p/omnifaces/source/detail?r=b3369a22688f8148caaa9dda4276
9a127bc95623

I made it a constant reference instead. Please try the attached snapshot.

Original comment by balusc on 22 Apr 2013 at 3:12

Attachments:

GoogleCodeExporter commented 9 years ago
Interesting/nice/perfect solutin! Since I've been making performance 
improvement/changes throughout the app, this fix is definitely a lesson-learned 
for me, and similar to changes that I have made in/throughout my app.

I downloaded the 1.5 snapshot JAR (that was attached to this issue), added to 
the web app (project), and went through multiple pages throughout the web app, 
and I am 'not' seeing this omnifaces EL function, formatDate, as a hotspot 
anymore.

So, I'll take it (this fix). Thanks!

When is the class instantiated? I couldn't find it in jvisualvm's Call Tree at 
all (after doing a sampler and then snapshot, and even after restarting tomee, 
and starting sampler before login to the web app).

Original comment by smithh03...@gmail.com on 22 Apr 2013 at 6:00

GoogleCodeExporter commented 9 years ago
The Dates class is never instantiated. It contains only static methods (and has 
a private constructor).

The TimeZone#getDefault() is --apparently-- instantiated on every call (I 
initially didn't expect it to be, that was my mistake, I would otherwise have 
made it a constant in first place, like as I already did for the UTC timezone). 
It becomes a hostspot because the created instance represents the same value 
everytime (as confirmed by equals()). It'd better be cached on application's 
startup or as a constant reference.

Thank you for reporting this (keep reporting them) and good luck 
fixing/enhancing your application's performance.

Original comment by balusc on 22 Apr 2013 at 6:07

GoogleCodeExporter commented 9 years ago
You're welcome and definitely, it is my pleasure to report this to you. I've 
been reporting other 'hot spots' to PrimeFaces, OpenWebBeans, MyFaces as well. 
Open-source at its best (reporting issues, especially performance issues). :)

Original comment by smithh03...@gmail.com on 22 Apr 2013 at 6:11