Drupal $GLOBALS
Has anyone ever put
<span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #007700">die(</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">)); <br></span><span style="color: #0000BB">?></span></span>
up at the top of their Drupal template page.tpl.php? If I were to print my var_dump source, it would be 181 pages. Granted when you var_dump $GLOBALS, there is some recursion, but that still seems like a lot of variable generation.
I can think of a couple things to do, namely more aggressive unset use, more discouraged use of the global keyword, or just putting to RAM what is actually needed.
AFAIK, Drupal loads every variable stored in the database to memory on every page load. I hope I'm wrong about that. It seems to me like a properly indexed database would be quicker if it only pulled variables it needed on every page load plus what a specific module needs for its operation. Someone should benchmark (which will probably end up being me if I want to know the answer) to see if storing Drupal core vars as a serialized string would be faster to unserialize or to pull from several database rows.
Is it an issue? I can't tell from just the preliminary var_dump output, but perhaps spending some time with APD will uncover some waste I can submit a patch for. I doubt developers are spending a lot of time comparing alternative scripting implementations for speed improvement.
Post categories