Running Drush on large sites can feel pretty slow (2-10 seconds in many cases). Clearly much of this is due to the time PHP takes to parse all the code. I would love to see if there are ways this can be improved.

PHP running on the web we can run APC or similar opcode caching to improve performance with dramatic results, however on the CLI you can't easily take advantage of that. You can set apc.enable_cli=1, but the opcode cache is dropped at the end of the CLI request, so that isn't really of direct use (except for testing APC key-value caching).

I did some investigating, however and found that recent versions of APC do in fact have a function to allow you to stash the opcode cache in a file and retrieve it later (this is intended for warming the caches of high performance web servers before coming on line). In principle that should work for Drush - see patch - but at least in my tests it always seemed to segfault PHP. Bummer.

The other idea I experimented with was running Drush as a daemon, and having a simple "client" app send commands and process user I/O. This is a little like the backend functionality, except that it runs commands in the same process, so you lose the isolation (of course many commands don't need the isolation) but you gain a huge speed advantage - subsequent commands took a fraction of a second because all the code is still in RAM. This approach worked OK for non-interactive commands, but for interactive stuff we would need to write/reuse some kind of protocol for handling the interaction, which may be quite a lot of work/complexity. The other problem is that if you run this as a system daemon you end up with all sorts of sketchy permissions issues, so you would probably need one daemon per website/user. Attached files are a very hacked up sketch of this.

I also thought a little about using the fcgid or native PHP cgi process management for the "daemon", but (f)CGI is not really suited to interactive stuff, so we end up with the same problem.

Does anyone have any thoughts on the above approaches, or other ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Not that familiar with it, but q0rbon came up with https://github.com/q0rban/drushd for a recent project. There are a couple more daemon projects at http://drupal.org/project/modules?filters=tid%3A4654&solrsort=sis_projec...

Owen Barton’s picture

Yes - I had thread forking working in my code also - it was pretty simple and worked fine, I took it out for testing though. The hard parts seem to be code reload/invalidation (perhaps have the fork live start transparently in the background and time out after a while), permissions (if systemwide), and most of all handling interactive user control (yes/no, select # etc). While I think it cold work well as a high performance cron type daemon or backend request handler alternative the drushd approach will get complex if you want to have it act exactly as it does on the shell (interaction, strout/err, colors, cwd response, table widths etc etc)

I think the APC approach is neater and simpler for regular execution. I was actually thinking that it would be best if APC implemented what I described internally - basically fixed the dump/load functions so they didn't segfault, and added a setting that saved the opcode at the end of each cli request in ~/.php.apc.cache (or whatever - it would have to be per user, for security though) and transparently loaded it for subsequent requests. Anyone know any APC developers ;)

sdboyer’s picture

FileSize
2.27 KB

I did some more tests on this. Turns out there are some fairly specific problems in APC, ones that'll hopefully be fairly easy to resolve. Assuming the bug report I filed is adequate.

I made some small additions to grugnog's original script, and noted that the segfaults only occur when we attempting to load dumps containing, specific files (specifically commands/core/cache.drush.inc and includes/table.inc). Have fun with the array_slice() I left in the patch, you can see it for yourself; I did my tests against revision 7c582a0 of drush. There are other errors that occur when attempting to dump a lot of the other files which do appear when you get the segfault-causers out of the way, but it seems like the files still dump in those cases.

sdboyer’s picture

Owen Barton’s picture

FileSize
1.13 KB

Nice detective work - I can confirm that I have same two problem files!

I dug a bit further and I think the problem when an undefined constant is used as a function argument default - for example in core.cache.inc if I change:

function drush_cache_set($cid = NULL, $data = '', $bin = NULL, $expire = CACHE_PERMANENT) {

to

function drush_cache_set($cid = NULL, $data = '', $bin = NULL, $expire = 0) {

- it works even if that file is not excluded from the cache.

I found a different issue in table.inc - php segfaults whenever a constant (even a defined one) is used inside a class.

I have produced a reduced testcase for both these issues - I will attach this to the PECL issue. Looks like gopalv responded on PECL and fingers crossed may take a look next week.

moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

We've added the commandfile cache which avoids a lot of dir scanning but all the converting to opcode is still present ... Could anyone prod that PECL person?

Owen Barton’s picture

Couldn't find Gopal in IRC (nick may be t3rmin4t0r it seems), so I e-mailed him just now. I'll update here if we hear anything back.

Owen Barton’s picture

I heard back from Gopal on IRC (he is no longer working on APC for his day job) and I e-mailed him the details. He also said "Will probably fix stuff in svn, it'll take me another month or so to land back home (Aug 12th), so don't expect a release right away.", so I am leaving this as postponed for now.

sdboyer’s picture

Well hey, that's something, at least...

moshe weitzman’s picture

Title: Ideas for improving Drush performance » Poke APC project so that opcode can persist when using CLI PHP.
pillarsdotnet’s picture

Status: Postponed (maintainer needs more info) » Needs work
FileSize
1.66 KB

Looks like this is fixed in trunk builds, at least.

bobvin@www:~$ wget -q http://drupal.org/files/issues/apc-segfault-php.txt
bobvin@www:~$ php apc-segfault-php.txt 
It ran!
bobvin@www:~$ php -v
PHP 5.5.0-dev (cli) (built: Jul 13 2011 01:29:35) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies

Unfortunately, after applying the attached patch, glibc still barfs:

bobvin@www:~$ drush status
 Drupal version                :  7.5-dev                         
 Site URI                      :  http://ifc.cfcmi.org/orgchart   
 Database driver               :  mysql                           
 Database hostname             :  localhost                       
 Database username             :  ifc                             
 Database name                 :  ifc                             
 Database                      :  Connected                       
 Drupal bootstrap              :  Successful                      
 Drupal user                   :  Anonymous                       
 Default theme                 :  ifc_theme                       
 Administration theme          :  seven                           
 PHP configuration             :  /home/bobvin/.drush/php.ini     
 Drush version                 :  5.0-dev                         
 Drush configuration           :  /home/bobvin/.drush/drushrc.php 
 Drush alias files             :                                  
 Drupal root                   :  /var/www                        
 Site path                     :  sites/ifc                       
 File directory path           :  sites/ifc/files                 
 Private file directory path   :  sites/ifc/private/files         

*** glibc detected *** /usr/local/bin/php: free(): invalid pointer: 0xf64b2d08 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6a81a)[0xf699e81a]
/lib/libc.so.6(+0x6c078)[0xf69a0078]
/lib/libc.so.6(cfree+0x6d)[0xf69a317d]
/usr/local/bin/php(destroy_zend_class+0x1ef)[0x83068b8]
/usr/local/bin/php(zend_hash_clean+0x6b)[0x83169d5]
/usr/local/bin/php[0x8118c41]
/usr/local/bin/php[0x81132cd]
/usr/local/bin/php[0x810b4bc]
/usr/local/bin/php[0x8311f4e]
/usr/local/bin/php[0x83159d5]
/usr/local/bin/php(zend_hash_graceful_reverse_destroy+0x1c)[0x8316aa3]
/usr/local/bin/php(zend_destroy_modules+0x35)[0x8310cfb]
/usr/local/bin/php[0x830cc80]
/usr/local/bin/php(php_module_shutdown+0x31)[0x82c5de1]
/usr/local/bin/php[0x8078e1d]
/lib/libc.so.6(__libc_start_main+0xe6)[0xf694ae16]
/usr/local/bin/php[0x80793a1]
======= Memory map: ========
08048000-088cd000 r-xp 00000000 ca:00 2097246                            /usr/local/bin/php
088cd000-08939000 rwxp 00885000 ca:00 2097246                            /usr/local/bin/php
08939000-08957000 rwxp 00000000 00:00 0 
0941c000-0b720000 rwxp 00000000 00:00 0                                  [heap]
ee29c000-ee29d000 r-xp 00000000 ca:00 3001309                            /usr/lib/gconv/ISO8859-1.so
ee29d000-ee29e000 r-xp 00001000 ca:00 3001309                            /usr/lib/gconv/ISO8859-1.so
ee29e000-ee29f000 rwxp 00002000 ca:00 3001309                            /usr/lib/gconv/ISO8859-1.so
ee29f000-ee2a6000 r-xs 00000000 ca:00 3001384                            /usr/lib/gconv/gconv-modules.cache
ee431000-ee43b000 r-xp 00000000 ca:00 1429889                            /lib/libnss_files-2.13.so
ee43b000-ee43c000 r-xp 00009000 ca:00 1429889                            /lib/libnss_files-2.13.so
ee43c000-ee43d000 rwxp 0000a000 ca:00 1429889                            /lib/libnss_files-2.13.so
f6300000-f6321000 rwxp 00000000 00:00 0 
f6321000-f6400000 ---p 00000000 00:00 0 
f644b000-f6476000 r-xp 00000000 ca:00 493999                             /usr/local/lib/php/20100525/xdebug.so
f6476000-f6478000 rwxp 0002b000 ca:00 493999                             /usr/local/lib/php/20100525/xdebug.so
f6478000-f65e7000 rwxp 00000000 00:00 0 
f65e7000-f65f6000 r-xp 00000000 ca:00 2983037                            /usr/lib/libtasn1.so.3.1.11
f65f6000-f65f7000 rwxp 0000e000 ca:00 2983037                            /usr/lib/libtasn1.so.3.1.11
f65f7000-f65fb000 r-xp 00000000 ca:00 2983671                            /usr/lib/libXdmcp.so.6.0.0
f65fb000-f65fc000 rwxp 00003000 ca:00 2983671                            /usr/lib/libXdmcp.so.6.0.0
f65fc000-f65fe000 r-xp 00000000 ca:00 2984332                            /usr/lib/libXau.so.6.0.0
f65fe000-f65ff000 rwxp 00001000 ca:00 2984332                            /usr/lib/libXau.so.6.0.0
f65ff000-f6600000 rwxp 00000000 00:00 0 
f6600000-f6603000 r-xp 00000000 ca:00 1425426                            /lib/libgpg-error.so.0.8.0
f6603000-f6604000 rwxp 00002000 ca:00 1425426                            /lib/libgpg-error.so.0.8.0
f6604000-f669c000 r-xp 00000000 ca:00 2983494                            /usr/lib/libgnutls.so.26.16.14
f669c000-f66a0000 rwxp 00098000 ca:00 2983494                            /usr/lib/libgnutls.so.26.16.14
f66a0000-f66b5000 r-xp 00000000 ca:00 2983917                            /usr/lib/librtmp.so.0
f66b5000-f66b6000 rwxp 00014000 ca:00 2983917                            /usr/lib/librtmp.so.0
f66b6000-f6703000 r-xp 00000000 ca:00 2982822                            /usr/lib/libldap_r-2.4.so.2.7.0
f6703000-f6705000 rwxp 0004c000 ca:00 2982822                            /usr/lib/libldap_r-2.4.so.2.7.0
f6705000-f6706000 rwxp 00000000 00:00 0 
f6706000-f6713000 r-xp 00000000 ca:00 2984543                            /usr/lib/liblber-2.4.so.2.7.0
f6713000-f6714000 rwxp 0000c000 ca:00 2984543                            /usr/lib/liblber-2.4.so.2.7.0
f6714000-f6715000 rwxp 00000000 00:00 0 
f6715000-f6737000 r-xp 00000000 ca:00 2984806                            /usr/lib/libssh2.so.1.0.1
f6737000-f6738000 rwxp 00021000 ca:00 2984806                            /usr/lib/libssh2.so.1.0.1
f6738000-f6768000 r-xp 00000000 ca:00 2984517                            /usr/lib/libidn.so.11.6.3
f6768000-f6769000 rwxp 0002f000 ca:00 2984517                            /usr/lib/libidn.so.11.6.3
f6769000-f676b000 r-xp 00000000 ca:00 1425434                            /lib/libkeyutils.so.1.3
f676b000-f676c000 rwxp 00001000 ca:00 1425434                            /lib/libkeyutils.so.1.3
f676c000-f6772000 r-xp 00000000 ca:00 2983440                            /usr/lib/libkrb5support.so.0.1
f6772000-f6773000 rwxp 00005000 ca:00 2983440                            /usr/lib/libkrb5support.so.0.1
f6773000-f678b000 r-xp 00000000 ca:00 2983690                            /usr/lib/libxcb.so.1.1.0
f678b000-f678c000 rwxp 00017000 ca:00 2983690                            /usr/lib/libxcb.so.1.1.0
f678c000-f678d000 rwxp 00000000 00:00 0 
f678d000-f67b1000 r-xp 00000000 ca:00 2983484                            /usr/lib/libexpat.so.1.5.2
f67b1000-f67b3000 rwxp 00023000 ca:00 2983484                            /usr/lib/libexpat.so.1.5.2
f67b3000-f67cf000 r-xp 00000000 ca:00 1425414                            /lib/libgcc_s.so.1
f67cf000-f67d0000 rwxp 0001b000 ca:00 1425414                            /lib/libgcc_s.so.1
f67d0000-f68b2000 r-xp 00000000 ca:00 2982494                            /usr/lib/libstdc++.so.6.0.16
f68b2000-f68b3000 ---p 000e2000 ca:00 2982494                            /usr/lib/libstdc++.so.6.0.16
f68b3000-f68b7000 r-xp 000e2000 ca:00 2982494                            /usr/lib/libstdc++.so.6.0.16
f68b7000-f68b8000 rwxp 000e6000 ca:00 2982494                            /usr/lib/libstdc++.so.6.0.16
f68b8000-f68bf000 rwxp 00000000 00:00 0 
f68bf000-f6930000 r-xp 00000000 ca:00 1425432                            /lib/libgcrypt.so.11.6.0
f6930000-f6933000 rwxp 00071000 ca:00 1425432                            /lib/libgcrypt.so.11.6.0
f6933000-f6934000 rwxp 00000000 00:00 0 
f6934000-f6a72000 r-xp 00000000 ca:00 1429888                            /lib/libc-2.13.so
f6a72000-f6a73000 ---p 0013e000 ca:00 1429888                            /lib/libc-2.13.so
f6a73000-f6a75000 r-xp 0013e000 ca:00 1429888                            /lib/libc-2.13.so
f6a75000-f6a76000 rwxp 00140000 ca:00 1429888                            /lib/libc-2.13.so
f6a76000-f6a79000 rwxp 00000000 00:00 0 
f6a79000-f6b9e000 r-xp 00000000 ca:00 2982821                            /usr/lib/libxml2.so.2.7.8
f6b9e000-f6ba3000 rwxp 00124000 ca:00 2982821                            /usr/lib/libxml2.so.2.7.8
f6ba3000-f6ba4000 rwxp 00000000 00:00 0 
f6ba4000-f6bda000 r-xp 00000000 ca:00 2982410                            /usr/lib/libxslt.so.1.1.26
f6bda000-f6bdb000 rwxp 00036000 ca:00 2982410                            /usr/lib/libxslt.so.1.1.26
f6bdb000-f6beb000 r-xp 00000000 ca:00 1426114                            /lib/libresolv-2.13.so
f6beb000-f6bec000 r-xp 00010000 ca:00 1426114                            /lib/libresolv-2.13.so
f6bec000-f6bed000 rwxp 00011000 ca:00 1426114                            /lib/libresolv-2.13.so
f6bed000-f6bef000 rwxp 00000000 00:00 0 
f6bef000-f6daf000 r-xp 00000000 ca:00 2983708                            /usr/lib/libmysqlclient.so.16.0.0
f6daf000-f6db1000 r-xp 001c0000 ca:00 2983708                            /usr/lib/libmysqlclient.so.16.0.0
f6db1000-f6df8000 rwxp 001c2000 ca:00 2983708                            /usr/lib/libmysqlclient.so.16.0.0
f6df8000-f6df9000 rwxp 00000000 00:00 0 
f6df9000-f6e55000 r-xp 00000000 ca:00 2984060                            /usr/lib/libcurl.so.4.2.0
f6e55000-f6e57000 rwxp 0005b000 ca:00 2984060                            /usr/lib/libcurl.so.4.2.0
f6e57000-f6e58000 rwxp 00000000 00:00 0 
f6e58000-f6e5a000 r-xp 00000000 ca:00 1425450                            /lib/libcom_err.so.2.1
f6e5a000-f6e5b000 rwxp 00001000 ca:00 1425450                            /lib/libcom_err.so.2.1
f6e5b000-f6e7f000 r-xp 00000000 ca:00 2982989                            /usr/lib/libk5crypto.so.3.1
f6e7f000-f6e80000 rwxp 00024000 ca:00 2982989                            /usr/lib/libk5crypto.so.3.1
f6e80000-f6f30000 r-xp 00000000 ca:00 2983421                            /usr/lib/libkrb5.so.3.3
f6f30000-f6f36000 rwxp 000b0000 ca:00 2983421                            /usr/lib/libkrb5.so.3.3
f6f36000-f6f6a000 r-xp 00000000 ca:00 2983208                            /usr/lib/libgssapi_krb5.so.2.2
f6f6a000-f6f6c000 rwxp 00033000 ca:00 2983208                            /usr/lib/libgssapi_krb5.so.2.2
f6f6c000-f6f7f000 r-xp 00000000 ca:00 1429884                            /lib/libnsl-2.13.so
f6f7f000-f6f80000 r-xp 00012000 ca:00 1429884                            /lib/libnsl-2.13.so
f6f80000-f6f81000 rwxp 00013000 ca:00 1429884                            /lib/libnsl-2.13.so
f6f81000-f6f84000 rwxp 00000000 00:00 0 
f6f84000-f6f86000 r-xp 00000000 ca:00 1426100                            /lib/libdl-2.13.so
f6f86000-f6f87000 r-xp 00001000 ca:00 1426100                            /lib/libdl-2.13.so
f6f87000-f6f88000 rwxp 00002000 ca:00 1426100                            /lib/libdl-2.13.so
f6f88000-f6fc4000 r-xp 00000000 ca:00 1425446                            /lib/libpcre.so.3.12.1
f6fc4000-f6fc5000 rwxp 0003b000 ca:00 1425446                            /lib/libpcre.so.3.12.1
f6fc5000-f6fe4000 r-xp 00000000 ca:00 2983347                            /usr/lib/libjpeg.so.62.0.0
f6fe4000-f6fe5000 rwxp 0001e000 ca:00 2983347                            /usr/lib/libjpeg.so.62.0.0
f6fe5000-f6ff4000 r-xp 00000000 ca:00 2984198                            /usr/lib/libXpm.so.4.11.0
f6ff4000-f6ff5000 rwxp 0000e000 ca:00 2984198                            /usr/lib/libXpm.so.4.11.0
f6ff5000-f7111000 r-xp 00000000 ca:00 2982568                            /usr/lib/libX11.so.6.3.0
f7111000-f7114000 rwxp 0011b000 ca:00 2982568                            /usr/lib/libX11.so.6.3.0
f7114000-f7115000 rwxp 00000000 00:00 0 
f7115000-f7198000 r-xp 00000000 ca:00 2983336                            /usr/lib/libfreetype.so.6.6.2
f7198000-f719c000 rwxp 00082000 ca:00 2983336                            /usr/lib/libfreetype.so.6.6.2
f719c000-f719d000 rwxp 00000000 00:00 0 
f719d000-f71da000 r-xp 00000000 ca:00 2988363                            /usr/lib/libt1.so.5.1.2
f71da000-f71dd000 rwxp 0003d000 ca:00 2988363                            /usr/lib/libt1.so.5.1.2
f71dd000-f71f2000 rwxp 00000000 00:00 0 
f71f2000-f7216000 r-xp 00000000 ca:00 1429883                            /lib/libm-2.13.so
f7216000-f7217000 r-xp 00023000 ca:00 1429883                            /lib/libm-2.13.so
f7217000-f7218000 rwxp 00024000 ca:00 1429883                            /lib/libm-2.13.so
f7218000-f723b000 r-xp 00000000 ca:00 1425445                            /lib/libpng12.so.0.44.0
f723b000-f723c000 rwxp 00022000 ca:00 1425445                            /lib/libpng12.so.0.44.0
f723c000-f7269000 r-xp 00000000 ca:00 2983253                            /usr/lib/libfontconfig.so.1.4.4
f7269000-f726b000 rwxp 0002c000 ca:00 2983253                            /usr/lib/libfontconfig.so.1.4.4
f726b000-f7289000 r-xp 00000000 ca:00 2982117                            /usr/lib/libgd.so.2.0.0
f7289000-f72a9000 rwxp 0001d000 ca:00 2982117                            /usr/lib/libgd.so.2.0.0
f72a9000-f72ad000 rwxp 00000000 00:00 0 
f72ad000-f72b9000 r-xp 00000000 ca:00 1425416                            /lib/libpam.so.0.82.3
f72b9000-f72ba000 rwxp 0000b000 ca:00 1425416                            /lib/libpam.so.0.82.3
f72ba000-f72bb000 rwxp 00000000 00:00 0 
f72bb000-f72ff000 r-xp 00000000 ca:00 3014673                            /usr/lib/i686/cmov/libssl.so.1.0.0
f72ff000-f7303000 rwxp 00043000 ca:00 3014673                            /usr/lib/i686/cmov/libssl.so.1.0.0
f7303000-f7465000 r-xp 00000000 ca:00 3014672                            /usr/lib/i686/cmov/libcrypto.so.1.0.0
f7465000-f747a000 rwxp 00162000 ca:00 3014672                            /usr/lib/i686/cmov/libcrypto.so.1.0.0
f747a000-f747d000 rwxp 00000000 00:00 0 
f747d000-f7484000 r-xp 00000000 ca:00 2983386                            /usr/lib/libltdl.so.7.3.0
f7484000-f7485000 rwxp 00007000 ca:00 2983386                            /usr/lib/libltdl.so.7.3.0
f7485000-f74aa000 r-xp 00000000 ca:00 2983626                            /usr/lib/libmcrypt.so.4.4.8
f74aa000-f74ad000 rwxp 00025000 ca:00 2983626                            /usr/lib/libmcrypt.so.4.4.8
f74ad000-f74b2000 rwxp 00000000 00:00 0 
f74b2000-f74d2000 r-xp 00000000 ca:00 3047434                            /usr/local/lib/libmemcached.so.7.0.0
f74d2000-f74d3000 rwxp 0001f000 ca:00 3047434                            /usr/local/lib/libmemcached.so.7.0.0
f74d3000-f74d4000 rwxp 00000000 00:00 0 
f74d4000-f74db000 r-xp 00000000 ca:00 1429896                            /lib/librt-2.13.so
f74db000-f74dc000 r-xp 00006000 ca:00 1429896                            /lib/librt-2.13.so
f74dc000-f74dd000 rwxp 00007000 ca:00 1429896                            /lib/librt-2.13.so
f74dd000-f74de000 r-xp 00000000 ca:00 2983185                            /usr/lib/libpspell.so.15.1.4
f74de000-f74df000 rwxp 00000000 ca:00 2983185                            /usr/lib/libpspell.so.15.1.4
f74df000-f7575000 r-xp 00000000 ca:00 2983184                            /usr/lib/libaspell.so.15.1.4
f7575000-f7579000 rwxp 00095000 ca:00 2983184                            /usr/lib/libaspell.so.15.1.4
f7579000-f757d000 rwxp 00000000 00:00 0 
f757d000-f75b3000 r-xp 00000000 ca:00 1425444                            /lib/libncurses.so.5.9
f75b3000-f75b6000 rwxp 00036000 ca:00 1425444                            /lib/libncurses.so.5.9
f75b6000-f75e6000 r-xp 00000000 ca:00 1425439                            /lib/libreadline.so.6.2
f75e6000-f75ea000 rwxp 00030000 ca:00 1425439                            /lib/libreadline.so.6.2
f75ea000-f75eb000 rwxp 00000000 00:00 0 
f75eb000-f75ee000 r-xp 00000000 ca:00 2984222                            /usr/lib/libmm.so.14.0.22
f75ee000-f75ef000 rwxp 00003000 ca:00 2984222                            /usr/lib/libmm.so.14.0.22
f75ef000-f75f0000 rwxp 00000000 00:00 0 
f75f0000-f75f7000 r-xp 00000000 ca:00 2199242                            /usr/local/lib/libsphinxclient-0.0.1.so
f75f7000-f75f8000 rwxp 00006000 ca:00 2199242                            /usr/local/lib/libsphinxclient-0.0.1.so
f75f8000-f7609000 r-xp 00000000 ca:00 2982408                            /usr/lib/libexslt.so.0.8.15
f7609000-f760a000 rwxp 00011000 ca:00 2982408                            /usr/lib/libexslt.so.0.8.15
f760a000-f761d000 r-xp 00000000 ca:00 2982571                            /usr/lib/libz.so.1.2.3.4
f761d000-f761e000 rwxp 00013000 ca:00 2982571                            /usr/lib/libz.so.1.2.3.4
f761e000-f7715000 r-xp 00000000 ca:00 2983566                            /usr/lib/libc-client.so.2007e.0
f7715000-f771c000 rwxp 000f6000 ca:00 2983566                            /usr/lib/libc-client.so.2007e.0
f771c000-f771d000 rwxp 00000000 00:00 0 
f771d000-f7732000 r-xp 00000000 ca:00 2982442                            /usr/lib/libsasl2.so.2.0.23
f7732000-f7733000 r-xp 00014000 ca:00 2982442                            /usr/lib/libsasl2.so.2.0.23
f7733000-f7734000 rwxp 00015000 ca:00 2982442                            /usr/lib/libsasl2.so.2.0.23
f7734000-f7735000 rwxp 00000000 00:00 0 
f7735000-f774a000 r-xp 00000000 ca:00 1426095                            /lib/libpthread-2.13.so
f774a000-f774b000 r-xp 00014000 ca:00 1426095                            /lib/libpthread-2.13.so
f774b000-f774c000 rwxp 00015000 ca:00 1426095                            /lib/libpthread-2.13.so
f774c000-f774e000 rwxp 00000000 00:00 0 
f774e000-f7757000 r-xp 00000000 ca:00 1426097                            /lib/libcrypt-2.13.so
f7757000-f7758000 r-xp 00008000 ca:00 1426097                            /lib/libcrypt-2.13.so
f7758000-f7759000 rwxp 00009000 ca:00 1426097                            /lib/libcrypt-2.13.so
f7759000-f7780000 rwxp 00000000 00:00 0 
f778e000-f7790000 rwxp 00000000 00:00 0 
f7790000-f7791000 r-xp 00000000 00:00 0                                  [vdso]
f7791000-f77ac000 r-xp 00000000 ca:00 1429890                            /lib/ld-2.13.so
f77ac000-f77ad000 r-xp 0001b000 ca:00 1429890                            /lib/ld-2.13.so
f77ad000-f77ae000 rwxp 0001c000 ca:00 1429890                            /lib/ld-2.13.so
ff966000-ff987000 rw-p 00000000 00:00 0                                  [stack]
Aborted
Owen Barton’s picture

@pillarsdotnet - did you have apc.enable_cli=1 and apc.stat=0 in your php.inc for cli? Otherwise it might look like it works, but this is cause the cache dump is not dumping anything (it only dumps non-stat'ed files). If this is the case, then you might try chopping out files/functions to determine what the new cause is (as we did before).

pillarsdotnet’s picture

@pillarsdotnet - did you have apc.enable_cli=1 and apc.stat=0 in your php.inc for cli?

Yes. Without apc.enable_cli=1 the code doesn't run (see my patch), and without apc.stat=0 I get very different error messages.

you might try chopping out files/functions to determine what the new cause is (as we did before).

Not today; maybe sometime later.

Owen Barton’s picture

Title: Poke APC project so that opcode can persist when using CLI PHP. » Use APC to persist opcode cache when using CLI PHP.

Got a nice e-mail from Gopal, the APC developer we have been e-mailing with, and he found some time to work on this during OSCON and committed the fixes to svn - Gopal++ :)

I just tested it out very briefly, using APC svn head, and it appears to work for me. The most recent patch at #11 did not work for me (empty cache file - I think it is taking array() literally, perhaps?) but the patch in #3 did. some very quick tests showed that this has a pretty reasonable effect - cutting execution time of "drush status" from about 1 second down to ~750ms - so roughly 25%, which is not an order of magnitude or anything, but I think still quite worthwhile. It would be interesting to hear from some others what effect this has on other systems.

sdboyer’s picture

AWESOME.

Did you look at memory usage at all? I'm suspecting usage would be the same for APC vs. non-APC, but I can hope...

I think a 25% boost on something like drush status is nothing to cry about - at least assuming you were running that outside of a bootstrappable drupal instance. The real benefits here pay off when drush is running on a big site with a lot of code to load, after all.

geerlingguy’s picture

I'm running drush commands via cron every minute or so, and have been noticing memory and CPU usage starting to increase as our server's load and bootstrap sizes have increased. Any update on the status of this? I'm running APC 3.1.9 on dev and production—would that be a good version to do some testing on?

sun’s picture

Issue tags: +APC

Tagging.

moshe weitzman’s picture

Version: » 8.x-6.x-dev

D8 is a bloated pig and really requires APC to load all those files. What are the next steps here?

geerlingguy’s picture

@moshe - looks like the patch in #3 needs a re-roll, and will work with APC 3.1.9 or later. If I get a chance, I'll try to test on one of my servers too.

Owen Barton’s picture

FileSize
1.1 KB

Here is the patch.

The bad news is that it appears PHP has regressed again - I am using APC 3.1.14 (the latest) with php 5.4 and get a similar "Exceeded bounds check in apc_bd_alloc_ex" message, both with the attached patch and the simplified test case. I have confirmed the APC fix for the previous issue http://news.php.net/php.pecl.cvs/16099 is still present in this version of PHP, so this must be a different underlying issue. My guess (looking at the changelogs) is that some change in 3.1.12 may have been the culprit, as this seems to have involved quite a bit of work on the dump/load functions.

Also, as I mentioned above - when I tested this, the improvement seemed very incremental - 25% at most. I think we should research other options as well.

- Zend OPcache (previously ZendOptimizerPlus) https://github.com/zendtech/ZendOptimizerPlus - this has been accepted into PHP 5.5 core and seems likely to become the most popular opcode cache. I was not able to identify if it has similar dump/load functions (I don't think so). This fork looks pretty promising however - https://github.com/TerryE/opcache/wiki/MLC-OPcache-details

- We can also investigate the "daemonized drush" approach discussed in the description. It occured to me that if we used the backend code to send requests and parse responses, it seems like this may be more achievable. It would still require a fair amount of work, but I think would be interesting.

greg.1.anderson’s picture

Status: Needs work » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this task to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.