When troubleshooting performance it can be very helpful to find out how much time is spent in the execution of each portlet that is on the page. Once identified which portlets are taking the majority of time it is possible to add more tracing and additional measures to get to the root cause of the performance issue.
While in the Portal 6.x themes one could add the code to compute the time in the Control.jsp file ( as described below) this is no longer possible with WebSphere Portal 7 and 8 themes.
How to add a Skin timer to a Portal 6.x skin:
Add the following code around the portletRender tag in the Control.jsp of each skin:
<div style="border: 1px solid red; padding 2px;">
<% long start = java.lang.System.currentTimeMillis(); %>
… <wps:portletRender…> … </wps:portletRender> …
<div style="color: red; padding: 4px; border: solid red; ">
<%= java.lang.System.currentTimeMillis() - start %>ms
</div>
</div>
The Portal 7 and 8 themes using webdav like the Page Builder 2 or the Portal 7.0.0.2 theme store the static markup in webdav and integrate the portlet output via a dynamic content spot. Since the markup code in webdav is not executing as part of a jsp one can not add the timer code to it.
The attached ear file adds the timer code as part of the portlet markup in form of a global portlet filter.
To install the code download the attached ear file and deploy it to your environment. After startup the ear file automatically registers with Portal and starts working.
The module creates entries in both SystemOut.log as well as the rendered html.
The log output looks like the following and is always prefixed with PortletPerfFilter:
[6/11/12 22:14:41:990 EDT] 0000007a PerformanceFi W PortletPerfFilter: Render Header Request for portlet /wps/PA_WCMLRingPortJSR286 took msecs: 995
The generated div uses the class portletperformance - it is possible to customize the look of the render time in the html output with css.
The html output looks like the following in the resulting html of the page for each portlet:
<div class="portletperformance" style="color: red;">Msecs taken: 455</div>
Limitations and Considerations:
- The code is provided "AS IS", without warranty of any kind. IBM shall not be liable for any damages arising out of your use of this code, even if they have been advised of the possibility of such damages.
- Right now the Module only supports JSR 286 portlets
- Only the 2nd part of the render phase (not the part for setting headers and cookies) is included in the html output - everything else is logged into the SystemOut.log
The ear file can be downloaded from Lotus Greenhouse:
https://greenhouse.lotus.com/files/app?lang=en_US#/file/54ea02c0-31a2-4b77-9539-02c4510de8f6
The author is interested in feedback on the module and would like to improve the module based on your feedback.
About the Author:
Thomas Hurek is a software architect at IBM's Research Triangle Park Development Lab. He has worked on the WebSphere Portal development team for 11 years, focusing on various components, including security and virtual portals. In his current role Thomas supports clients as lab based services consultant and works as Chief Programmer on the development of the product. You can contact Thomas at thurek@us.ibm.com.