Use drupal_static() in dashboard_regions()

sun - October 31, 2009 - 22:25
Project:Drupal
Version:7.x-dev
Component:dashboard.module
Category:bug report
Priority:minor
Assigned:Unassigned
Status:needs review
Description

Dashboard is invoked on all pages.

I started to work on a patch, but...

...debug_backtracing through dashboard module I get the feeling that we need to retitle this issue "Region and block building + rendering eats our performance"...

#1

sun - October 31, 2009 - 22:49

Contains my cufa() tweak from #615822: Figure out why D7 is so much slower than D6 to be able to see those function calls in the first place.

AttachmentSizeStatusTest resultOperations
drupal.dashboard-performance.patch4.02 KBIdleFailed: Failed to apply patch.View details | Re-test

#2

sun - October 31, 2009 - 22:52
AttachmentSizeStatusTest resultOperations
bench-head.txt1.3 KBIgnoredNoneNone
bench-patch.txt1.3 KBIgnoredNoneNone

#3

sun - October 31, 2009 - 23:26
Title:Dashboard eats our performance» Dashboard, and region and block building + rendering eats our performance

Yes, it IS the block building and rendering. This is just a start, but the whole thing needs to be revamped.

AttachmentSizeStatusTest resultOperations
drupal.dashboard-block-region-perf.patch5.03 KBIdleFailed: Failed to apply patch.View details | Re-test
bench-head.txt1.3 KBIgnoredNoneNone
bench-patch.txt1.3 KBIgnoredNoneNone

#4

janusman - November 3, 2009 - 21:07

Confirming it's slightly faster with the patch... but just slightly.

ab -c1 -n100 -C [session cookie] http://localhost/admin/dashboard
unpatched: 6.69 req/sec
patched: 6.76 req/sec

#5

moshe weitzman - November 9, 2009 - 20:18

Could you elaborate on the problem with block building and rendering? We don't usually have many blocks on a page so I would surprised if thats a significant contributor.

#6

catch - November 10, 2009 - 03:17

I think when you look at a call graph, block rendering includes the rendering of the main content block, so that's probably what's showing up, but haven't looked into it much.

We are currently attempting to render the dashboard on every single page though, which is stupid.

@sun - can you re-roll without the call_user_func_array() changes?

#7

David_Rothstein - November 10, 2009 - 15:47

We are currently attempting to render the dashboard on every single page though, which is stupid.

As far as I recall, we specifically make sure not to render it - see http://api.drupal.org/api/function/dashboard_block_info_alter/7

So I'm not sure I understand how this issue is about anything more than micro-optimization? (Not to say that it isn't worth doing, of course, but I don't understand how this would lead to major performance improvements.)

#8

catch - November 11, 2009 - 02:08

Here's what shows up when viewing the front page.

AttachmentSizeStatusTest resultOperations
screenshot_001.png32.32 KBIgnoredNoneNone

#9

sun - November 11, 2009 - 04:12

Without cufa() changes.

AttachmentSizeStatusTest resultOperations
drupal.dashboard-block-region-perf.9.patch2.49 KBIdlePassed: 14694 passes, 0 fails, 0 exceptionsView details | Re-test

#10

David_Rothstein - November 11, 2009 - 05:01

Looks about right to me.

What is the rationale for using static rather than drupal_static() here?

#11

David_Rothstein - November 11, 2009 - 05:02
Title:Dashboard, and region and block building + rendering eats our performance» Dashboard, region and block building have unnecessary function calls
Priority:critical» normal

Much more accurate title and priority, IMO :)

#12

sun - November 11, 2009 - 05:10

What's the rationale for using drupal_static?

#13

Dries - November 11, 2009 - 08:52
Status:needs review» fixed

Committed to CVS HEAD. Thanks!

#14

David_Rothstein - November 11, 2009 - 14:25
Status:fixed» needs review

Well, I thought the default policy was to use drupal_static() unless there is a really good reason not to... but the reality is that there is no policy :)

In any case, I think we do need it for dashboard_regions() since the results of that function come from module_invoke_all(), so it seems like they could change. Probably don't need it for dashboard_is_visible().

AttachmentSizeStatusTest resultOperations
dashboard-drupal-static-619902-14.patch672 bytesIdlePassed: 14705 passes, 0 fails, 0 exceptionsView details | Re-test

#15

scroogie - November 13, 2009 - 15:45

I thought the policy is to use drupal_static only where you need to be able to reset the cache in special situations (those situations where a $reset parameter was formerly used). If you wouldn't have used a $reset parameter before, you wouldn't use a drupal_static now. So as sun noted, the question should always be: What's the rationale for using drupal_static? instead of the other way around.
About the module_invoke_all(). Can't this only change if a new module is activated? In that case it would be before dashboard_regions() is called for the first time, or not?

#16

David_Rothstein - November 14, 2009 - 22:55

Well, module_enable() can be called at any time in a page request or while running a script, and we can't predict when that will be in relation to anything else...

#17

sun - November 14, 2009 - 23:28

1) A script doesn't count, because you won't see a dashboard without a UI.

2) If you expect that module_enable() will have any effect within the same request... then you have strange expectations IMHO. Drupal's overall caching doesn't allow for that. Arbitrary results is all what you may get, depending on when during the request you invoke it. Even if you convert to a drupal_static here, who will reset this static when a module is enabled?

#18

catch - November 30, 2009 - 07:55
Title:Dashboard, region and block building have unnecessary function calls» Use drupal_static() in dashboard_regions()
Priority:normal» minor
Issue tags:-Performance

No longer a performance issue.

 
 

Drupal is a registered trademark of Dries Buytaert.