I recommend to use drupal_static_fast pattern in ctools_get_plugins() function instead of simple drupal_static pattern. This function can be called too many times.

Comments

maximpodorov’s picture

joelpittet’s picture

What kind of savings are we looking at here @maximpodorov, I have that function coming in at about 60 times, do you have it being called more in the 1000s?

I did some preliminary research to see when drupal_fast_static becomes worth the extra code complexity and it seems to me that about 5000 calls is a nice number where it starts to make some good merit for it's use.

@see https://www.drupal.org/node/2354561#comment-9390521

I could be way off and like you know more about the subject than I do, but please share if you do:) Or how my testing is flawed.

joelpittet’s picture

Sorry 250 times, is my count not 60.

maximpodorov’s picture

If Panelizer is used for entities, and many entities are to be shown, and every has view attached, you can get tens of thouthands ctools_get_plugins() calls. Of course, the time is not saved considerably, but, if you can reduce function calls, it's better, I think.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Well cool, if you can get >5000 it seems the extra complexity is outweighed by the benefit IMO.

It would be nice to get a couple of XHProf Kit results on this one with an example, if possible. Though from what you mentioned in #4 It's likely that could get that high quickly and I have 250 calls in a much simpler case.

I'll let a committer decide if it needs profiling?

japerry’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Performance

Nice little optimization. Committed.

  • japerry committed d3b731a on 7.x-1.x authored by maximpodorov
    Issue #2415709 by maximpodorov: Use drupal_static_fast pattern in...

Status: Fixed » Needs work

The last submitted patch, 1: ctools-ctools_get_plugins_caching-2415709-1.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Fixed

It was committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.