Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117318 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93068 invoked from network); 12 Mar 2022 18:41:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Mar 2022 18:41:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9EA1B180539 for ; Sat, 12 Mar 2022 12:05:55 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8495 185.67.36.0/23 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 12 Mar 2022 12:05:54 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 219FC240101 for ; Sat, 12 Mar 2022 21:05:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1647115553; bh=ukei4UDE+8X055mu6ZIeIcZSWVQQDiDSjs9Nep58c80=; h=Date:From:To:Subject:From; b=fr0O9sU7H1RUbrNo/kluybcYsB9OKrxlZaWIQ+2mRP5kyyjjscUOH+K4QUkau3ELq mX146wlr5t4MD993qvl0qQlvsxOnod5InU/ZBmGVa4IQKOEUyCMr8oOei+qtvZvcxI /V6kHczzH3cURzt6bG6A440y6YXKQDAYw/PutTWwr4q8+BLrtEERibmZQMgxgIfdRZ YvPkBAXGRqwq+yzM24MVo2g9QwgdAWUYE2GHQnEFFUJKw+cDD5utd1Tu0okWwBWfw3 EfLvLQVkxKWQriftfVx4bWdBOhx8z9V/lTAAzi0WX8QmtLWYZItomgi3AV9PJ895Xa 9A1rIxOR2W+tg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KGDM458wsz9rxV for ; Sat, 12 Mar 2022 21:05:52 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 12 Mar 2022 20:05:52 +0000 To: PHP internals In-Reply-To: References: Message-ID: Subject: Re: [PHP-DEV] LTO support From: thomas.pakkanen@posteo.de (=?UTF-8?Q?Thomas_Kr=C3=BCger?=) > In fact, it does not seem to work very well. Hi Go Kudo, I read about the LTO feature from GCC in the past, and in my opinion, LTO works have many years of improvement in the GCC, it works pretty good nowadays. But programmers of Open Source projects were really clever the last twenty years. I read about bench tests where larger projects changes from normal compiling to -lto in GCC and after large benchmarking, they do not have much performance benefits from LTO. They said in these reports that mostly the bottleneck which -lto solves, were not existing in these projects: Developers for example move critical codes in the past from the .c-files into the .h-headers, so GCC can inline them without having such a feature like -lto. Or there use parts of "single-file" approaches for projects in C which have same compiling results as with the feature -lto. So, I think LTO works fine now, but you need projects which have these kind of bottlenecks to benefit from LTO. :) Best regards, Thomas ps: Sorry, for two e-mails, Go, I was not able to press the right answer button in my email program. ^^ Am 12.03.2022 19:17 schrieb Go Kudo: > At present, PHP cannot be built using LTO (Link Time Optimization). > > LTO is a compiler feature that can improve performance by optimizing at > link time. > Chromium is also using this feature. > > https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html > > The reason for the LTO failure appears to be the Zend Engine's use of > GCC's > global register variables. Conversely, it is otherwise compatible with > LTO. > (except: opcache). > > I modified toolchain too to enable and validate LTOs outside of Zend > Engine > and OPcache: > > https://github.com/zeriyoshi/php-src/commit/b25c237837fec2f82d268d8dbd45ec886baf474f > > I tested the following compilation options: > > ``` > gcc: (Debian 10.2.1-6) 10.2.1 20210110 > CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -D_LARGEFILE_SOURCE > -D_FILE_OFFSET_BITS=64" > CXXFLAGS="${CFLAGS}" > LDFLAGS="-Wl,-O1 -pie" > $ ./sapi/cli/php ./Zend/bench.php > simple 0.010 > simplecall 0.005 > simpleucall 0.010 > simpleudcall 0.013 > mandel 0.052 > mandel2 0.049 > ackermann(7) 0.012 > ary(50000) 0.003 > ary2(50000) 0.002 > ary3(2000) 0.020 > fibo(30) 0.035 > hash1(50000) 0.004 > hash2(500) 0.004 > heapsort(20000) 0.012 > matrix(20) 0.012 > nestedloop(12) 0.010 > sieve(30) 0.006 > strcat(200000) 0.002 > ------------------------ > Total 0.261 > ``` > > vs > > ``` > gcc: (Debian 10.2.1-6) 10.2.1 20210110 > CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -flto > -fuse-linker-plugin > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" > CXXFLAGS="${CFLAGS}" > LDFLAGS="-Wl,-O1 -pie -flto -fuse-linker-plugin" > $ ./sapi/cli/php ./Zend/bench.php > simple 0.006 > simplecall 0.003 > simpleucall 0.010 > simpleudcall 0.014 > mandel 0.050 > mandel2 0.049 > ackermann(7) 0.012 > ary(50000) 0.003 > ary2(50000) 0.002 > ary3(2000) 0.020 > fibo(30) 0.035 > hash1(50000) 0.004 > hash2(500) 0.004 > heapsort(20000) 0.012 > matrix(20) 0.011 > nestedloop(12) 0.010 > sieve(30) 0.007 > strcat(200000) 0.002 > ------------------------ > Total 0.255 > ``` > > In fact, it does not seem to work very well. However, it may be > effective > when large numbers of extensions are built into PHP. > > Is anyone interested in supporting this?