Home » Forum
NoNumber!

Joomla! extensions & websites
development / support / consultancy

I try to respond within 24 hours (excluding weekends). If I haven't responded by then, feel free to post a reminder or bug me via email.
Welcome, Guest
Please Login or Register.    Lost Password?

Performance issue
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Performance issue
#7104
Performance issue 6 Months, 3 Weeks ago  
Hi all,

first thing: The content templater is a very, very usefull addon I really like!

I tried to send this posting with the nonumber-contact-form but had no luck. ("you are not allowed to use this form" or similar...)

What I wanted to say: The templater has a major performance problem that would be easy to fix. I patched one model and got no problem any more. I thought, you nonumbers are possibly interested...

Following is written by memory - details may differ, the main thing should be clear.

The model coded in models/item.php utilizes a JParamter object that loads some xml data from a file on disk. Loading the file takes (on my testing system) about 0,03 seconds.

In a site with two jce-editor instances and a lot of templates, I count about 200 file accesses that cumulate to about 6 seconds. Another site takes more than 10 seconds just for opening the same file several hundred times. That's bad.

I patched the model in a simple way: Using a small factory class like the one in [1], and replaced following line in item.php:

$xml = new JParameter($params...)

=>
$xml = ParamFactory::getInstance($params)


After this modification, the templater works fast as hell.

Greets, Clemente

[1]
class ParamFactory {
   static $instance = null;

   static function getInstance($params, ...) {
      if ParamFactory::$instance == null {
            ParamFactory::$instance
      }
      return ParamFactory::$instance;
   }
}
Clemens
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#7105
Re: Performance issue 6 Months, 3 Weeks ago  
class ParamFactory {
   static $instance = null;

   static function getInstance($params, ...) {
      if ParamFactory::$instance == null {
            ParamFactory::$instance = new JParamter($params, ...)
      }
      return ParamFactory::$instance;
   }
}
Clemens
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#7112
Re: Performance issue 6 Months, 3 Weeks ago  
I don't see why this would improve performance.
Every time the $xml is created it is unique (different values).
So I don't understand why creating instances would be beneficial.

I have done some testing with your code and it actually uses up more php memory than the original (page load is a little faster, though).
Peter van Westen
Admin
Posts: 4506
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#7221
Re: Performance issue 6 Months, 3 Weeks ago  
HI,

Every time the $xml is created it is unique (different values).
This is not what I observe
I just put following line in line 134 of item.php. Just before the $xml = new JParameter... stuff.

print ("File: ".$xmlfile."<br>");

The output generated is here: http://pastie.org/823008.
Every line there opens the following and obviously identical File:

administrator/components/com_contenttemplater/item_params.xml

You can count the lines and multiply your result with about 0.03 seconds...

What I suggest is:
Create only one instance of JParameter and consequently open the file only one time.

If running in debug mode, Joomla says following:
Time until reneered unpatched: About 6 seconds.
Time until rendered patches: 0,8 seconds.

As already written: The issue has only impact with a lot of templates active. In this situation, we use about 40 templates.

and it actually uses up more php memory
I didn't profile this - but I cannot believe that 1 instance can afford more memory than 200 instances of a class. Perhaps you did something wrong? I copy/paste my code below.

Somewhere out of the model class, best below. Starting at line 485:
class ParamFactory {
    
    static $instance = null;
    
    static function getInstance($ini, $xmlfile) {
        if (ParamFactory::$instance == null) {  
            ParamFactory::$instance = new JParameter( $ini, $xmlfile );
        }
        $result = ParamFactory::$instance;
        return $result;
    }
}


Lines 133 and 134:
//$xml = new JParameter( $ini, $xmlfile );
$xml = ParamFactory::getInstance($ini, $xmlfile);
Clemens
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#7222
Re: Performance issue 6 Months, 3 Weeks ago  
Hi again,

I just opened the same site unpatched and patched to see the memory usage. Joomla was in debug mode, results are copy/pasted direct from the html ouput.
Those number sprek for themselves - little less memory usage and less than 10% rendering time after patching...

Unpatched:
Profil zum Laufzeitverhalten
Application afterLoad: 0.002 seconds, 0.42 MB
Application afterInitialise: 0.135 seconds, 3.55 MB
Application afterRoute: 0.135 seconds, 3.55 MB
Application afterDispatch: 11.366 seconds, 7.87 MB
Application afterRender: 11.471 seconds, 8.88 MB
Speichernutzung
9358720


Patched:
Profil zum Laufzeitverhalten
Application afterLoad: 0.002 seconds, 0.43 MB
Application afterInitialise: 0.099 seconds, 3.55 MB
Application afterRoute: 0.099 seconds, 3.55 MB
Application afterDispatch: 0.812 seconds, 7.72 MB
Application afterRender: 0.924 seconds, 8.72 MB
Speichernutzung
9186620
Clemens
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#7234
Re: Performance issue 6 Months, 2 Weeks ago  
I didn't say the xml file is unique. I said the $xml var is unique.
The params is unique (in your function, the $ini). So what is returned to the $xml var is unique.

I'll do some more testing.
Peter van Westen
Admin
Posts: 4506
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
Go to topPage: 12
Joomla Open Source Training