<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Workplace Performance</TITLE>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=629334808-17082000>I
found this problem months ago and suggested the same hack on 19. May 2000
;-</SPAN></FONT><FONT face=Tahoma><FONT size=2><SPAN
class=629334808-17082000><FONT color=#0000ff
face=Arial> )</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=629334808-17082000>Thanks
to KL-Groups great JProbe-Profiler!</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=629334808-17082000>Here
comes my old mail again:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=629334808-17082000><FONT
size=2>
<P>Hello together!</P>
<P>Today I made a profiling session with OpenCms. </P>
<P>I picked out the file-frame of the workplace, which is in my
configuration:</P>
<P>http://localhost:8080/examples/servlet/opencms/system/workplace/action/explo</P>
<P>rer_files.html</P>
<P>For now I found one interesting hotspot:</P>
<P>Each request to CmsXmlWpTemplateFile causes a new instance of the</P>
<P>CmsXmlLanguageFile object. This is a very expensive operation, because
the</P>
<P>very large LanguageFile must be loaded, parsed and so on (cumulated about</P>
<P>60% of the whole request time).</P>
<P>Then I patched (it is just a demo hack!!!) the CmsXmlWpTemplateFile</P>
<P>implementation and changed CmsXmlLanguageFile.m_languageFile to a static.</P>
<P>Then I profiled again and compared the request times:</P>
<P>Normal version opencms:</P>
<P>(fresh started server)</P>
<P>first request: 79.825 ms</P>
<P>second request: 11.046 ms</P>
<P>==================================</P>
<P>Patched version:</P>
<P>(fresh started server)</P>
<P>first request: 14.623 ms</P>
<P>second request: 4.539 ms</P>
<P>With this hack you get more than 50 percent of speed. OK it is just a
hack,</P>
<P>but it proves the need to do something in this spot. I suggest a
singleton</P>
<P>class which caches all the language files ever loaded and doublecheck
that</P>
<P>the mechanism is thread save. Furthermore there must be a way to
invalidate</P>
<P>this cache.</P>
<P>Here comes the diff-dump:</P>
<P>RCS file:</P>
<P>/usr/local/cvs/opencms/src/com/opencms/workplace/CmsXmlWpTemplateFile.java,v</P>
<P>retrieving revision 1.40</P>
<P>diff -r1.40 CmsXmlWpTemplateFile.java</P>
<P>53c53</P>
<P>< private CmsXmlLanguageFile m_languageFile = null;</P>
<P>---</P>
<P>> private static CmsXmlLanguageFile m_languageFile = null;</P>
<P>98c98,103</P>
<P>< m_languageFile = new CmsXmlLanguageFile(cms);</P>
<P>---</P>
<P>> </P>
<P>> if( m_languageFile == null )</P>
<P>> {</P>
<P>> m_languageFile = new CmsXmlLanguageFile(cms);</P>
<P>> }</P>
<P>> </P>
<P> </P>
<P>Lets discuss the best implementation for this issue!</P>
<P> </P>
<P>Best regards</P>
<P>Hardi</P></FONT></SPAN></FONT></DIV>
<DIV><FONT face=Tahoma><FONT size=2><SPAN
class=629334808-17082000></SPAN></FONT></FONT> </DIV>
<DIV><FONT face=Tahoma><FONT size=2><SPAN
class=629334808-17082000> </SPAN>-----Ursprüngliche
Nachricht-----<BR><B>Von:</B> Shaun Kelly
[mailto:shaun.kelly@spike.com.au]<BR><B>Gesendet:</B> Donnerstag, 17. August
2000 09:20<BR><B>An:</B> 'opencms-dev@www.opencms.com'<BR><B>Betreff:</B>
[opencms-dev] Workplace Performance<BR><BR></DIV></FONT>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px"></FONT>
<P><FONT face=Arial size=2>Hi,</FONT> </P>
<P><FONT face=Arial size=2>I have found a performance problem with the OpenCms
WorkPlace. Every time the class CmsXmlWpTemplateFile is created, it creates a
new instance of CmsXmlLanguageFile. On creation CmsXmlLanguageFile, parses the
appropriate language file for the current user. Parsing the language file is a
slow process, it takes about 1.5 seconds. An instance of CmsXmlWpTemplateFile
is created for each request to the CMS, even if the request is for an image.
This drastically reduces the performance of the CMS. A temporary fixed is
shown in the code below. This code will fix the language used by WorkPlace to
the default language (German). If you wish to use English, you will need to
change the default language to English.</FONT></P>
<P><FONT face=Arial size=2>Regards Shaun</FONT> </P>
<P><B><FONT face=Arial size=2>class CmsXmlWpTemplateFile</FONT></B> <BR><FONT
face=Arial size=2> </FONT> <BR><FONT face=Arial size=2>
static private CmsXmlLanguageFile m_languageFile = null;</FONT> </P>
<P><FONT face=Arial size=2> public void init(CmsObject cms,
CmsFile file) throws CmsException {</FONT> <BR><FONT face=Arial
size=2> if(m_languageFile ==
null)</FONT> <BR><FONT face=Arial
size=2> {</FONT> <BR><FONT
face=Arial size=2>
m_languageFile = new
CmsXmlLanguageFile(cms);</FONT> <BR><FONT face=Arial
size=2> }</FONT> <BR><FONT
face=Arial size=2> super.init(cms,
file);</FONT> <BR><FONT face=Arial size=2> }</FONT> </P>
<P><FONT face=Arial size=2> public void init(CmsObject cms,
CmsFile file) throws CmsException {</FONT> <BR><FONT face=Arial
size=2> if(m_languageFile ==
null)</FONT> <BR><FONT face=Arial
size=2> {</FONT> <BR><FONT
face=Arial size=2>
m_languageFile = new
CmsXmlLanguageFile(cms);</FONT> <BR><FONT face=Arial
size=2> }</FONT> <BR><FONT
face=Arial size=2> super.init(cms,
file);</FONT> <BR><FONT face=Arial size=2> }</FONT> </P>
<P align=center><B><FONT face=Tahoma>Shaun Kelly</FONT></B></P>
<P align=center><B><FONT face="Courier New">S</FONT><FONT
face="Courier New"></FONT> <FONT face="Courier New">P</FONT><FONT
face=Tahoma></FONT> <FONT color=#0000ff face="Courier New">I</FONT><FONT
face=Tahoma></FONT> <FONT face="Courier New">K</FONT><FONT face=Tahoma></FONT>
<FONT face="Courier New">E</FONT></B></P>
<P align=center><FONT face=Tahoma size=2>Email:
shaun.kelly@spike.com.au</FONT></P>
<P align=center><FONT face=Tahoma size=2>Ph: 61 2 8584
8584</FONT></P>
<P align=center><FONT face=Tahoma size=2>Fax: 61 2 8584
8500</FONT></P>
<P align=center><FONT color=#ffffff face=Verdana size=2>L O S A N G E L
E S T O K Y O</FONT><FONT face=Verdana size=2> S Y D N E Y
</FONT><FONT color=#ffffff face=Verdana size=2>M E L B O U R N E A U C K
L AN D</FONT></P><BR></BLOCKQUOTE></BODY></HTML>