[opencms-dev] Performance Profiling Session

Hardi Probst hardi.probst at infarct.de
Fri May 19 22:05:34 CEST 2000


Hello together!

Today I made a profiling session with OpenCms. 

I picked out the file-frame of the workplace, which is in my configuration:

http://localhost:8080/examples/servlet/opencms/system/workplace/action/explo
rer_files.html

For now I found one interesting hotspot:

Each request to CmsXmlWpTemplateFile causes a new instance of the
CmsXmlLanguageFile object. This is a very expensive operation, because the
very large LanguageFile must be loaded, parsed and so on (cumulated about
60% of the whole request time).

Then I patched (it is just a demo hack!!!) the CmsXmlWpTemplateFile
implementation and changed CmsXmlLanguageFile.m_languageFile to a static.
Then I profiled again and compared the request times:

Normal version opencms:
(fresh started server)

first request:  79.825 ms
second request: 11.046 ms

==================================

Patched version:
(fresh started server)

first request:  14.623 ms
second request:  4.539 ms

With this hack you get more than 50 percent of speed. OK it is just a hack,
but it proves the need to do something in this spot. I suggest a singleton
class which caches all the language files ever loaded and doublecheck that
the mechanism is thread save. Furthermore there must be a way to invalidate
this cache.

Here comes the diff-dump:

RCS file:
/usr/local/cvs/opencms/src/com/opencms/workplace/CmsXmlWpTemplateFile.java,v
retrieving revision 1.40
diff -r1.40 CmsXmlWpTemplateFile.java
53c53
<     private CmsXmlLanguageFile m_languageFile = null;
---
>     private static CmsXmlLanguageFile m_languageFile = null;
98c98,103
<         m_languageFile = new CmsXmlLanguageFile(cms);
---
> 
>         if( m_languageFile == null )
>         {
>            m_languageFile = new CmsXmlLanguageFile(cms);
>         }
>         


Lets discuss the best implementation for this issue!


Best regards

Hardi





More information about the opencms-dev mailing list