Fast, Low Memory Drupal 5 System Module

A drop-in replacement for the system.module of Drupal 5.23 which makes your Drupal 5 site use less memory and may even make it faster. The one test that I ran suggested that I got:

3% faster performance

5% less memory

If this sounds interesting, please feel free to install this and try it out. I'd be especially interested to hear feedback as to whether this makes any difference at all if you have an opcode cache installed. If it works for you, you might be interested in downloading my other low memory modules as well.

Performance Benchmark (5.2 version)

This version of the module performs around 3% faster than the stock module in my single test:

Benchmark run on stock Fedora 7 with Apache 2.2.4 (httpd-2.2.4-4.1.fc7) and MySQL 5.0.37 (mysql-server-5.0.37-2.fc7), using ab -n 200 http://hostname/user on a development copy of this site.

Memory Benchmark (5.2 version)

This module saved 538K memory or 5% of overall site memory usage in the only test I ran.

Using the same setup as above, and testing the same page (the user login page), I added an echo memory_get_usage(); to the end of Drupal's index.php. Without the patch, it printed 11129644, or 10.61MB. With the patch, it printed 10578956, or 10.09MB, a savings of 538K or 5%. This savings won't be realized on the administration pages.

Caveat Emptor

This patch removes several functions from system.module which are technically "public" functions by Drupal's convention, because they don't start with an underscore. If you have code which relied on one of those functions that got removed, and you're interested in using this, please leave a comment below.

I haven't thoroughly tested all of the administration functions covered by the system module. If you run into a problem which you believe to be caused by this module, please also leave a comment below.

As this code is based on Drupal, which is licensed under the GPL, this code is also licensed under the GPL, which means (in the word of said license):

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Installation (whole module version)

To install, simply download the archive, unpack it, and put the files in your modules/system directory. The system.module from the archive will replace the stock drupal system.module.

If you're on a command line, you can do so by switching into the drupal installation directory (running ls should show index.php and cron.php), and running:

PS I did notice when I tried to find this article again on your site I was not able to find it and had to refer to my bookmark. It seems like an important contribution and should be displayed more prominently. :) Of course I could have just missed an obvious link.

Thanks for the feedback, and that's a good point. I've created fast, low memory versions of serveral modules, which you can now find linked from my drupal page. I'd love to hear your experience with those as well.

If you are doing a fresh install, use the original system.module file first or you will get errors. Also, the Gallery module that integrates G2 with Drupal requires the original system.module file as well. I am unsure which functions are required but I got a blank page for the General Settings page of the module while using the modified system file.

The .patch.bz2 files are exactly that—patches for core. However, based on your suggestion and similar previous suggestions, I have submitted the Drupal 6 version to drupal.org. If you would like this patch to be applied to Drupal 6, please let the Drupal maintainers know by commenting on Drupal issue #455092. Definitely feel free to also submit this Drupal 5 patch on drupal.org and advocate for it to be included in Drupal 5.

This website has been doing well for year, more than 10000 visits a day, but it suddenly shows thousand of error pages everyday, and even after having disabled all the useless modules it still shows errors.

This is a drupal 5.19 install, I couldn't find what are the modules causing memory problem. My host (dreamhost) told me that this website is using too much memory on my VPS set up to 4000 MB.

I am really desperate and don't know what to do.

Something weird is that even when I put this website in maintenance mode i still get errors on others websites which have less than 100 visitors a day, is it normal ?

I wish you could help me somehow, because i really don't know what to do after installing your modules.

With great interest i read your blog post, but i see nothing more then just claims and speedtests. Can you please be a little more elaborate in WHAT your patches do to speedup D6 it might help you to actually get them into the core.

With just saying it is faster, just download and see yourself you are not really winning my attention. I for one, like to know what i'am downloading, what is doing, why it is better then stock etc. etc. Just like the pressflow people do, they claim and explain why there D6 is different and potentially faster.

Oh and do some real life tests with different modules, content etc etc. like mentioned above by other people.
It does not really matter where you test it on, just make sure that your test setup is consistent, that is more important then testing it on 10 different machine's :)