Optimizing JComponentHelper::getComponent #5124

Merged
merged 2 commits into from Nov 22, 2014

Conversation

Projects
None yet
7 participants
@Hackwar
Member

Hackwar commented Nov 16, 2014

Joomla currently loads each and every component seperately when it tries to retrieve the parameters of a component for example. On a vanilla Joomla, that means at least an additional 7 queries per pageload. This PR combines those into one query against the extension table and caching all results of that. This means less load for the database, less (albeit neglectable) memory consumption for Joomla and slightly less execution time for the overall system. The effects on a test-system might not be big, but it will be an optimization for larger systems.

This PR has one downside: So far the protected methode load() retrieved the data and then created the params object of each component. With the change I could either generate the params object for all components up front, or delegate that step to the getComponent() method and do it on demand. I choose the later option. This means that the load() method has a slightly changed behavior, which could be called a break in backwards compatibility. Since load() would only be accessible from inside the JComponentHelper class or a class inheriting from it and I simply can't think of a reason to create such an inheriting class, this change seems acceptable. However, I'd like to hear other opinions on this.

Test instructions:

  1. Enable debug mode, notice the number of queries on a page, its execution time and memory consumption.
  2. Apply the change.
  3. Reload the page and see a reduced number of queries and slightly reduced numbers for execution time and memory consumption.
@wilsonge

This comment has been minimized.

Show comment
Hide comment
@wilsonge

wilsonge Nov 16, 2014

Contributor

Can we keep Registry instead of JRegistry please?

Contributor

wilsonge commented Nov 16, 2014

Can we keep Registry instead of JRegistry please?

@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Nov 16, 2014

Member

sure

Member

Hackwar commented Nov 16, 2014

sure

@Fedik

This comment has been minimized.

Show comment
Hide comment
@Fedik

Fedik Nov 17, 2014

Contributor

test
works good for me.
on the Test Installation on the homepage: before patch was 51 query, and 44 - after.

Contributor

Fedik commented Nov 17, 2014

test
works good for me.
on the Test Installation on the homepage: before patch was 51 query, and 44 - after.

@chmst

This comment has been minimized.

Show comment
Hide comment
@chmst

chmst Nov 17, 2014

Contributor

test
3.3.7_dev, 64 db-queries before - 37 after the patch

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

Contributor

chmst commented Nov 17, 2014

test
3.3.7_dev, 64 db-queries before - 37 after the patch

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

@chmst

This comment has been minimized.

Show comment
Hide comment
@chmst

chmst Nov 17, 2014

Contributor

sry - multiple entries due to a pending browser

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

Contributor

chmst commented Nov 17, 2014

sry - multiple entries due to a pending browser

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

@roland-d

This comment has been minimized.

Show comment
Hide comment
@roland-d

roland-d Nov 18, 2014

Contributor

Moving to RTC as we have 2 successful tests

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

Contributor

roland-d commented Nov 18, 2014

Moving to RTC as we have 2 successful tests

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5124.

@mbabker mbabker added this to the Joomla! 3.4.0 milestone Nov 22, 2014

mbabker added a commit that referenced this pull request Nov 22, 2014

Merge pull request #5124 from Hackwar/componenttable
Optimizing JComponentHelper::getComponent

@mbabker mbabker merged commit 45919f9 into joomla:staging Nov 22, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

@Hackwar Hackwar deleted the Hackwar:componenttable branch Nov 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment