AW: [opencms-dev] Workplace Performance

Hardi Probst hardi.probst at infarct.de
Fri Aug 18 11:59:04 CEST 2000


I found this problem months ago and suggested the same hack on 19. May 2000
;- )
Thanks to KL-Groups great JProbe-Profiler!
 
Here comes my old mail again:
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

 
 -----Ursprüngliche Nachricht-----
Von: Shaun Kelly [mailto:shaun.kelly at spike.com.au]
Gesendet: Donnerstag, 17. August 2000 09:20
An: 'opencms-dev at www.opencms.com'
Betreff: [opencms-dev] Workplace Performance



Hi, 

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.

Regards Shaun 

class CmsXmlWpTemplateFile 
  
    static private CmsXmlLanguageFile m_languageFile = null; 

    public void init(CmsObject cms, CmsFile file) throws CmsException { 
        if(m_languageFile == null) 
        { 
                m_languageFile = new CmsXmlLanguageFile(cms); 
        } 
        super.init(cms, file); 
    } 

    public void init(CmsObject cms, CmsFile file) throws CmsException { 
        if(m_languageFile == null) 
        { 
                m_languageFile = new CmsXmlLanguageFile(cms); 
        } 
        super.init(cms, file); 
    } 

Shaun Kelly

S P I K E

Email:  shaun.kelly at spike.com.au

Ph:     61 2 8584 8584

Fax:    61 2 8584 8500

L O S  A N G E L E S  T O K Y O  S Y D N E Y  M E L B O U R N E  A U C K L
AN D


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20000818/47ec8fc0/attachment.htm>


More information about the opencms-dev mailing list