php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77622 PHP is slow at some point (because of huge page ?)
Submitted: 2019-02-15 10:03 UTC Modified: 2019-02-18 13:09 UTC
From: lyrixx at lyrixx dot info Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.2.15 OS: linux
Private report: No CVE-ID: None
 [2019-02-15 10:03 UTC] lyrixx at lyrixx dot info
Description:
------------
Hello,

When my computer becomes low on RAM, PHP becomes really slow.

When I strace (sudo strace -p 2865  -f -T -tt) a composer update for exemple, I can see the following :

10:53:01.519555 mmap(NULL, 136314880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4349000000 <0.000006>                                                 
10:53:01.519581 munmap(0x7f4351001000, 2093056) = 0 <0.000009>                                                                                                            
10:53:01.519610 madvise(0x7f4349000000, 134221824, MADV_HUGEPAGE) = 0 <0.000008>                                                                                          
10:53:28.714302 munmap(0x7f436a800000, 67112960) = 0 <0.003810>                                                                                                           
10:53:28.718243 mmap(NULL, 150994944, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4340000000 <0.000022>                                                 
10:53:28.718346 madvise(0x7f4340000000, 150994944, MADV_HUGEPAGE) = 0 <0.000058>                                                                                          
10:53:39.676726 munmap(0x7f435be00000, 75497472) = 0 <0.003604>                                                                                                           
10:53:39.768176 mmap(0x7f4364601000, 67108864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f436aa00000 <0.000026>                                        
10:53:39.768288 munmap(0x7f436aa00000, 67108864) = 0 <0.000014>                                                                                                           
10:53:39.768333 mmap(NULL, 134221824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4337fff000 <0.000010>                                                 
10:53:39.768371 munmap(0x7f4337fff000, 134221824) = 0 <0.000009>                                                                                                          
10:53:39.768407 mmap(NULL, 136314880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4337e00000 <0.000011>                                                 
10:53:39.768446 munmap(0x7f433fe01000, 2093056) = 0 <0.000012>
10:53:39.768484 madvise(0x7f4337e00000, 134221824, MADV_HUGEPAGE) = 0 <0.000009>
10:53:43.449465 munmap(0x7f4360600000, 67112960) = 0 <0.003008>
10:53:43.493691 mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f436e800000 <0.000012>

an theses calls are very slow. During theses call one core of my CPU is at 100% and I have some free RAM 

I usually close my browser to "fix" this issue, but it's not convenient...

I have seen similar issue https://bugs.php.net/bug.php?id=70984 or https://bugs.php.net/bug.php?id=76867

And I tried to run sudo sysctl -w vm.nr_hugepages=512 But without success 

======================================

## PHP Version

PHP 7.2.15-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:38:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.15-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.24.4~linux-x64-non_zts72, https://blackfire.io, by Blackfire

## Compilations options

php-config  --configure-options
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-cli --disable-cgi --disable-phpdbg --with-config-file-path=/etc/php/7.2/cli --with-config-file-scan-dir=/etc/php/7.2/cli/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --config-cache --cache-file=/build/php7.2-qjOCut/php7.2-7.2.15/config.cache --libdir=${prefix}/lib/php --libexecdir=${prefix}/lib/php --datadir=${prefix}/share/php/7.2 --program-suffix=7.2 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-all --disable-debug --disable-rpath --disable-static --with-pic --with-layout=GNU --without-pear --enable-filter --with-openssl=yes --with-password-argon2=/usr --with-pcre-regex=/usr --enable-hash --with-mhash=/usr --enable-libxml --enable-session --with-sodium --with-system-tzdata --with-zlib=/usr --with-zlib-dir=/usr --enable-dtrace --enable-pcntl --with-libedit=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fdebug-prefix-map=/build/php7.2-qjOCut/php7.2-7.2.15=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -pedantic -fsigned-char -fno-strict-aliasing -g


## OS

$ uname -a
Linux gregoire 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-18 13:09 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-02-18 13:09 UTC] nikic@php.net
I've disabled the use of MADV_HUGEPAGE by default in https://github.com/php/php-src/commit/928c42211f737640e4dc3c9702ba833c3059bddf. This is not the first reports of large slowdowns due to MADV_HUGEPAGE, so it's best to be conservative here.
 [2019-02-19 15:43 UTC] lyrixx at lyrixx dot info
Thanks
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Mar 24 13:01:25 2019 UTC