Memory profiling in hooks

Events happening in the community are now at Drupal community events on www.drupal.org.
btopro's picture

https://drupal.psu.edu/content/memory-profiling-hooks

Wanted to post this to this group as well about my investigation into the memory used by drupal's various hooks in a site that I'm developing. As a result of the monitoring I was able to find ways to either eliminate or mitigate many RAM zapping functions and hooks as well as finding ways to mitigate some other functions (like optimizing the core book module's navigation rendering capabilities).

I used this dropbucket of functions to do the profiling w/ devel to dpm the output dropbucket.org/node/2036

Comments

I read your article earlier

joelpittet's picture

I read your article earlier this week and it was great, thanks for sharing!

If you have an IDE that has conditional breakpoints you can avoid dpm() call and store the results for each hook into an array, sort the array and breakpoint at the end of the function. Same thing but different approach. It's nice because sorting the array can help surface the slow hooks to the top.

Here's one I did that is in the same vein for module_invoke_all (debugging performance issues with expire and authcache issues on hook_node_insert/update/delete)
https://gist.github.com/f22596ca587ffe009fb5

It's what litters this page of screenshots: https://www.drupal.org/node/2443049

Of course the pretty formatting to MB, KB, etc get's lost if you want to sort it... or you can get creative there and format after sort:)

Cheers

Thanks

znerol's picture

Thanks for sharing! I already wondered how you took those screenshots, but it did not occur to me that this could be so simple :)

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: