Voting starts in March for the Drupal Association Board election.
As a relative newcomer, I'm just starting to get into Drupal code. I'm no PHP stud and not not savvy with MySQL nuances either. I'd like to use this avatar_selection module as an ongoing opportunity to try to improve performance for selecting and rendering the image list in the Manage page.
I just took a look at the code and here are some general thoughts.
- I see that you're doing some processing on each image as it's rendered. It might be best to do that sort of processing in a separate loop, or perhaps offer a checkbox to allow the user to decide whether the extra processing will be done during their session.
- When generating $avatars_list, the foreach loop copies the entire array, in memory and into the new $avatars_indexed array. There has to be a ton of overhead there with the 7500 images I'm sending into there (total memory footprint = 22500 images consuming about 22MB of RAM every time a page is rendered!). I tried changing $image to &$image but there wasn't any obvious effect.
- Note that the foreach statement seems to have the arguments backwards:
foreach ($avatars as $image => $name) should be
foreach ($avatars as $name => $image) no ? (PHP doc on foreach)
- I also changed the foreach to a for-loop with no perceived improvement.
- There are two indexes on the avatar_selection table, PRIMARY, and 'avatar'. Since one is redundant I removed PRIMARY. Any objection?
- We are planning to use OG and I appreciate the code in there, but we're not using weights and not assigning a unique name to avatars, so as a test I changed the selection to Order By avatar (which is indexed where 'weight' and 'name' are not), and I commented out anything related to those fields and replaced them with 'avatar'. There was no noticable improvement in performance.
Remember that these are just local experiments, not change proposals. Considering all of the apps in the world that operate on images I'm sure there is a way to optimize the selection of large sets of images and rendering of subsets one page at a time.
Comments welcome here about anything related to performance. Sound like a plan?