[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-20 Thread Launchpad Bug Tracker
This bug was fixed in the package php8.1 - 8.1.2-1ubuntu4

---
php8.1 (8.1.2-1ubuntu4) kinetic; urgency=medium

  * d/p/0046-Update-gcc-func-attr-macro.patch: fix detection of unknown gcc
function attributes. (LP: #1882279)
  * d/rules: document garbage collection in ini files. (LP: #1772915)

 -- Athos Ribeiro   Mon, 02 May 2022
19:54:49 -0300

** Changed in: php8.1 (Ubuntu)
   Status: Triaged => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-06 Thread Launchpad Bug Tracker
** Merge proposal linked:
   
https://code.launchpad.net/~athos-ribeiro/ubuntu/+source/php8.1/+git/php8.1/+merge/421591

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-04 Thread Athos Ribeiro
Since testing the proposed changes for i386 may be trickier for kinetic,
I tested it in the following fashion:

- Deployed a Debian stable i386 VM and upgraded it to Debian testing (which 
contains php 8.1);
- Ensured the VM CPU supported the sse2 instruction (which is checked in the 
configuration test to enable the performance boost related to this bug;
- Built and installed Debian's PHP i386 package with the related patch (see 
https://salsa.debian.org/php-team/php/-/merge_requests/12);
- Ran the test script provided by this bug reporter to look for regressions (no 
regressions found, no performance boost observed);
- Changed the VM CPU to support avx2/sse3 instructions and re-ran the test. 
Now, the performance boost was observed;
- Finally, Changed the VM CPU for a pre-pentium 4 micro-architecture, where 
sse2 is not available (this is the most important i386 test here).
- Re-ran the test script. No performance boost observed. No regressions 
observed.

This provides enough evidence that no regressions should be introduced
if the patch is introduced in stable releases for i386 users with
machines that do not support avx2/sse3/sse2 instructions. It is
important to note that this feature will be enabled in the i386 builds
since LP builders do support sse2.

The next steps here are to introduce this change as a delta into kinetic
and SRU it all the way back to focal.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-03 Thread Athos Ribeiro
Debian salsa MR: https://salsa.debian.org/php-
team/php/-/merge_requests/12

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-03 Thread Athos Ribeiro
While proceeding to the next steps on Rafael's analysis, I realized that
the Ubuntu package and the self compiled version of PHP were calling
different functions to process the same input file (the test file
uploaded by the bug reporter).

The Ubuntu PHP package calls the function reported above
(php_base64_decode_ex), while the local compiled package calls
php_base64_decode_ex_avx2.

The locally compiled binary does process the test script 10x faster than
the packaged one. This is also true for the Debian and the Fedora
packages (they are slower) but not to the upstream PHP Docker image
shipped in dockerhub under docker.io/php.

After some investigation, I realized that PHP will use different x86_64
instructions for some tasks when such instructions are available. That
is either done when the binaries are compiled to target specific x86_64
micro-architectures or through the "target" function attribute provided
by gcc (see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-
Attributes.html)

When specific (newer) x86_64 instructions are available, PHP will use
them to speed up some specific tasks (such as base64 encoding/decoding).
If they are not available, it falls back to other (older) available
instructions.

For instance, in the base64 decoding case, it will use avx2, introduced
in x86_64-v3 when available; it then falls back to sse3, introduced in
x86_64-v2, and finally uses the common v1 instructions when neither is
available.

The option to compile such additional functions is set during
configuration time, through the "ax_cv_have_func_attribute_target"
configuration. This configuration option is set by a modified version of
an embedded gcc macro shipped in
$PHP_SRC_ROOT/build/ax_gcc_func_attribute.m4.

The original macro is described at
https://www.gnu.org/software/autoconf-
archive/ax_gcc_func_attribute.html.

This macro relies on warnings being thrown to decide if the system
supports a specific function attribute. The (old) version being shipped
by PHP considers any warnings as a negative (i.e., the system does not
support the function attribute in question), always generating false
negatives when "-Wall" is enabled, since it relies on a test that
declares and does not define a fuction, resulting in:

"warning: ‘bar’ declared ‘static’ but never defined [-Wunused-
function]",

which leads the configuration step to always define

"ax_cv_have_func_attribute_target=no"

When "-Wall" is present in the CFLAGS (which is true for Ubuntu, Debian,
Fedora, etc).

The issue with the macro have been fixed in autoconf-archive upstream at

http://git.savannah.gnu.org/gitweb/?p=autoconf-
archive.git;a=commitdiff;h=df0894ad1a8195df67a52108b931e07d708cec9a

but this has not been backported into the php embedded macro yet.

Updating the macro and rebuilding the package generates PHP binaries
with the improved performance perceived by the bug reporter.

A PPA with the proposed change is available at
https://launchpad.net/~athos-ribeiro/+archive/ubuntu/lp1882279-php-perf/+packages.

I proposed updating the macro upstream at https://github.com/php/php-
src/pull/8483.

I tested the patched package emulating different x86_64 CPUs, and it
will either use the avx2, the sse3, or fallback to the regular (slower)
code path.

The test being performed in the configuration step verifies if the
"sse2" target is available. While this is true for x86_64 v1 and on,
when dealing with i386, it is was only made available from pentium 4 and
on. LP i386 builds are setting

"ax_cv_have_func_attribute_target=yes",

So we would still need to test the patched binaries on an i386 CPU older
than a pentium 4. No performance gains should be expected, but we also
should make sure no regressions will be introduced (i.e., the patch
should no break the binaries for such arches).

Note that the explanations above also contain the reason why Rafael
could not perceive the performance differences on his tests:

> "2 seconds in my old AMD (4.4 GHz) CPUs.. before and after local
compilation"...

Next, I will propose the patch to Debian with a salsa MR and perform the
i386 test before filing a MP with this patch as a Delta for kinetic.
Then we can proceed to filing SRUs here.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-05-02 Thread Athos Ribeiro
** Tags added: server-todo

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-04-29 Thread Athos Ribeiro
** Changed in: php7.4 (Ubuntu)
 Assignee: (unassigned) => Athos Ribeiro (athos-ribeiro)

** Changed in: php8.1 (Ubuntu)
 Assignee: (unassigned) => Athos Ribeiro (athos-ribeiro)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2022-03-17 Thread Athos Ribeiro
This is still valid for php 8.1;

Rafael's next steps seem to still be the path forward here.

** Also affects: php8.1 (Ubuntu)
   Importance: Undecided
   Status: New

** Changed in: php8.1 (Ubuntu)
   Status: New => Triaged

** Changed in: php8.1 (Ubuntu)
   Importance: Undecided => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2020-06-18 Thread Rafael David Tinoco
2 seconds in my old AMD (4.4 GHz) CPUs.. before and after local
compilation, with perf record getting samples at the same frequency.

(c)rafaeldtinoco@groovy:~$ sudo perf report --stdio

# Overhead  Command  Shared Object  Symbol  
 
#   ...  .  
.
#
73.54%  php  php7.4 [.] php_base64_decode_ex
21.96%  php  php7.4 [.] php_base64_encode
 1.07%  php  php7.4 [.] execute_ex

and if you annotate it:

https://paste.ubuntu.com/p/Qb9rvT84MX/

you're basically expending almost 75% of the time in decoding base64:

https://pastebin.ubuntu.com/p/YFcqrqfZBm/

but there isn't a single bottleneck, suggesting overall optimizations at
compilation time, SPECIALLY if you judge the source code and generated
instructions (by disassembling php_base64_decode_ex).

A bit amount of time (from these 75%) is in between the branches from
line 274 <-> 264.. suggesting that lots of unknown chars are hitting
continue; (~10% of 75%). Another considerable source of time is the bit
shifts (~8% of the 75%).

next step here is *likely* doing a "perf diff" among the 2 different
reports and it will show the main deviations from the 2 executions..
then you will have to identify:

- is the compiler putting a diff subset of instructions (like SIMD for vectors, 
usually using vectorization HW extensions/instructions - sse for x64 for 
example)
- is the compiler just doing better loop generation for the decoding ? (usually 
related to better intermediate code generation because of a specific flag)

etc...

this is the TODO here.


** Changed in: php7.4 (Ubuntu)
   Status: New => Triaged

** Changed in: php7.4 (Ubuntu)
   Importance: Undecided => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2020-06-16 Thread Dustin Falgout
That is true but I am guessing that would be because of one of the
patches in the Ubuntu source package. There are A LOT of patches. Most
appear to be security related but I haven't had time to look past the
filenames of the patches so take that with a grain of salt.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1882279] Re: PHP built from source performs much better than the Ubuntu packaged version

2020-06-16 Thread Paride Legovini
@Dustin,

I used a Docker image that comes with php precompiled (php:7.4-cli, see
my Dockerfile above) but still managed to reproduce the performance
difference, so I don't think it's building from source on the same
machine that will run the php perf test that makes the difference. The
difference likely comes from a compile-time flag or optimization. I'm
convinced that compiling php from the Ubuntu source package would
produce the same "slow" php.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1882279

Title:
  PHP built from source performs much better than the Ubuntu packaged
  version

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.4/+bug/1882279/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs