split mode
chx - October 29, 2005 - 11:20
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | base system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | chx |
| Status: | duplicate |
Description
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.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| split.php | 5.68 KB | Ignored | None | None |

#1
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.
#2
New, even smaller patch. Script follows.
#3
Of course, the script got a bit bigger...
#4
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.
#5
Another run... drupal_get_title was a tough one. But the solution is, IMO, quite elegant.
#6
#7
Modified further
drupal_bootstrapso 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.#8
Back to #5 -- the patch in #7 is bogus. Better docs though.
#9
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
#10
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.
#11
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()?
#12
I think you mean remove module_* The
module_invokecall won't work now because it callsmodule_hookwhich now checks whethermodule_existand 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.
#13
Introducing another var,
split_dir, defaults to split. Bart is right in that I should meddle with files.#14
The script got smaller with the new var. Yay!
#15
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.
#16
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.
#17
A big +1 for this feature, for the reasons highlighted here:
http://drupal.org/node/32262#comment-53036
#18
+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.
#19
As a patch, I really feel it's ready. The only change is reroll against current HEAD.
#20
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
#21
Rerolled so that it applies without offset.
Note: script does not work with .theme files yet. I should add them. And probably .php , too.
#22
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.
#23
can not work w/ 4.6.4 that version does not have the necessary capabilities.
#24
It is still a feature. :)
#25
+1
#26
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.
#27
Well, it's probably out of sync again.
#28
chx: Is this patch implemented?
Moving to cvs.
#29
Hasn't this been superceded by the Registry?
#221964: Registry
#30
This has been superseded by the D6 page split and the D7 Registry.