Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 607792 - dev-lang/php: PHP installation from emerge is 4-8x slower than manual compilation
Summary: dev-lang/php: PHP installation from emerge is 4-8x slower than manual compila...
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-31 11:58 UTC by Ján Regeš
Modified: 2017-02-04 00:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ján Regeš 2017-01-31 11:58:29 UTC
Hi,

sorry for this query, but do you know, why is PHP installation by emerge 4-8x slower than with manual installation from sources by configure && make && make install?

Emerge for same PHP version 7.1.1 take about 10-15 minutes, manually installed for 2-3 minutes.

We have 4 cores/8 HT CPU (Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz).

My comparation is only about emerge PHP single package (all dependencies are already installed) and manually installed with same dependecies/enabled flags.

Emerge and manual installation grab and saturate all CPU cores to 100%. So, probably it is not about misconfigured all-cpu usage flags (makeopts).

About emerge:
=============

emerge -av dev-lang/php

/etc/portage/make.conf (relevant part):
---------------------------------------
CFLAGS="-O2 -pipe -march=nocona"
CXXFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
FEATURES="parallel-fetch"
MAKEOPTS="-j8"

About manual installation:
==========================

manual install script:
----------------------

cd php-7.1.1

CFLAGS="-march=nocona -O2 -pipe" \
CHOST="x86_64-pc-linux-gnu" \
./configure \
    --prefix=/opt/php7 \
    --sysconfdir=/opt/php7/etc \
    --with-pdo-mysql=mysqlnd \
    --with-sqlite3 \
    --enable-ftp \
    --enable-soap \
    --enable-sockets \
    --enable-bcmath \
    --enable-opcache \
    --with-curl \
    --with-imap=/usr \
    --with-imap-ssl=/usr \
    --with-jpeg-dir=/usr/include \
    --with-zlib-dir=/usr/include \
    --with-gd \
    --with-freetype-dir=/usr/include \
    --with-mcrypt \
    --with-ldap \
    --with-tidy \
    --with-openssl \
    --with-xsl \
    --with-xmlrpc \
    --enable-exif \
    --enable-zip \
    --enable-mbstring=all \
    --enable-fpm \
    --with-fpm-user=httpd \
    --with-fpm-group=httpd

make clean
make --jobs=8 && make install --jobs=8
Comment 1 Matthew Schultz 2017-02-01 13:45:29 UTC
You should post emerge --info so the developer knows what use flags you're using under emerge.
Comment 2 Michael Orlitzky gentoo-dev 2017-02-01 13:56:24 UTC
PHP has a bunch of different "SAPIs", which are just different ways that you can run it. We have the following SAPIs, all controlled by USE flags: embed cli cgi fpm apache2 phpdbg. The ebuild for dev-lang/php builds them one at a time, so how long the build takes depends on how many of those flags you have enabled.

The default upstream is to build only the CLI, so if you (on Gentoo) also build for "apache2", it will take twice as long. If you build both the "fpm" and "apache2" SAPIS in addition to the CLI, it will take three times as long, etc.

It may be possible to speed things up -- I don't know why the ebuild loops through them all one-at-a-time. I'll have to change it and see what breaks =)
Comment 3 Michael Orlitzky gentoo-dev 2017-02-01 14:11:04 UTC
Ok, that didn't take long. We have to build each SAPI separately to allow our slotting and eselect to work nicely. We have different php.ini files for each version of PHP, and each SAPI; for example, the CLI has a different php.ini than apache does (and that's important).

When we build PHP, we have to tell it where the INI file and extensions are located with

  --with-config-file-path=/etc/php/${sapi}-php${SLOT}"
  --with-config-file-scan-dir=/etc/php/${sapi}-php${SLOT}/ext-active

Those values get compiled in, and so we have to re-compile whenever they change, which is once per SAPI. Thus we're forced to recompile the whole thing a few times.

I hope that explains it -- I don't see a way to speed it up while keeping the separate php.ini files.
Comment 4 Ján Regeš 2017-02-01 17:47:46 UTC
Hi Michael,

thank you very much, for your great explanation! It makes sense :)

Below is my current emerge --info for php:7.1.

So, when i use PHP 7.1 only for PHP-PFM and CLI (Apache module is for PHP 5.6), best improvement is to setup USE flags "-apache2 -cgi" for php:7.1 slot. Right?

Thank you.

emerge --info dev-lang/php:7.1
==============================
Portage 2.2.28 (python 2.7.10-final-0, default/linux/amd64/13.0, gcc-4.8.4, glibc-2.20-r2, 4.0.5-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.0.5-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5-2643_0_@_3.30GHz-with-gentoo-2.2
KiB Mem:     8185460 total,   1650828 free
KiB Swap:    2000892 total,    941992 free
Timestamp of repository gentoo: Sat, 28 Jan 2017 21:15:01 +0000
sh bash 4.3_p33-r2
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.3_p33-r2::gentoo
dev-lang/perl:            5.22.3_rc4::gentoo
dev-lang/python:          2.7.10-r1::gentoo, 3.3.5-r1::gentoo
dev-util/cmake:           3.6.3::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.13.4::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.24-r3::gentoo
sys-devel/gcc:            4.8.4::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

steveeJ
    location: /var/lib/layman/steveeJ
    masters: gentoo
    priority: 50

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.cz.gentoo.org/gentoo-portage
    priority: 1000

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=nocona"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/spool/munin-async/.ssh"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/apache2-php5.6/ext-active/ /etc/php/apache2-php7.1/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cgi-php7.1/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/php/cli-php7.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=nocona"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=4"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.mirror.web4u.cz"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j9"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl acpi amd64 bash-completion berkdb big-tables bzip2 cli cracklib crypt cxx dri fontconfig fortran freetype gcj gd gdbm gif gnutls iconv inno innodb jpeg jpeg2k mmx modules multilib ncurses nls nptl openmp opentype pam parse-clocks pcre perl png python readline seccomp session sse sse2 ssl tcpd tiff truetype unicode upcall xattr zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_4 python3_5" RUBY_TARGETS="ruby21" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

dev-lang/php-7.1.1::gentoo was built with the following:
USE="acl apache2 bcmath berkdb bzip2 cgi cli crypt ctype curl exif fileinfo filter fpm ftp gd gdbm hash iconv imap json mysql opcache pdo phar posix readline session simplexml soap sockets sqlite ssl tidy tokenizer truetype unicode xml xmlreader xmlwriter zip zlib -calendar -cdb -cjk -coverage -debug -embed -enchant (-firebird) -flatfile -gmp -inifile -intl -iodbc -ipv6 -kerberos -ldap -ldap-sasl -libedit -libressl -mhash -mssql -mysqli -nls -oci8-instant-client -odbc -pcntl -phpdbg -postgres -qdbm -recode (-selinux) -sharedmem -snmp -spell -systemd -sysvipc -test -threads -wddx -webp -xmlrpc -xpm -xslt" ABI_X86="64"
Comment 5 Michael Orlitzky gentoo-dev 2017-02-02 01:24:08 UTC
(In reply to Ján Regeš from comment #4)
> Hi Michael,
> 
> thank you very much, for your great explanation! It makes sense :)
> 
> Below is my current emerge --info for php:7.1.
> 
> So, when i use PHP 7.1 only for PHP-PFM and CLI (Apache module is for PHP
> 5.6), best improvement is to setup USE flags "-apache2 -cgi" for php:7.1
> slot. Right?
> 

Right. If those flags were previously set, then unsetting them will save you two whole builds of PHP.