[JBoss Seam] - JSF performance tips in Seam applications
by mgrouch
Improving JSF performance in Seam Applications
JSF performs best with server side state saving
So in your web.xml you should have
<context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>server</param-value>
| </context-param>
Improving render phase performance
You should increase response buffer (to reduce reallocations at render time)
(Experimentally I've seen 2 times better render times on larger pages esp with data tables)
With Sun RI
<context-param>
| <param-name>com.sun.faces.responseBufferSize</param-name>
| <param-value>500000</param-value>
| </context-param>
If you using facelets add also
<context-param>
| <param-name>facelets.BUFFER_SIZE</param-name>
| <param-value>500000</param-value>
| </context-param>
With Seam chances are you are using Ajax4Jsf. Ajax4Jsf adds additional filter which parses XHTML output
before sending to to browser.
Use this filter definition
<filter>
| <display-name>Ajax4jsf Filter</display-name>
| <filter-name>ajax4jsf</filter-name>
| <filter-class>org.ajax4jsf.FastFilter</filter-class>
| <init-param>
| <param-name>forceparser</param-name>
| <param-value>false</param-value>
| </init-param>
| </filter>
| <filter>
| <filter-mapping>
| <filter-name>ajax4jsf</filter-name>
| <url-pattern>*.seam</url-pattern>
| <dispatcher>REQUEST</dispatcher>
| <dispatcher>FORWARD</dispatcher>
| <dispatcher>INCLUDE</dispatcher>
| </filter-mapping>
|
NOTE (IN newer Seam versions same settings are done via components.xml file; check docs)
Or (better) turn off Ajax4Jsf filter completely if your XHTML is valid.
There are 2 independent settings
1) forceparser=false (prevents Ajax4Jsf parser from executing on non Ajax requests)
2) filter-class=org.ajax4jsf.FastFilter (uses nekko parser which is faster than org.ajax4jsf.Filter)
In production environment use (see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#config-webapp-init)
<context-param>
| <param-name>facelets.DEVELOPMENT</param-name>
| <param-value>false</param-value>
| </context-param>
| <context-param>
| <param-name>facelets.REFRESH_PERIOD</param-name>
| <param-value>-1</param-value>
| </context-param>
|
In production JBoss server turn off Seam DEBUG level logging which is turned on by default in JBoss log4j configuration
It is quite excessive and goes into JBoss server log (you do not see it on console)
Use Native I/O on your application server. You usually need to install additional DLLs or shared libraries for that,
check app server documentation and warnings on start-up.
Check your JVM setting make sure memory settings are adequate for your application.
JRockIt JVM should perform better than Sun's one.
Make sure that your jar files contain XSD schemas and DTDs you refer in you XML configuration files
especially Seam XSD (to prevent fetching them from Internet)
Javassist performance optimization settings for Seam [TODO:]
Performance of third party JSF component libraries
1. Tomahawk (check their recommendation about StreamingAddResource, t:documentBody, t:documentHead, t:document)
2. RichFaces (see ajax4sf filter tips)
3. IceFaces [TODO]
4. Trinidad [TODO]
5. QuipuKit [TODO]
6. Woodstock [TODO]
General UI Design TIPS
1. Avoid displaying large tables to user. Use pagination
2. With many components on the page <ui:remove> will help you to identify which one is performance killer
3. Try different methods to render same content (Ex: rendering tables with ui:repeat vs h:dataTable)
4. Avoid components which use have JavaScript on client side unless you tested them carefully for
their client side performance. Very often those render slow in browser cause of JavaScript in them, and
not because of JSF server side RENDER phase. Fancy ones are usually very slow especially in IE.
5. When using ajax4jsf you can sometimes reduce APPLY REQUEST VALUES JSF phase (which might be
significant when large form with many inputs is submitted). Check documentation on ajaxOnly and relevant attributes
6. Consider immediate=true attributes on elements where you do not need validation
7. Choose wisely between client side and server side in components such as tabs, collapsible panels, etc
8. Profile javascript with FireBug
9. Choose appropriate java collection based on access method (direct, sequential, by key)
10. Use java StringBuilder vs StringBuffer and + operator
11. Consider using Web Remoting in some cases vs ajax4jsf for simple things (ex: dependable dropdowns)
12. Do not over complicate EL expressions, code them in Java in backing bean
13. Avoid constructing and destroying objects in a loop. Create once and re-use.
14. Review your code you might be calling same functions repeatedly which could have been called only once
Hibernate, EJB and back-end performance tips
[Not covered in details but to mention a few]
1. Use indexes on database tables appropriately
2. Reduce number of round trips to database to fetch data (Ex: RowFetchSize in JDBC, join queries,
insert batch and retrieve generated keys via result sets in one round trip, etc)
3. USE CACHING (caching is easy to set up with hibernate)
4. Do not use many transactions while serving one HTML page
5. Be careful with excessive logging
6. Understand Seam concept of conversations
See below details about tips for server and client state savings scenarios
For server side state with Sun RI see:
http://wiki.glassfish.java.net/Wiki.jsp?page=JavaServerFacesRI#section-Ja...
<context-param>
| <param-name>com.sun.faces.numberOfViewsInSession</param-name>
| <param-value>50</param-value>
| </context-param>
| <context-param>
| <param-name>com.sun.faces.numberOfLogicalViews</param-name>
| <param-value>50</param-value>
| </context-param>
For server side state with MyFaces see:
http://wiki.apache.org/myfaces/Performance
<context-param>
| <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
| <param-value>false</param-value>
| </context-param>
| <context-param>
| <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
| <param-value>false</param-value>
| </context-param>
| <context-param>
| <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
| <param-value>50</param-value>
| <description>
| Only applicable if state saving method is "server" (= default).
| Defines the amount (default = 20) of the latest views are stored in session.
| </description>
| </context-param>
|
| If you are not using server state saving
you still can gain some better results by using JBoss serialization
for MyFaces follow steps for Client http://wiki.apache.org/myfaces/Performance:
<context-param>
| <param-name>org.apache.myfaces.SERIAL_FACTORY</param-name>
| <param-value>org.apache.myfaces.JbossSerialFactory</param-value>
| </context-param>
for Sun RI set (see http://jira.jboss.com/jira/browse/JBAS-3529)
<context-param>
| <param-name>com.sun.faces.serializationProvider</param-name>
| <param-value>org.jboss.web.jsf.integration.serialization.JBossSerializationProvider</param-value>
| </context-param>
|
Code can be found here
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/trunk/tomcat/src/main/...
Please, comment if you have more suggestion to add. This is for Seam Wiki.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078546#4078546
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078546
18Â years, 8Â months
[JBoss Seam] - Re: selectDate & convertDateTime
by tcavaleiro
Thanks for the reply Pete.
Originally I didn't interpret well what I've read on http://jira.jboss.org/jira/browse/JBSEAM-623 so I didn't understand the right use of s:selectDate.
But after digging on your code (SelectDateRendererBase.java) I got it (how it works...)
I was thinking that s:selectDate needed some sort of *.js locale resource (DateFormatSymbols is powerful).
The truth is that I've define the locale in faces-config.xml like this
| <locale-config>
| <default-locale>pt</default-locale>
| <supported-locale>pt</supported-locale>
| </locale-config>
|
and the s:selectDate works very well, but if my s:selectDate is created dynamically through Ajax4JSF the Javascript is transfered but never evaluated.
This is also reported in this thread ( http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035703#4035703 )
and there's a JIRA related ( http://jira.jboss.com/jira/browse/JBSEAM-1156 )
I don't know exactly what is the problem (I've tested with Firefox 2.0.0.6, Opera 9.23 and IE 7 and in all it goes the same. Also [for all] if I made a refresh then the s:selectDate names now appears on portuguese)
Workaround: After putting the next code (through static form) the problem is solved (as is suggested by damianharvey)!!
| <script type="text/javascript">
|
| //
| var CAL_DAYS_SHORT = 'Do,Se,Te,Qu,Qu,Se,Sá';
| var CAL_DAYS_MEDIUM = 'Dom,Seg,Ter,Qua,Qui,Sex,Sáb';
| var CAL_DAYS_LONG = 'Domingo,Segunda-feira,Terça-feira,Quarta-feira,Quinta-feira,Sexta-feira,Sábado';
| var CAL_MONTHS_MEDIUM = 'Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez';
| var CAL_MONTHS_LONG = 'Janeiro,Fevereiro,Março,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro';
| var CAL_FIRST_DAY_OF_WEEK = 1;
| var CAL_DATE_FORMAT = 'dd/MM/yyyy';
| //
|
| </script>
|
Sorry if it went too extensive!
Tiago.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078543#4078543
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078543
18Â years, 8Â months
[JBoss Seam] - Re: Seam Text
by tony.herstellï¼ gmail.com
for NO.2. I nearly cracked it:
anonymous wrote :
| entity_user_email_hint=#a valid email where you wish to be contacted. #This will be used as your username. #Your email will be used to keep in touch with you by the on-line booking and events management capabilities of this site. #This will *not* be shown on the site.
|
I get the startings of a list rendered but then it goes wrong and I get this in the server log:
anonymous wrote :
| 12:25:28,656 ERROR [STDERR] line 1:48: unexpected token: #
| 12:25:28,656 ERROR [STDERR] line 1:49: unexpected token: This
| 12:25:28,656 ERROR [STDERR] line 1:85: unexpected token: #
| 12:25:28,656 ERROR [STDERR] line 1:208: unexpected token: #
|
pretty much the same problem for "=" (unordered list) as well... has it been another character for a list this hack would have worked.
Darn... almost!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078542#4078542
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078542
18Â years, 8Â months