Attention: I know that there are bugs, with my fix based on the configuration of your menu system. Since I can not replicate these issues myself, I can not fix them on my own. I would like to complete the fix for those people who may want to use joomla with dynamic caching. If you are interested please email me at joomlafixd@yahoo.com.
It’s no secret that there are serious performance problems with Joomla 1.5x. Especially if you’re not using caching. Right out of the box, most sites see memory and CPU usage go through the roof with each request. This problem is well documented, and even Joomla’s own website has pages dedicated to helping users come up with fixes and work-arounds.
After much frustration on a recent project, I decided to investigate the problem. Below is what I discovered.
First: By turning off the Main Menu in the Module Manager, there is vast improvement in performance to be found. This is where most of the resources are greedily consumed.
Next: To recreate the functionality of the menu system, I created a hack that caches the HTML for all of Joomla’s menus. I’ve made this available to the public, below.
Note: The project I worked on has a fairly large menu, about five levels deep. But this hack should work for any size menu.
Here are the results.
Before
Profile Information
Application afterLoad: 0.002 seconds, 0.43 MB
Application afterInitialise: 0.214 seconds, 2.28 MB
Application afterRoute: 0.341 seconds, 3.78 MB
Application afterDispatch: 0.482 seconds, 4.33 MB
Application afterRender: 5.377 seconds, 6.02 MB
Memory Usage
6346872
45 queries logged
After
Profile Information
Application afterLoad: 0.002 seconds, 0.43 MB
Application afterInitialise: 0.191 seconds, 2.28 MB
Application afterRoute: 0.308 seconds, 3.78 MB
Application afterDispatch: 0.446 seconds, 4.33 MB
Application afterRender: 0.708 seconds, 5.16 MB
Memory Usage
5455480
45 queries logged
Notice the afterRender where the Top Menu module executes. Significant time and memory has been shaved off.
While the performance improvements are most noticeable when you’re not using caching (either free or purchased), this hack will work alongside all the caching plug-ins available.
Also, I have not come up with an elegant way to make a plug-in, so you’ll have to replace some files to get it to start working. (If you have suggestions on how best to make this a plug-in, let me know.)
Instructions
1. Make a back-up copy of these files in case it does not work properly for your install. Then copy helper.php under your docs/modules/mod_mainmenu
item.php and list.php under /docs/administrator/components/com_menus/models.
2. Replace those files with these, under the same directory: helper.php, item.php, and list.php.
3. Make sure that the docs/cache folder is write-able, you should start seeing .html files appear with in your cache directory. The html files are all the menu files cached so that Joomla does not have to execute or build the data structure to write them out. The source files that go in the administrator component will take care of menu changes by deleting the specific cache.
Update on joomlacode:
There are two patches mines and this one. My patch should be a greater performance boost, but as I said this is more a work around or hack. I do not know if joomla is addressing this in any other fashion.
Also if you are experiencing bugs, please email me at joomlafixd@yahoo.com, so maybe I can work out a universal solution in case joomla does not come up with an actual fix.
October 11, 2008 at 3:17 am
I wan to try this, but I can’t figure out what you mean by:
“First: By turning off the Top Menu in the Module Manager,”
Do you mean the menu module highest up on list? I have no “top menu” name or template position.
Thanks for any clarification you can give.
October 12, 2008 at 12:12 am
In the Joomla Administrator there is a Module Manager. From the toolbar go to Extensions->Module Manager, there you can turn off the Main Menu Module, sorry I think I was calling it Top Menu.
However turning off the Module is not a fix, because you still probably want Joomla to make the menu’s for you. This was just my first clue that the creating of the menu links was the bottle neck.
October 12, 2008 at 1:28 am
Thanks for the reply – I can see where I was misreading a bit what you said.
I tried this again and all my menus went wonky – the same three links in all of them.
I think I will experiment and use just one menu for the module. Maybe that will allow your hack to work – and maybe even speed things up anyways.
So you have other Joomla Speed Improvements elsewhere I can read up on?
October 12, 2008 at 2:40 pm
If you want information about joomla performance from somebody who really knows performance, you should check out Joomlaperformance.com. The author really knows his stuff and is one of the foremost names in joomla! performance.
October 12, 2008 at 3:09 pm
Tested, and yes this is a great improvement !!
(under J1.5.7)
October 12, 2008 at 6:14 pm
Tim and anyone else, if it is not working for you, please drop me and email @ joomlafixd@yahoo.com.
I did not get to finish working on this enhancement when i worked on the project (although i feel it is close to an actual work around), so any assistance would be helpful.
October 13, 2008 at 4:58 pm
Hi again.
Spoke to fast last time.
Great improvement, but strange things. Now I got the main menu showing up in a module, but I never put this lodule “on”.
And the other thing is that my child menus doesn’t work for some of them.
I made a screenshot, with the buggy page, mail me if you want to see that