-
Replaces
require_oncewithinclude_oncemaking it more robust to module erroneous calls. - Errors due to missing files are shown as warnings: better warn the module developers that they did an error than letting them silent.
-
Removed the surrounding
if(is_file())making this code 100% I/O free when used with an opcode cache. Both PHP vanilla and opcode caches already optimize include statements for us, checking for the file existence is bypassing this optimization.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 1978592-29-module_load_include-is_file.patch | 470 bytes | pounard |
| #21 | 1978592-21-module_load_include-performance.patch | 830 bytes | soul88 |
| #18 | 1978592-17-module_load_include-performance.patch | 855 bytes | soul88 |
| #15 | 1978592-15-module_load_include-performance.patch | 945 bytes | soul88 |
| #12 | 1978592-12-module_load_include-is_file.patch | 470 bytes | pounard |
Comments
Comment #1
pounardComment #3
pounard#1: 1978592-1-module_load_include-is_file.patch queued for re-testing.
Comment #5
soul88Got the same problem with Commons distribution. waiting for is_file to complete takes 15-20% of page load time on the most heavy pages (ex.: groups)
Comment #6
soul88seems that it's strongly related to this: https://drupal.org/node/752730
Comment #7
soul88https://drupal.org/node/1524630
Comment #8
pounardThere is multiple reasons why this is not a duplicate:
module_load_include()only, because it's a very small change and can be safely done without being extensive over the systemComment #9
pounardOk spoke too quickly, closing in flavor of #1524630: replace is_file() + require_once() with include_once() for apc performance.I remebered now why I opened this bug, I was already following the others, and most of them have either been switched to D8, either being closed under other various assumptions. I read them all, I participated in most of them, and I opened this one in order to restrict the field of application of the global idea and make a less extensive, less intrusive although still efficient patch.
Comment #10
pounard#1: 1978592-1-module_load_include-is_file.patch queued for re-testing.
Comment #12
pounardI'm not fond of the @ operator but Drupal always attempt to load non existing files, which is a deeper problem. Thus the operator is mandatory for this very simple patch to work.
Comment #13
pounardComment #14
pounardYay green! Please anyone reviews :)
Comment #15
soul88I'd like to propose a bit more extended approach. I'm now working on Drupal Commons site and on some pages I have 1700+ calls of this function on the page. And only 34 of them have unique parameters. So I'd like to propose to add static cache additionally to the patch above. It saves me 0,3-1 sec per page load.
Comment #16
soul88Some details can be found here: https://drupal.org/node/2077375 (XHProf listings mostly)
Comment #18
soul88reroll
Comment #19
soul88changed status
Comment #21
soul88Comment #22
soul88Comment #23
pounardI actually did test the exact opposite, removing this kind of static cache from a few functions in core, and with APC it was quicker without, plus PHP consumed less memory. A decent OPcode cache will already do this static cache for you but at a lower level, and will be faster than you. I'd be curious to know if any is an OPcode cache enabled on your testing box?
Comment #24
pounardThis sound huge! I'd say you have a problem on your site. If you are using a basic commons distribution without modifications, then I'd say Commons has never been designed to perform great.
Comment #25
soul88replied in the post about Commons. APC is installed.
https://drupal.org/node/2077375
Comment #26
pounardI will do some benchmarks on my side installing a Drupal commons with Drupal vanilla, my patch and your patch (if I have time on multiple different boxes). Nevertheless I also will try to see why this function is being called so many time, it sounds like a bug to me.
Comment #27
Sylvain_G commentedThe patch on #21 causes Fatals error with i18n
https://drupal.org/node/2082573#comment-7832895
Comment #28
pounard21: 1978592-21-module_load_include-performance.patch queued for re-testing.
Comment #29
pounardComment #30
pounardThis actually works, please I need some reviews here.
Comment #31
soul88The last patch works great for me.
Comment #32
pounardI'm not confortable with proceeding with this without profiing a variety of different sites, some more reviews and some benchmarks/profiling traces would be helpful too! Thanks for testing.
Comment #33
soul88On my site I've got 70-110 "is_file" calls on the page that take 30-50ms. It's about 2% of page load time.
//PHP5.5 + cache opcode enabled
Comment #34
joelpittetThis seems like a better and maybe more comfortable solution for D7. #1443308-9: Add static cache to module_load_include()
@pounard maybe close as duplicate if you agree?
Comment #35
pounardI'm definitely not really happy with polluting Drupal with "Yet another static cache" whereas the optimization on that specific include call should be done by the VM or the OPCode, not us. In the other issue, did you do the same benchmarks as those exposed with a single include_once without static cache and without file_exists() ?
Comment #36
joelpittetIn the other issue I just tested before and after the patch.
I researched a bit alternatives but they all seem to have drawbacks with OPcode caching so I really didn't pay too much attention to them.
Comment #37
pounard"Seem" does not seem legit to me :) I'd be curious to see how it behave both of:
https://www.drupal.org/files/issues/1978592-29-module_load_include-is_fi... (#29)
and https://www.drupal.org/files/1978592-1-module_load_include-is_file.patch (#1)
compared to doing a static cache.
Comment #38
joelpittetThen you know what to do;) I don't see that being a big improvement so not interested in profiling this ATM. Feel free to see what gains you get.
Comment #39
pounardYes I agree I should probably do some benchmarks myself, will do if I find some time to do it.
Comment #40
pounard@Joelpittet did it, and https://www.drupal.org/node/1443308#comment-10688528 so I close this issue.