(See http://wtanaka.com/drupal/system-6 for more details)

This is a drop-in replacement for the system.module of Drupal 6.11 which makes Drupal 6 use less memory (on a stock OS install, I haven't tested with a PHP opcode cache/accelerator). On memory- and I/O- bound workloads, this reduction of memory seems to also translate into a speed and overall throughput improvement.

A test I ran in a development environment with a stock Drupal 6 installation (no custom modules enabled) suggested that I got:

* 2—4.4% reduction in average page load time
* 3% less memory

The patch preserves all "public" non-underscore functions inside the system.module namespace and also _system_theme_data() which is called from outside the system.module file despite starting with underscore.

I have tried my best to preserve exactly the semantics of the existing system.module with the exception of removing from the public namespace the rest of the underscore functions which are not called directly by core modules.

Comments

wmostrey’s picture

Version: 6.11 » 6.14

This is actually similar to what has already been done to the menu module to decrease overhead: http://drupal.org/node/146172. it is definitely worth another look.

niklp’s picture

Is this something that should be tagged with "Drupal 7" as well, or is it moot for that version?

damien tournoud’s picture

Status: Needs review » Postponed (maintainer needs more info)

Please post a proper patch. This cannot be reviewed.

swentel’s picture

Wesley Tanaka’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new152.53 KB

Could you either explain what you mean by proper, or explain what in particular about this patch is not proper? That patch should apply cleanly against Drupal 6.11. I am attaching one for Drupal 6.14. The patch is a fairly mechanical application of this process. It removes all underscore functions from the global function name space with the exception of _system_theme_data() which at the time I created the patch was called directly by another core module in violation of what I remember the Drupal function naming conventions to be.

Given the nature of the unified diff file format, I do not believe that it is possible to make the file size of this patch significantly smaller, but I would love to hear suggestions as to how to do that if there are any! I believe this is just one of those cases where a semantically and conceptually compact change does not translate into a storage-space-compact unified diff.

A similar thing has been tried before with chx's split module, with the exception in that case where I think that module created one separate file per function.

I do have a suggestion for a way to review that this patch is a semi-mechanical translation of system.module:

1. Apply the patch, but keep a backup of the original system.module
2. Diff system.module.orig against each of the new files to make sure that function bodies have not changed
3. Manually review function headers in the newly created files
4. Manually review the function headers in the new system.module

sinasalek’s picture

Interesting, subscribed

sun’s picture

Category: feature » task
Status: Needs review » Postponed (maintainer needs more info)

What are your benchmarks based on? Do/did you have an opcode cache (like APC) enabled or disabled?

crea’s picture

With opcode cacher memory will still be used by cached script anyway, but page loading time can improve, indeed.
Wesley, did you test with opcode cache on, like Sun asks ?
Also I suggest you to contact Pressflow guys: even if this improvement is small, it would be nice to include in Pressflow, if we can't have this in official D6.

Wesley Tanaka’s picture

Version: 6.14 » 6.15

The specific conditions of the test I ran are documented on http://wtanaka.com/drupal/system-6

No opcode cache was installed, I'm specifically interested in hearing feedback if this makes things worse, better, or does not change anything with an opcode cache installed.

The patch (also available at above url) has been updated for 6.15

Wesley Tanaka’s picture

crea: Feel free (beyond the fact that you're already free based on the terms of the GPL) to use this patched module in your Pressflow or in anything else as long as you abide by the GPL terms.

Wesley Tanaka’s picture

Status: Postponed (maintainer needs more info) » Needs review

I am not sure if I am supposed to change the status back myself now that I answered the questions. I will err on the side of assuming that I am supposed to.

crea’s picture

Wesley,
Ofcourse I can patch manually. That was not the point.I meant that you can discuss it with Pressflow guys and they include your patch in Pressflow.
Drupal has different goals, and maintainers won't risk compatibitility in exchange for small performance boost. For drupal compatibility > performance. Pressflow is whole different game: it trades compatibility in exchange for speed. That's why I suggested it.

It makes sense to rerun tests with opcode cache enabled. I never heard anyone running production sites without opcode cache. Even all newbie guides for running LAMP include installing one. So for test result to have any real value, it must be running in real world environment.

Wesley Tanaka’s picture

crea, these are great suggestions. I didn't mean you can patch your installations, I meant you can add the patch to (your?) Pressman project without needing to consult me.

However, it's not clear to me that you should do that. Like you say, I don't know of results of tests with an opcode cache enabled, so it might not be a win in that case. Presumably if it's a win without an opcode cache and a wash with one, you might consider including it, but if it's a win in one case and a loss in the other, you probably wouldn't want to include it.

If Pressman is interested in things like this, you might want to point them at this issue trail. Perhaps they have the time to spare and an stable opcode cache setup where they can run the opcode test that so many people seem to want to see the results of?

sun’s picture

Status: Needs review » Closed (won't fix)

No opcode cache was installed

In that case, you can stop hacking/patching core, because you can easily get a 20-40% boost by enabling an opcode cache like APC or XCache.

More information about this particular topic, splitting code, and Drupal core's direction can be found in:
#345118: Performance: Split .module files by moving hooks

If you want to help make Drupal faster by other means:
http://drupal.org/project/issues/search/drupal?status%5B%5D=Open&version...

vlad.k’s picture

subscribing

fabianx’s picture

subscribe