[drupal-devel] Speed of Drupal, memory usage, and all that stuff

Gerhard Killesreiter killesreiter at physik.uni-freiburg.de
Wed Feb 2 17:21:33 UTC 2005


Hi there,

those of you who have been following Drupal's development for some time
will know that I've always been interested in making Drupal faster. Some
other people have expressed interest in making Drupal use less memory,
especially on the admin/modules page where currently all present modules
are included.

I've recently experimented a bit and came up with a solution that
achieves both goals. You can look at it in the speed-drupal directory in
my sandbox. There is also an issue with the title "Make Drupal faster"
where I described my results.

I reduced the amount of lines of code that gets included and parsed by
PHP on each page call by moving most of a module's code into .inc files
and only leaving small wrappers for the functions in the .module file.

The result is fully functional and achieves both goals. I still don't
like it much because having both a wrapper and a function in a .inc
file isn't really nice.

That is why I thought about another approach:

On calling admin/modules we should not include the modules, but include
a small .functions file. This file should (for each module) tell us
which functions are defined in which file. By this approach it would be
possible to split each file up in a number of small files and still let
Drupal know where the functions are defined. The array of
functionname->file associations will be stored and if a function is
called through a wrapper such as module_invoke Drupal would be able to
include the neccessary file and execute the function. This would of
course require that module authors call all external functions through
module_invoke.

A second step of optimisation would be to define the operation of each
hook that is implemented. For example a module might only implement the
'delete' operation of the _nodeapi hook. Then it would not be neccessary
to include any file if the 'view' operation of that hook is invoked.
This is very important for the _help hook which has a lot of code[1].

As a closing remark I need to state that the whole code parsing issue is
of little concern if you run your own server and can install a PHP
cache. Those caches keep the generated byte code in memory (either
virtual or in files) and thus make all this effort pretty much
unneccessary.

Since I do now run my own server, I have little personal use for either
of the outlined approaches and will only work on it if I see good
chances to get it into Drupal 4.7.

Discussion is welcome.

Cheers,
	Gerhard

[1] Actually I think we could get rid of the help hook for most help
    messages by using drupal_set_message with a help status
    (drupal_set_message('I am your helpfull message', 'help')).




More information about the drupal-devel mailing list