The attached script loads all includes and modules and writes every functon into its own include file. The patch that will follow teaches Drupal how to work in split mode. To engage split mode at this moment you need to add 'split_mode' => 1 to $conf.

Comments

chx’s picture

StatusFileSize
new8.19 KB

Here is the patch. I really worked hard on change as little as possible. Because it is possible that split.php will be sentenced to contrib for Drupal 4.7 cycle, and that's fine but core should be ready for it.

chx’s picture

StatusFileSize
new7.35 KB

New, even smaller patch. Script follows.

chx’s picture

StatusFileSize
new6.24 KB

Of course, the script got a bit bigger...

chx’s picture

StatusFileSize
new6.4 KB

With .txt extension.

If you read the code, you'll see I do a strange dance with module.inc because I load all if its functions anyways, so why split? This way the function_exists in module_hook gets rewritten to drupal_function_exists but only in split module. So, drupal_function_exists is a) moved to split.inc b) need not to check for split_mode all the time.

chx’s picture

StatusFileSize
new8.41 KB

Another run... drupal_get_title was a tough one. But the solution is, IMO, quite elegant.

chx’s picture

StatusFileSize
new6.43 KB
chx’s picture

StatusFileSize
new8.98 KB

Modified further drupal_bootstrap so it's simpler now but still returns the remaining phases. Allowed me to remove a few bytes from index.php, so it's again under 700 bytes. Note: the comments in index.php is not up to par anymore.

chx’s picture

StatusFileSize
new8.43 KB

Back to #5 -- the patch in #7 is bogus. Better docs though.

asimmonds’s picture

Is this against 4.6.3 or HEAD?, as the issue version says 4.6.3 but the patches are for HEAD.

Anyways, in trying it against HEAD, patch #8 applies and split.php #6 executes OK.

Came across 3 problems so far:
- In admin/logs, admin/path and admin/user I get: Warning: preg_replace_callback() requires argument 2, '_unicode_caseflip', to be a valid callback in \files\split\dr\drupal_strtoupper.inc on line 8

- In admin/filters/add I get: Warning: uasort(): Invalid comparison function. in \files\split\fi\filter_list_all.inc
(I think some of the split functions are not finding they callbacks)

- Apache PHP module crashes when I try to create content eg node/add/page. I don't get a entry in apache's error.log, but the last file read before the crash is: \files\split\me\menu_parent_options.inc

Everything else I tried seemed to work OK, haven't looked at the code yet.

Test enviroment is: Apache 1.3.33/PHP 4.4.0 under windows with current HEAD

chx’s picture

Version: 4.6.3 » x.y.z
StatusFileSize
new6.47 KB

Of course it's against HEAD. Thanks for review. Please try ab. I added the two mentioned functions to exceptions in split.php. I will inspect the node add problem.

gábor hojtsy’s picture

Looking at pacth #8 (not trying it, just examining the diff), my only suspicious part is the system module change. Why does that add a function_exists(), while all other parts remove these and add module_exists() and module_invoke()?

chx’s picture

I think you mean remove module_* The module_invoke call won't work now because it calls module_hook which now checks whether module_exist and module_list() does not contain all modules. This check is new but won't break anything else because you are not supposed to force load not switched on modules.

The other function_exists are not removed but changed to module_exist because if you look into the script you'll see that function_exists gets changed to drupal_function_exists which is not module aware. Generally, you should use module_* to interact with a module.

chx’s picture

StatusFileSize
new8.37 KB

Introducing another var, split_dir, defaults to split. Bart is right in that I should meddle with files.

chx’s picture

StatusFileSize
new6.37 KB

The script got smaller with the new var. Yay!

bart jansens’s picture

The patch looks good

I ran some quick tests, benchmarked the index.php page of a default drupal install. Using split mode was almost twice as fast as without. I did the same after I enabled all core modules, this time it was more than five times as fast. Of course this was a special situation; no opcode cache and a very simple page, but it shows some promising results.

I still encountered a few problems though:
- after changing the site status to offline, users get
Fatal error: Call to undefined function: drupal_site_offline() in /home/jabart/public_html/drupal/index.php on line 24

- on q=admin/comment/configure:
warning: array_filter(): An error occurred while invoking the filter callback in /home/jabart/public_html/drupal/files/split/el/element_children.inc on line 2.

warning: implode(): Bad arguments. in /home/jabart/public_html/drupal/files/split/fo/form_get_error.inc on line 7.

chx’s picture

Thanks, Bart. Currently, my focus is on getting the split patch in.

Drupal_site_offline needs some thinking, but as it is very small, I will probably add it to exceptions.

I will check whether the other error occurs in HEAD... I can't see why the split mode would cause that, the relevant functon (element_child) is in exceptions, it's always loaded.

beginner’s picture

A big +1 for this feature, for the reasons highlighted here:
http://drupal.org/node/32262#comment-53036

eaton’s picture

+1 for compatability so far. I haven't looked closely at the memory aspect of it, but installed it on a stock 4.7 and have been poking around the system. No problems.

chx’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new8.85 KB

As a patch, I really feel it's ready. The only change is reroll against current HEAD.

chx’s picture

Still applies with some offset. Instructions: apply http://drupal.org/files/issues/split_5.patch , create an apache writeable 'split' dir, add $conf = array('split_dir' => 'split' , 'split_mode' => 1); to settings.php and run http://drupal.org/files/issues/split.php_2.txt

chx’s picture

StatusFileSize
new7.02 KB

Rerolled so that it applies without offset.

Note: script does not work with .theme files yet. I should add them. And probably .php , too.

tsk1979’s picture

Category: feature » support

Hi chx,
I am facing the drupal memory exausted problem. since I am on a shared server and cannot be allocated more than 16M of memory, this patch looked interesting. currently I am 4.6.4, is there a consise HOWTO on the steps needed to install this patch. do I have to do anything with my php installation etc., or will it work on the same PHP5 installation.

chx’s picture

can not work w/ 4.6.4 that version does not have the necessary capabilities.

killes@www.drop.org’s picture

Category: support » feature

It is still a feature. :)

Wesley Tanaka’s picture

+1

beginner’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new8.08 KB

I rerolled the patch.

A few hunks failed.

In particular, I couldn't replace the following code, because apparently the whole block has disappeared.

<code>*** 571,577 ****

    if (!isset($title)) {
      // during a bootstrap, menu.inc is not included and thus we cannot provide a title
-     if (function_exists('menu_get_active_title')) {
        $title = check_plain(menu_get_active_title());
      }
    }
--- 576,582 ----

    if (!isset($title)) {
      // during a bootstrap, menu.inc is not included and thus we cannot provide a title
+     if (!drupal_bootstrap()) {
        $title = check_plain(menu_get_active_title());
      }
    }


But I think it would work as well as the previous patch.

beginner’s picture

Status: Needs review » Needs work

Well, it's probably out of sync again.

LAsan’s picture

Version: x.y.z » 7.x-dev

chx: Is this patch implemented?

Moving to cvs.

Susurrus’s picture

Hasn't this been superceded by the Registry?

#221964: Registry

Crell’s picture

Status: Needs work » Closed (duplicate)

This has been superseded by the D6 page split and the D7 Registry.