Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature.
Thanks. Dmitry.
Hi all,
This is fantastic news thank you! I was going to ask if JIT would also work
when Opcache is enabled with "opcache.file_cache_only". Our use case is a
ReactPHP app that right now only has Opcache basically for the
optimizations and we do not use the standard shared memory portion. We
believe JIT could improve quite a lot these kinds of "long-running"
processes that can serve multiple requests per-process. Thanks a lot!
Best,
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
Hi all,
This is fantastic news thank you! I was going to ask if JIT would also
work when Opcache is enabled with "opcache.file_cache_only".
Unfortunately, not yet, but we are planning to move opcache into PHP-8
core and allow optimization and JIT without caching.
Our use
case is a ReactPHP app that right now only has Opcache basically for the
optimizations and we do not use the standard shared memory portion. We
believe JIT could improve quite a lot these kinds of "long-running"
processes that can serve multiple requests per-process. Thanks a lot!
Better to try and provide feedback right now.
You can get sources and build PHP from the link in RFC.
https://github.com/zendtech/php-src/
Thanks. Dmitry.
Best,
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
JIT, FFI, covariant return types and typed properties: what a year for PHP.
Thank you all for working on making PHP better and better.
- Marcos
Em qui, 31 de jan de 2019 às 08:54, Dmitry Stogov dmitry@zend.com
escreveu:
Hi all,
This is fantastic news thank you! I was going to ask if JIT would also
work when Opcache is enabled with "opcache.file_cache_only".Unfortunately, not yet, but we are planning to move opcache into PHP-8
core and allow optimization and JIT without caching.Our use
case is a ReactPHP app that right now only has Opcache basically for the
optimizations and we do not use the standard shared memory portion. We
believe JIT could improve quite a lot these kinds of "long-running"
processes that can serve multiple requests per-process. Thanks a lot!Better to try and provide feedback right now.
You can get sources and build PHP from the link in RFC.
https://github.com/zendtech/php-src/Thanks. Dmitry.
Best,
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
Just want to say that this is HUGE, thanks so much for the work done here,
can't wait to try it out, hopefully this will land in PHP 7.4!
Ben
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
This has been a long time on the horizon, nice to see this finally moving
forward :)
Here are some initial thoughts: I think that it's best to approach this
issue from a cost/benefit angle. The benefits of the JIT compiler are
roughly (and as already outlined in the RFC):
- Significantly better performance for numerical code.
- Slightly better performance for "typical" PHP web application code.
- The potential to move more code from C to PHP, because PHP will now be
sufficiently fast.
However, there are also a number of costs, on which I'll expand in more
detail:
a) Maintenance: This is really my main concern. Right now there are about
3-4 people who I would trust to carry out a non-trivial language change,
which will require touching the compiler, the virtual machine, the
optimizer and the persistence layer. Each of those components is quite
complex, in different ways. Some people who are comfortable with doing VM
changes will struggle with implementing optimizer changes.
Adding a JIT compiler exacerbates this issue further. Because this JIT is
dynasm based, the core JIT code is essentially written in raw x86 assembly.
This will further limit the pool of people who will be able to make
non-trivial engine changes. Personally, I don't have any particular
familiarity with writing x86 assembly, so it will likely take a while to
get up to speed with this code.
b) Bugs and stability: I think that everyone is aware that the initial PHP
7.3 release suffered from substantial stability issues, more than new minor
version releases tend to do. I think there are multiple reasons for that
(and we might want to start a conversation about our QA processes in a
separate thread), but one main contributing factor were opcache optimizer
bugs. Compiler optimizations are tricky and hard to verify, and we often
only learn about issues once the optimizer makes contact with production
codebases, which feature a much richer collection of code patterns than our
test suite. One can wonder whether the relatively minor speedups we get
from our optimization framework are really worth having these stability
issues...
Adding a JIT compiler adds a new dimension of stability issues. Next to
"simple" executor bugs, and optimizer bugs, we now get additional bugs in
the JIT. These are probably going to be hard to debug, as we'll have to
drop down from our usual C-level tooling, down to inspecting assembly.
c) Platform support: Having a JIT segregates platforms into two tiers:
Those that have JIT support and those that don't. While that is not a
problem per se, it does introduce some dangers. For example, if we decide
to more parts of our C code into PHP because PHP is fast enough with a JIT,
that will of course only be true for platforms that actually have JIT
support. I'm not terribly concerned about loosing out some performance on
MIPS, but we do need to make sure that all our main platforms are supported
(Windows is a must there, imho).
d) Debugging: I'm not sure whether or not this is an issue (maybe the RFC
can clarify?), but I'm wondering if this will have an impact on things like
XDebug. Will it be possible to using XDebug to accurately inspect variables
at any point in time while the JIT is running? If not, that would be a big
tooling regression.
I think those are the main points that come to mind right now...
Regards,
Nikita
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
This has been a long time on the horizon, nice to see this finally
moving forward :)Here are some initial thoughts: I think that it's best to approach this
issue from a cost/benefit angle. The benefits of the JIT compiler are
roughly (and as already outlined in the RFC):* Significantly better performance for numerical code.
* Slightly better performance for "typical" PHP web application code.
* The potential to move more code from C to PHP, because PHP will now
be sufficiently fast.However, there are also a number of costs, on which I'll expand in more
detail:a) Maintenance: This is really my main concern. Right now there are
about 3-4 people who I would trust to carry out a non-trivial language
change, which will require touching the compiler, the virtual machine,
the optimizer and the persistence layer. Each of those components is
quite complex, in different ways. Some people who are comfortable with
doing VM changes will struggle with implementing optimizer changes.Adding a JIT compiler exacerbates this issue further. Because this JIT
is dynasm based, the core JIT code is essentially written in raw x86
assembly. This will further limit the pool of people who will be able to
make non-trivial engine changes. Personally, I don't have any particular
familiarity with writing x86 assembly, so it will likely take a while to
get up to speed with this code.b) Bugs and stability: I think that everyone is aware that the initial
PHP 7.3 release suffered from substantial stability issues, more than
new minor version releases tend to do. I think there are multiple
reasons for that (and we might want to start a conversation about our QA
processes in a separate thread), but one main contributing factor were
opcache optimizer bugs. Compiler optimizations are tricky and hard to
verify, and we often only learn about issues once the optimizer makes
contact with production codebases, which feature a much richer
collection of code patterns than our test suite. One can wonder whether
the relatively minor speedups we get from our optimization framework are
really worth having these stability issues...Adding a JIT compiler adds a new dimension of stability issues. Next to
"simple" executor bugs, and optimizer bugs, we now get additional bugs
in the JIT. These are probably going to be hard to debug, as we'll have
to drop down from our usual C-level tooling, down to inspecting assembly.c) Platform support: Having a JIT segregates platforms into two tiers:
Those that have JIT support and those that don't. While that is not a
problem per se, it does introduce some dangers. For example, if we
decide to more parts of our C code into PHP because PHP is fast enough
with a JIT, that will of course only be true for platforms that actually
have JIT support. I'm not terribly concerned about loosing out some
performance on MIPS, but we do need to make sure that all our main
platforms are supported (Windows is a must there, imho).
I don't see any problems with including JIT without Windows support.
Windows runs PHP much slower any way.
d) Debugging: I'm not sure whether or not this is an issue (maybe the
RFC can clarify?), but I'm wondering if this will have an impact on
things like XDebug. Will it be possible to using XDebug to accurately
inspect variables at any point in time while the JIT is running? If not,
that would be a big tooling regression.
XDebug may work with JIT or opcache disabled.
I think those are the main points that come to mind right now...
Anyway, I'm mostly agree with all the points.
There are two options :)
- take the challenge and start developing JIT together
- forget about JIT, because we are afraid
Thanks. Dmitry.
Regards,
Nikita
Den tor. 31. jan. 2019 kl. 18.39 skrev Dmitry Stogov dmitry@zend.com:
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
This has been a long time on the horizon, nice to see this finally
moving forward :)Here are some initial thoughts: I think that it's best to approach this
issue from a cost/benefit angle. The benefits of the JIT compiler are
roughly (and as already outlined in the RFC):
- Significantly better performance for numerical code.
- Slightly better performance for "typical" PHP web application code.
- The potential to move more code from C to PHP, because PHP will now
be sufficiently fast.However, there are also a number of costs, on which I'll expand in more
detail:a) Maintenance: This is really my main concern. Right now there are
about 3-4 people who I would trust to carry out a non-trivial language
change, which will require touching the compiler, the virtual machine,
the optimizer and the persistence layer. Each of those components is
quite complex, in different ways. Some people who are comfortable with
doing VM changes will struggle with implementing optimizer changes.Adding a JIT compiler exacerbates this issue further. Because this JIT
is dynasm based, the core JIT code is essentially written in raw x86
assembly. This will further limit the pool of people who will be able to
make non-trivial engine changes. Personally, I don't have any particular
familiarity with writing x86 assembly, so it will likely take a while to
get up to speed with this code.b) Bugs and stability: I think that everyone is aware that the initial
PHP 7.3 release suffered from substantial stability issues, more than
new minor version releases tend to do. I think there are multiple
reasons for that (and we might want to start a conversation about our QA
processes in a separate thread), but one main contributing factor were
opcache optimizer bugs. Compiler optimizations are tricky and hard to
verify, and we often only learn about issues once the optimizer makes
contact with production codebases, which feature a much richer
collection of code patterns than our test suite. One can wonder whether
the relatively minor speedups we get from our optimization framework are
really worth having these stability issues...Adding a JIT compiler adds a new dimension of stability issues. Next to
"simple" executor bugs, and optimizer bugs, we now get additional bugs
in the JIT. These are probably going to be hard to debug, as we'll have
to drop down from our usual C-level tooling, down to inspecting assembly.c) Platform support: Having a JIT segregates platforms into two tiers:
Those that have JIT support and those that don't. While that is not a
problem per se, it does introduce some dangers. For example, if we
decide to more parts of our C code into PHP because PHP is fast enough
with a JIT, that will of course only be true for platforms that actually
have JIT support. I'm not terribly concerned about loosing out some
performance on MIPS, but we do need to make sure that all our main
platforms are supported (Windows is a must there, imho).I don't see any problems with including JIT without Windows support.
Windows runs PHP much slower any way.
Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.
I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.
As long as we can agree that very few actually *deploy *on Windows, I think
we're on solid grounds.
As the JIT implementation is likely to have at least some significant
differences compared to Linux, I'm not sure what testing it on Windows
would give you. JIT is supposed to be entirely transparent, and the
performance characteristics - as well as the bug patterns - are likely to
be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?
I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.
I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
It'd be interesting to evaluate the cost associated with supporting
Windows. Bare in mind, we're proposing to vote on this as a production
feature for PHP 8 - which realistically means almost two years from now at
the earliest. I'm sure we'd have Windows support a lot sooner than that
if we decide that it's a must have. I agree with Nikita that the key
question is in fact, do we or do we not want to introduce JIT in - with the
main question being the maintenance cost. Let's tackle this question
first, otherwise - why send Dmitry (and maybe others) for doing more work
(Windows support) if we are likely to flush it all down the toilet?
I think that if we reach the conclusion that Windows support is a must, we
can condition the inclusion of JIT based on having it. Let's first agree
on whether we want it in the first place.
Zeev
On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen kalle@php.net
wrote:Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.As long as we can agree that very few actually *deploy *on Windows, I think
we're on solid grounds.
As the JIT implementation is likely to have at least some significant
differences compared to Linux, I'm not sure what testing it on Windows
would give you. JIT is supposed to be entirely transparent, and the
performance characteristics - as well as the bug patterns - are likely to
be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
It'd be interesting to evaluate the cost associated with supporting
Windows. Bare in mind, we're proposing to vote on this as a production
feature for PHP 8 - which realistically means almost two years from now at
the earliest. I'm sure we'd have Windows support a lot sooner than that
if we decide that it's a must have. I agree with Nikita that the key
question is in fact, do we or do we not want to introduce JIT in - with the
main question being the maintenance cost. Let's tackle this question
first, otherwise - why send Dmitry (and maybe others) for doing more work
(Windows support) if we are likely to flush it all down the toilet?Maybe we're the only ones, but we run production PHP on Windows. I have no
issues with the idea of not initially having support for Windows. I can
probably even live with never having support for Windows - provided that we
don't find ourselves in a situation like Nikita mentioned where features
start getting developed in PHP instead of C and require JIT in order to
function.
I think that if we reach the conclusion that Windows support is a must, we
can condition the inclusion of JIT based on having it. Let's first agree
on whether we want it in the first place.Zeev
--
-- Chase
chasepeeler@gmail.com
On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen kalle@php.net
wrote:
Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.As long as we can agree that very few actually *deploy *on Windows, I
think
we're on solid grounds.
As the JIT implementation is likely to have at least some significant
differences compared to Linux, I'm not sure what testing it on Windows
would give you. JIT is supposed to be entirely transparent, and the
performance characteristics - as well as the bug patterns - are likely to
be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
It'd be interesting to evaluate the cost associated with supporting
Windows. Bare in mind, we're proposing to vote on this as a production
feature for PHP 8 - which realistically means almost two years from now
at
the earliest. I'm sure we'd have Windows support a lot sooner than that
if we decide that it's a must have. I agree with Nikita that the key
question is in fact, do we or do we not want to introduce JIT in - with
the
main question being the maintenance cost. Let's tackle this question
first, otherwise - why send Dmitry (and maybe others) for doing more work
(Windows support) if we are likely to flush it all down the toilet?Maybe we're the only ones, but we run production PHP on Windows. I have no
issues with the idea of not initially having support for Windows. I can
probably even live with never having support for Windows - provided that we
don't find ourselves in a situation like Nikita mentioned where features
start getting developed in PHP instead of C and require JIT in order to
function.
Question from a non-compiler-engineer: Could we end up in a situation where
future language features (in 8.3 or something) are only performant on JIT-
enabled platforms? I know there were some RFCs rejected in the past on the
grounds that they involved too many runtime checks (and thus a performance
hit); if it were possible for a JIT to optimize some of those away, it might
make the cost acceptable. However, if a JIT only works on some systems that
might widen the gap between have- and have-not platforms.
Is that a concern, or am I making things up? Or, is it a concern but we're
legit OK with that happening (which is also an entirely valid decision to
make)?
--Larry Garfield
On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen kalle@php.net
wrote:
Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.As long as we can agree that very few actually *deploy *on Windows, I
think
we're on solid grounds.
As the JIT implementation is likely to have at least some significant
differences compared to Linux, I'm not sure what testing it on Windows
would give you. JIT is supposed to be entirely transparent, and the
performance characteristics - as well as the bug patterns - are likely to
be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
It'd be interesting to evaluate the cost associated with supporting
Windows. Bare in mind, we're proposing to vote on this as a production
feature for PHP 8 - which realistically means almost two years from now
at
the earliest. I'm sure we'd have Windows support a lot sooner than that
if we decide that it's a must have. I agree with Nikita that the key
question is in fact, do we or do we not want to introduce JIT in - with
the
main question being the maintenance cost. Let's tackle this question
first, otherwise - why send Dmitry (and maybe others) for doing more work
(Windows support) if we are likely to flush it all down the toilet?Maybe we're the only ones, but we run production PHP on Windows. I have no
issues with the idea of not initially having support for Windows. I can
probably even live with never having support for Windows - provided that we
don't find ourselves in a situation like Nikita mentioned where features
start getting developed in PHP instead of C and require JIT in order to
function.Question from a non-compiler-engineer: Could we end up in a situation where
future language features (in 8.3 or something) are only performant on JIT-
enabled platforms? I know there were some RFCs rejected in the past on the
grounds that they involved too many runtime checks (and thus a performance
hit); if it were possible for a JIT to optimize some of those away, it might
make the cost acceptable. However, if a JIT only works on some systems that
might widen the gap between have- and have-not platforms.
I think, JIT only approach doesn't make a lot of sense for PHP, with one
of the most fast VM. And this is a trend. Even V8, starting from JIT
only, switched back to VM+JIT.
Thanks. Dmitry.
Is that a concern, or am I making things up? Or, is it a concern but we're
legit OK with that happening (which is also an entirely valid decision to
make)?--Larry Garfield
Morning Dmitry, and internals,
This is marvellous stuff, truly brilliant. I particularly appreciate the
non-intrusive approach of setting jit'd code as the opcode handler, this
makes life a little easier for hacky extension authors, I think.
As others have said:
I don't like the idea of omitting to support windows, less worried about
fancy architectures.
I'm not keen on the idea that there is no way to debug the code this
generates outside of GDB, and I'm not sure how useful gdb will be: I've
tried to debug JIT'd code in that before and it doesn't do so well, but I
could easily have been doing it wrong. I'd be very happy to be corrected
about this ?
I'm not keen on the idea of merging this into 7.4, for various reasons
that don't need to be repeated.
Bottom line though, I love it, it's brilliant, and look forward to PHP 8.
Thank you, Dmitry.
Cheers
Joe
On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen kalle@php.net
wrote:
Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.As long as we can agree that very few actually *deploy *on Windows, I
think
we're on solid grounds.
As the JIT implementation is likely to have at least some significant
differences compared to Linux, I'm not sure what testing it on Windows
would give you. JIT is supposed to be entirely transparent, and the
performance characteristics - as well as the bug patterns - are likely
to
be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree
PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
It'd be interesting to evaluate the cost associated with supporting
Windows. Bare in mind, we're proposing to vote on this as a production
feature for PHP 8 - which realistically means almost two years from now
at
the earliest. I'm sure we'd have Windows support a lot sooner than
that
if we decide that it's a must have. I agree with Nikita that the key
question is in fact, do we or do we not want to introduce JIT in - with
the
main question being the maintenance cost. Let's tackle this question
first, otherwise - why send Dmitry (and maybe others) for doing more
work
(Windows support) if we are likely to flush it all down the toilet?Maybe we're the only ones, but we run production PHP on Windows. I have
no
issues with the idea of not initially having support for Windows. I can
probably even live with never having support for Windows - provided
that we
don't find ourselves in a situation like Nikita mentioned where features
start getting developed in PHP instead of C and require JIT in order to
function.Question from a non-compiler-engineer: Could we end up in a situation
where
future language features (in 8.3 or something) are only performant on
JIT-
enabled platforms? I know there were some RFCs rejected in the past on
the
grounds that they involved too many runtime checks (and thus a
performance
hit); if it were possible for a JIT to optimize some of those away, it
might
make the cost acceptable. However, if a JIT only works on some systems
that
might widen the gap between have- and have-not platforms.I think, JIT only approach doesn't make a lot of sense for PHP, with one
of the most fast VM. And this is a trend. Even V8, starting from JIT
only, switched back to VM+JIT.Thanks. Dmitry.
Is that a concern, or am I making things up? Or, is it a concern but
we're
legit OK with that happening (which is also an entirely valid decision to
make)?--Larry Garfield
Morning Dmitry, and internals,
This is marvellous stuff, truly brilliant. I particularly appreciate the
non-intrusive approach of setting jit'd code as the opcode handler, this
makes life a little easier for hacky extension authors, I think.As others have said:
I don't like the idea of omitting to support windows, less worried
about fancy architectures.
I can provide help to people who will going to implement JIT support for
Windows. This is not going to be easy, because MSVC doesn't support
"hybrid VM" and "global register variables", therefore the code is going
to be more expensive.
I'm not keen on the idea that there is no way to debug the code this
generates outside of GDB, and I'm not sure how useful gdb will be: I've
tried to debug JIT'd code in that before and it doesn't do so well, but
I could easily have been doing it wrong. I'd be very happy to be
corrected about this ?
I'm not sure, what is wrong with GDB, and if any other debuggers have
special API for run-time generated code.
I'm not keen on the idea of merging this into 7.4, for various
reasons that don't need to be repeated.
OK. It's not only your opinion.
You may vote against, and persuade others.
Thanks. Dmitry.
Bottom line though, I love it, it's brilliant, and look forward to PHP 8.
Thank you, Dmitry.
Cheers
JoeOn Fri, 1 Feb 2019 at 09:41, Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> >> On Thu, Jan 31, 2019 at 12:04 PM Zeev Suraski <zeev@php.net <mailto:zeev@php.net>> wrote: >>> On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen <kalle@php.net <mailto:kalle@php.net>> >>> >>> wrote: >>>> Without my usual Windows bias, I do believe it is a considerable fact >>>> like Nikita pointed out as Windows is a first class citizen in terms >>>> of operating systems we support. While PHP on Windows may not have the >>>> speed that the Unix counterpart have, it is still a very important >>>> development platform. Many developers develop on Windows and deploy on >>>> a Unix based system, being unable to test such an important feature in >>>> a development environment is also a large question mark. >>> >>> As long as we can agree that very few actually *deploy *on Windows, I >>> think >>> we're on solid grounds. >>> As the JIT implementation is likely to have at least *some* significant >>> differences compared to Linux, I'm not sure what testing it on Windows >>> would give you. JIT is supposed to be entirely transparent, and the >>> performance characteristics - as well as the bug patterns - are likely to >>> be quite different on Linux vs. Windows, at least in many cases. >>> Is it really that important to have? >>> >>> I'm honestly a bit perplexed by how many people here viewing Windows >>> support as a must have, while at the same time I think we all agree PHP is >>> very scarcely found on production Windows servers, and JIT is a >>> predominantly production feature. >>> >>> I'm personally interested in taking a look at it (and I'm certain >>> >>>> Anatol does too), but simply dismissing is a no-go for me. >>> >>> It'd be interesting to evaluate the cost associated with supporting >>> Windows. Bare in mind, we're proposing to vote on this as a production >>> feature for PHP 8 - which realistically means almost two years from now >>> *at >>> the earliest*. I'm sure we'd have Windows support a lot sooner than that >>> if we decide that it's a must have. I agree with Nikita that the key >>> question is in fact, do we or do we not want to introduce JIT in - with >>> the >>> main question being the maintenance cost. Let's tackle this question >>> first, otherwise - why send Dmitry (and maybe others) for doing more work >>> (Windows support) if we are likely to flush it all down the toilet? >>> >> Maybe we're the only ones, but we run production PHP on Windows. I have no >> issues with the idea of not initially having support for Windows. I can >> probably even live with never having support for Windows - provided that we >> don't find ourselves in a situation like Nikita mentioned where features >> start getting developed in PHP instead of C and require JIT in order to >> function. > > Question from a non-compiler-engineer: Could we end up in a situation where > future language features (in 8.3 or something) are only performant on JIT- > enabled platforms? I know there were some RFCs rejected in the past on the > grounds that they involved too many runtime checks (and thus a performance > hit); if it were possible for a JIT to optimize some of those away, it might > make the cost acceptable. However, if a JIT only works on some systems that > might widen the gap between have- and have-not platforms. I think, JIT only approach doesn't make a lot of sense for PHP, with one of the most fast VM. And this is a trend. Even V8, starting from JIT only, switched back to VM+JIT. Thanks. Dmitry. > > Is that a concern, or am I making things up? Or, is it a concern but we're > legit OK with that happening (which is also an entirely valid decision to > make)? > > --Larry Garfield
Morning Dmitry, and internals,
This is marvellous stuff, truly brilliant. I particularly appreciate the
non-intrusive approach of setting jit'd code as the opcode handler, this
makes life a little easier for hacky extension authors, I think.As others have said:
I don't like the idea of omitting to support windows, less worried
about fancy architectures.I can provide help to people who will going to implement JIT support for
Windows. This is not going to be easy, because MSVC doesn't support
"hybrid VM" and "global register variables", therefore the code is going
to be more expensive.
I think an important point here is that this issue affects not only
Windows: It also affects any platform that uses clang as their compiler.
Notably this includes MacOS.
Clang theoretically supports global registers, but only for non-allocatable
regs (rsp and rbp), which I think is not very useful for this purpose.
So this problem needs to be solved not just for Windows support, but also
for MacOS support (and also FreeBSD and other clang-using platforms).
Nikita
I'm not keen on the idea that there is no way to debug the code this
generates outside of GDB, and I'm not sure how useful gdb will be: I've
tried to debug JIT'd code in that before and it doesn't do so well, but
I could easily have been doing it wrong. I'd be very happy to be
corrected about this ?I'm not sure, what is wrong with GDB, and if any other debuggers have
special API for run-time generated code.I'm not keen on the idea of merging this into 7.4, for various
reasons that don't need to be repeated.OK. It's not only your opinion.
You may vote against, and persuade others.Thanks. Dmitry.
Bottom line though, I love it, it's brilliant, and look forward to PHP 8.
Thank you, Dmitry.
Cheers
JoeOn Fri, 1 Feb 2019 at 09:41, Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> >> On Thu, Jan 31, 2019 at 12:04 PM Zeev Suraski <zeev@php.net <mailto:zeev@php.net>> wrote: >>> On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen <kalle@php.net <mailto:kalle@php.net>> >>> >>> wrote: >>>> Without my usual Windows bias, I do believe it is a considerable fact >>>> like Nikita pointed out as Windows is a first class citizen in terms >>>> of operating systems we support. While PHP on Windows may not have the >>>> speed that the Unix counterpart have, it is still a very
important
>>>> development platform. Many developers develop on Windows and deploy on >>>> a Unix based system, being unable to test such an important feature in >>>> a development environment is also a large question mark. >>> >>> As long as we can agree that very few actually *deploy *on Windows, I >>> think >>> we're on solid grounds. >>> As the JIT implementation is likely to have at least *some* significant >>> differences compared to Linux, I'm not sure what testing it on Windows >>> would give you. JIT is supposed to be entirely transparent, and the >>> performance characteristics - as well as the bug patterns - are likely to >>> be quite different on Linux vs. Windows, at least in many cases. >>> Is it really that important to have? >>> >>> I'm honestly a bit perplexed by how many people here viewing Windows >>> support as a must have, while at the same time I think we all agree PHP is >>> very scarcely found on production Windows servers, and JIT is a >>> predominantly production feature. >>> >>> I'm personally interested in taking a look at it (and I'm
certain
>>> >>>> Anatol does too), but simply dismissing is a no-go for me. >>> >>> It'd be interesting to evaluate the cost associated with
supporting
>>> Windows. Bare in mind, we're proposing to vote on this as a production >>> feature for PHP 8 - which realistically means almost two years from now >>> *at >>> the earliest*. I'm sure we'd have Windows support a lot sooner than that >>> if we decide that it's a must have. I agree with Nikita that the key >>> question is in fact, do we or do we not want to introduce JIT in - with >>> the >>> main question being the maintenance cost. Let's tackle this question >>> first, otherwise - why send Dmitry (and maybe others) for doing more work >>> (Windows support) if we are likely to flush it all down the
toilet?
>>> >> Maybe we're the only ones, but we run production PHP on Windows. I have no >> issues with the idea of not initially having support for Windows. I can >> probably even live with never having support for Windows - provided that we >> don't find ourselves in a situation like Nikita mentioned where features >> start getting developed in PHP instead of C and require JIT in order to >> function. > > Question from a non-compiler-engineer: Could we end up in a situation where > future language features (in 8.3 or something) are only performant on JIT- > enabled platforms? I know there were some RFCs rejected in the past on the > grounds that they involved too many runtime checks (and thus a performance > hit); if it were possible for a JIT to optimize some of those away, it might > make the cost acceptable. However, if a JIT only works on some systems that > might widen the gap between have- and have-not platforms. I think, JIT only approach doesn't make a lot of sense for PHP, with one of the most fast VM. And this is a trend. Even V8, starting from JIT only, switched back to VM+JIT. Thanks. Dmitry. > > Is that a concern, or am I making things up? Or, is it a concern but we're > legit OK with that happening (which is also an entirely valid decision to > make)? > > --Larry Garfield
On Fri, Feb 1, 2019 at 2:12 PM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> Morning Dmitry, and internals, > > This is marvellous stuff, truly brilliant. I particularly appreciate the > non-intrusive approach of setting jit'd code as the opcode handler, this > makes life a little easier for hacky extension authors, I think. > > As others have said: > > I don't like the idea of omitting to support windows, less worried > about fancy architectures. I can provide help to people who will going to implement JIT support for Windows. This is not going to be easy, because MSVC doesn't support "hybrid VM" and "global register variables", therefore the code is going to be more expensive.
I think an important point here is that this issue affects not only
Windows: It also affects any platform that uses clang as their compiler.
Notably this includes MacOS.Clang theoretically supports global registers, but only for
non-allocatable regs (rsp and rbp), which I think is not very useful for
this purpose.
We will have to provide a patch for CLANG, implementing PHP VM calling
convention (HHVM, Erlang, Haskel did this).
Thanks. Dmitry.
So this problem needs to be solved not just for Windows support, but
also for MacOS support (and also FreeBSD and other clang-using platforms).Nikita
> I'm not keen on the idea that there is no way to debug the code this > generates outside of GDB, and I'm not sure how useful gdb will be: I've > tried to debug JIT'd code in that before and it doesn't do so well, but > I could easily have been doing it wrong. I'd be very happy to be > corrected about this ? I'm not sure, what is wrong with GDB, and if any other debuggers have special API for run-time generated code. > I'm not keen on the idea of merging this into 7.4, for various > reasons that don't need to be repeated. OK. It's not only your opinion. You may vote against, and persuade others. Thanks. Dmitry. > > Bottom line though, I love it, it's brilliant, and look forward to PHP 8. > > Thank you, Dmitry. > > Cheers > Joe > > > On Fri, 1 Feb 2019 at 09:41, Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> > <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: > > > > On 2/1/19 3:29 AM, Larry Garfield wrote: > > On Thursday, January 31, 2019 12:30:52 PM CST Chase Peeler wrote: > >> On Thu, Jan 31, 2019 at 12:04 PM Zeev Suraski <zeev@php.net <mailto:zeev@php.net> > <mailto:zeev@php.net <mailto:zeev@php.net>>> wrote: > >>> On Thu, Jan 31, 2019 at 6:47 PM Kalle Sommer Nielsen > <kalle@php.net <mailto:kalle@php.net> <mailto:kalle@php.net <mailto:kalle@php.net>>> > >>> > >>> wrote: > >>>> Without my usual Windows bias, I do believe it is a > considerable fact > >>>> like Nikita pointed out as Windows is a first class citizen in > terms > >>>> of operating systems we support. While PHP on Windows may not > have the > >>>> speed that the Unix counterpart have, it is still a very important > >>>> development platform. Many developers develop on Windows and > deploy on > >>>> a Unix based system, being unable to test such an important > feature in > >>>> a development environment is also a large question mark. > >>> > >>> As long as we can agree that very few actually *deploy *on > Windows, I > >>> think > >>> we're on solid grounds. > >>> As the JIT implementation is likely to have at least *some* > significant > >>> differences compared to Linux, I'm not sure what testing it on > Windows > >>> would give you. JIT is supposed to be entirely transparent, > and the > >>> performance characteristics - as well as the bug patterns - are > likely to > >>> be quite different on Linux vs. Windows, at least in many cases. > >>> Is it really that important to have? > >>> > >>> I'm honestly a bit perplexed by how many people here viewing > Windows > >>> support as a must have, while at the same time I think we all > agree PHP is > >>> very scarcely found on production Windows servers, and JIT is a > >>> predominantly production feature. > >>> > >>> I'm personally interested in taking a look at it (and I'm certain > >>> > >>>> Anatol does too), but simply dismissing is a no-go for me. > >>> > >>> It'd be interesting to evaluate the cost associated with supporting > >>> Windows. Bare in mind, we're proposing to vote on this as a > production > >>> feature for PHP 8 - which realistically means almost two years > from now > >>> *at > >>> the earliest*. I'm sure we'd have Windows support a lot sooner > than that > >>> if we decide that it's a must have. I agree with Nikita that > the key > >>> question is in fact, do we or do we not want to introduce JIT > in - with > >>> the > >>> main question being the maintenance cost. Let's tackle this > question > >>> first, otherwise - why send Dmitry (and maybe others) for doing > more work > >>> (Windows support) if we are likely to flush it all down the toilet? > >>> > >> Maybe we're the only ones, but we run production PHP on Windows. > I have no > >> issues with the idea of not initially having support for > Windows. I can > >> probably even live with never having support for Windows - > provided that we > >> don't find ourselves in a situation like Nikita mentioned where > features > >> start getting developed in PHP instead of C and require JIT in > order to > >> function. > > > > Question from a non-compiler-engineer: Could we end up in a > situation where > > future language features (in 8.3 or something) are only > performant on JIT- > > enabled platforms? I know there were some RFCs rejected in the > past on the > > grounds that they involved too many runtime checks (and thus a > performance > > hit); if it were possible for a JIT to optimize some of those > away, it might > > make the cost acceptable. However, if a JIT only works on some > systems that > > might widen the gap between have- and have-not platforms. > > I think, JIT only approach doesn't make a lot of sense for PHP, with > one > of the most fast VM. And this is a trend. Even V8, starting from JIT > only, switched back to VM+JIT. > > Thanks. Dmitry. > > > > > Is that a concern, or am I making things up? Or, is it a concern > but we're > > legit OK with that happening (which is also an entirely valid > decision to > > make)? > > > > --Larry Garfield > > > > -- > >
I'm not keen on the idea of merging this into 7.4, for various
reasons that don't need to be repeated.OK. It's not only your opinion.
You may vote against, and persuade others.
I think it would be interesting to clarify the intended audience for an
experimental JIT in 7.4. Presumably, it would be marked as not suitable for
production, so would only be of interest to those experimenting with the
feature; but any problems they find might already be fixed in master, so
would it be better to encourage them to download a snapshot build of
8.0-pre-alpha and test there?
Regards,
Rowan Collins
[IMSoP]
Question from a non-compiler-engineer: Could we end up in a situation
where
future language features (in 8.3 or something) are only performant on JIT-
enabled platforms? I know there were some RFCs rejected in the past on
the
grounds that they involved too many runtime checks (and thus a performance
hit); if it were possible for a JIT to optimize some of those away, it
might make the cost acceptable. However, if a JIT only works on some
systems that might widen the gap between have- and have-not platforms.I think, JIT only approach doesn't make a lot of sense for PHP, with one
of the most fast VM. And this is a trend. Even V8, starting from JIT
only, switched back to VM+JIT.Thanks. Dmitry.
I'm... not sure how that answers my question? I'm saying "if we had a VM+JIT,
and the JIT part made feature X acceptably fast but it wasn't acceptably fast
with just the VM, is that a problem?" Or is that a situation that cannot
happen? Or that we don't care if it happens?
--Larry Garfield
I'm... not sure how that answers my question? I'm saying "if we had a VM+JIT,
and the JIT part made feature X acceptably fast but it wasn't acceptably fast
with just the VM, is that a problem?" Or is that a situation that cannot
happen? Or that we don't care if it happens?
Technically, you're absolutely right that this may happen. For instance, if we decide to implement certain features in userland, factoring in the fact that JIT makes it fast enough - but without JIT it would be prohibitively slow - this could be a problem. I do think that if we’d want to go in this direction, our platform support would likely have to be wider than it currently is. But there are still two things that mitigate this issue to a large degree:
-
Our VM is super quick, by far the quickest non-JITted dynamic language (to the best of our knowledge). So VM would be slower, but depending on the specific use case - probably not dead slow.
-
Most PHP production workloads are on Linux, and as far as I can tell this trend is only growing over the years - with virtual machines and now containers becoming more and more popular - meaning that even developers with other host OSs still use Linux for the actual PHP development.
That said, again, we should probably evaluate it thoroughly before we come to rely on JIT for any must-have functionality.
Zeev
Hi Zeev,
Zeev Suraski in php.internals (Sun, 3 Feb 2019 07:05:49 +0000):
- Most PHP production workloads are on Linux, and as far as I can tell
this trend is only growing over the years - with virtual machines and
now containers becoming more and more popular - meaning that even
developers with other host OSs still use Linux for the actual PHP
development.
I am not sure this really is the case. Depending on which statistics you
believe te be true, about a quarter to a third of the Web is powered by
Wordpress. Wordpress market share is not diminishing.
Do not underestimate the huge amount of Wordpress plugin developers that
develop on Windows. Code quality is varying from very low to quite high,
but these people are PHP developers as well.
Jan
Question from a non-compiler-engineer: Could we end up in a situation
where
future language features (in 8.3 or something) are only performant on JIT-
enabled platforms? I know there were some RFCs rejected in the past on
the
grounds that they involved too many runtime checks (and thus a performance
hit); if it were possible for a JIT to optimize some of those away, it
might make the cost acceptable. However, if a JIT only works on some
systems that might widen the gap between have- and have-not platforms.I think, JIT only approach doesn't make a lot of sense for PHP, with one
of the most fast VM. And this is a trend. Even V8, starting from JIT
only, switched back to VM+JIT.Thanks. Dmitry.
I'm... not sure how that answers my question? I'm saying "if we had a VM+JIT,
and the JIT part made feature X acceptably fast but it wasn't acceptably fast
with just the VM, is that a problem?" Or is that a situation that cannot
happen? Or that we don't care if it happens?
Everything is possible, but I don't think very realistic now.
When some features are going to depend on JIT, we might have much better
JIT then now.
Thanks. Dmitry.
--Larry Garfield
Den tor. 31. jan. 2019 kl. 19.04 skrev Zeev Suraski zeev@php.net:
As long as we can agree that very few actually deploy on Windows, I think we're on solid grounds.
As the JIT implementation is likely to have at least some significant differences compared to Linux, I'm not sure what testing it on Windows would give you. JIT is supposed to be entirely transparent, and the performance characteristics - as well as the bug patterns - are likely to be quite different on Linux vs. Windows, at least in many cases.
Is it really that important to have?
I think we can easily agree on the fact that by no means Windows is
the top candidate for production. For me personally from a project
standpoint, I believe it is something important that we can have a PHP
that is pretty much as transparent and identical no matter what
platform you are on, which is something I have tried to do myself by
implementing various Linux routines for Windows natively to make PHP
as platform independent as possible.
I'm honestly a bit perplexed by how many people here viewing Windows support as a must have, while at the same time I think we all agree PHP is very scarcely found on production Windows servers, and JIT is a predominantly production feature.
With above being said, then I do also agree with you here, but I would
like to have such functionality and improvements to our core system be
as global as possible, naturally I don't think its fair either to
require it so desperately upfront, but it should be a heavy
consideration with the amount of work that we all have put into making
Windows support one of the best among programming languages of similar
category.
It'd be interesting to evaluate the cost associated with supporting Windows. Bare in mind, we're proposing to vote on this as a production feature for PHP 8 - which realistically means almost two years from now at the earliest. I'm sure we'd have Windows support a lot sooner than that if we decide that it's a must have. I agree with Nikita that the key question is in fact, do we or do we not want to introduce JIT in - with the main question being the maintenance cost. Let's tackle this question first, otherwise - why send Dmitry (and maybe others) for doing more work (Windows support) if we are likely to flush it all down the toilet?
I don't think it would be fair either to simply dismiss the idea and
many years of hard work for a detail like platform support either, and
that is not the way I hope anyone would cast their vote.
I think that if we reach the conclusion that Windows support is a must, we can condition the inclusion of JIT based on having it. Let's first agree on whether we want it in the first place.
Agreed. Naturally I would contribute in what I can to work on those
parts (Windows).
--
regards,
Kalle Sommer Nielsen
kalle@php.net
I'm honestly a bit perplexed by how many people here viewing Windows
support as a must have, while at the same time I think we all agree PHP is
very scarcely found on production Windows servers, and JIT is a
predominantly production feature.
While this is anecdotal, I think you might find a different perspective from user group organizers. I've encountered many user group members over the years who run PHP on Windows. It's more common that they develop on Windows and deploy to Linux, but I do know those who also deploy to Windows in production.
That's not to say I personally think that Windows support is a must-have for JIT, but it's definitely important for many of the people in the user groups I've worked with.
-Ben
Hi,
Den tor. 31. jan. 2019 kl. 18.39 skrev Dmitry Stogov dmitry@zend.com:
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
This has been a long time on the horizon, nice to see this finally
moving forward :)Here are some initial thoughts: I think that it's best to approach this
issue from a cost/benefit angle. The benefits of the JIT compiler are
roughly (and as already outlined in the RFC):
- Significantly better performance for numerical code.
- Slightly better performance for "typical" PHP web application code.
- The potential to move more code from C to PHP, because PHP will now
be sufficiently fast.However, there are also a number of costs, on which I'll expand in more
detail:a) Maintenance: This is really my main concern. Right now there are
about 3-4 people who I would trust to carry out a non-trivial language
change, which will require touching the compiler, the virtual machine,
the optimizer and the persistence layer. Each of those components is
quite complex, in different ways. Some people who are comfortable with
doing VM changes will struggle with implementing optimizer changes.Adding a JIT compiler exacerbates this issue further. Because this JIT
is dynasm based, the core JIT code is essentially written in raw x86
assembly. This will further limit the pool of people who will be able to
make non-trivial engine changes. Personally, I don't have any particular
familiarity with writing x86 assembly, so it will likely take a while to
get up to speed with this code.b) Bugs and stability: I think that everyone is aware that the initial
PHP 7.3 release suffered from substantial stability issues, more than
new minor version releases tend to do. I think there are multiple
reasons for that (and we might want to start a conversation about our QA
processes in a separate thread), but one main contributing factor were
opcache optimizer bugs. Compiler optimizations are tricky and hard to
verify, and we often only learn about issues once the optimizer makes
contact with production codebases, which feature a much richer
collection of code patterns than our test suite. One can wonder whether
the relatively minor speedups we get from our optimization framework are
really worth having these stability issues...Adding a JIT compiler adds a new dimension of stability issues. Next to
"simple" executor bugs, and optimizer bugs, we now get additional bugs
in the JIT. These are probably going to be hard to debug, as we'll have
to drop down from our usual C-level tooling, down to inspecting assembly.c) Platform support: Having a JIT segregates platforms into two tiers:
Those that have JIT support and those that don't. While that is not a
problem per se, it does introduce some dangers. For example, if we
decide to more parts of our C code into PHP because PHP is fast enough
with a JIT, that will of course only be true for platforms that actually
have JIT support. I'm not terribly concerned about loosing out some
performance on MIPS, but we do need to make sure that all our main
platforms are supported (Windows is a must there, imho).I don't see any problems with including JIT without Windows support.
Windows runs PHP much slower any way.Without my usual Windows bias, I do believe it is a considerable fact
like Nikita pointed out as Windows is a first class citizen in terms
of operating systems we support. While PHP on Windows may not have the
speed that the Unix counterpart have, it is still a very important
development platform. Many developers develop on Windows and deploy on
a Unix based system, being unable to test such an important feature in
a development environment is also a large question mark.
in the age of CI systems it doesn't matter much what your primary local
development platform is, even if it is different than the targeted
platform. One creates a PR, pushes, CI triggers, checks validity, could
be performance tested, and that's the real environment.
And not to mention containers for local development when the code is
actually run in a Linux container, no matter whether running on Win,
Linux or Mac.
I'm personally interested in taking a look at it (and I'm certain
Anatol does too), but simply dismissing is a no-go for me.
Best,
Andrey
I don't see any problems with including JIT without Windows support.
Windows runs PHP much slower any way.
How so? I tend to disagree here. Except if recent changes affect Windows
indirectly (as in optimization done on linux only).
Also while I use php on windows less, I still see a large amount of
companies using php on windows, in similar ways than on Linux.
Nikita concerns are valid, PHP is and should remain a cross platform
language. And some top OSes besides linux should remain a target. Easier
said than done and willing to help at least for windows. I am sure msft
teams will step in as well.
Pierre,
I don't see any problems with including JIT without Windows support.
Windows runs PHP much slower any way.How so? I tend to disagree here. Except if recent changes affect Windows
indirectly (as in optimization done on linux only).Also while I use php on windows less, I still see a large amount of
companies using php on windows, in similar ways than on Linux.Nikita concerns are valid, PHP is and should remain a cross platform
language. And some top OSes besides linux should remain a target. Easier
said than done and willing to help at least for windows. I am sure msft
teams will step in as well.
considering how open is Microsoft to open source nowadays it is probably
a no brainer to have them help. They might only need some hinting :)
Cheers,
Andrey
On Thu, Jan 31, 2019, 11:39 PM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com wrote:I don't see any problems with including JIT without Windows support. Windows runs PHP much slower any way.
How so? I tend to disagree here. Except if recent changes affect Windows
indirectly (as in optimization done on linux only).
More or less right. PHP uses GCC extensions, that are not available in MSVC.
Also while I use php on windows less, I still see a large amount of
companies using php on windows, in similar ways than on Linux.Nikita concerns are valid, PHP is and should remain a cross platform
language. And some top OSes besides linux should remain a target. Easier
said than done and willing to help at least for windows. I am sure msft
teams will step in as well.
It would be great, if MSFT team helps.
I definitely, can't move JIT forward, and provide support for all
platforms at the same time.
Thanks. Dmitry.
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
This has been a long time on the horizon, nice to see this finally moving
forward :)Here are some initial thoughts: I think that it's best to approach this
issue from a cost/benefit angle. The benefits of the JIT compiler are
roughly (and as already outlined in the RFC):
- Significantly better performance for numerical code.
- Slightly better performance for "typical" PHP web application code.
- The potential to move more code from C to PHP, because PHP will now be
sufficiently fast.However, there are also a number of costs, on which I'll expand in more
detail:a) Maintenance: This is really my main concern. Right now there are about
3-4 people who I would trust to carry out a non-trivial language change,
which will require touching the compiler, the virtual machine, the
optimizer and the persistence layer. Each of those components is quite
complex, in different ways. Some people who are comfortable with doing VM
changes will struggle with implementing optimizer changes.Adding a JIT compiler exacerbates this issue further. Because this JIT is
dynasm based, the core JIT code is essentially written in raw x86 assembly.
This will further limit the pool of people who will be able to make
non-trivial engine changes. Personally, I don't have any particular
familiarity with writing x86 assembly, so it will likely take a while to
get up to speed with this code.b) Bugs and stability: I think that everyone is aware that the initial PHP
7.3 release suffered from substantial stability issues, more than new minor
version releases tend to do. I think there are multiple reasons for that
(and we might want to start a conversation about our QA processes in a
separate thread), but one main contributing factor were opcache optimizer
bugs. Compiler optimizations are tricky and hard to verify, and we often
only learn about issues once the optimizer makes contact with production
codebases, which feature a much richer collection of code patterns than our
test suite. One can wonder whether the relatively minor speedups we get
from our optimization framework are really worth having these stability
issues...Adding a JIT compiler adds a new dimension of stability issues. Next to
"simple" executor bugs, and optimizer bugs, we now get additional bugs in
the JIT. These are probably going to be hard to debug, as we'll have to
drop down from our usual C-level tooling, down to inspecting assembly.c) Platform support: Having a JIT segregates platforms into two tiers:
Those that have JIT support and those that don't. While that is not a
problem per se, it does introduce some dangers. For example, if we decide
to more parts of our C code into PHP because PHP is fast enough with a JIT,
that will of course only be true for platforms that actually have JIT
support. I'm not terribly concerned about loosing out some performance on
MIPS, but we do need to make sure that all our main platforms are supported
(Windows is a must there, imho).d) Debugging: I'm not sure whether or not this is an issue (maybe the RFC
can clarify?), but I'm wondering if this will have an impact on things like
XDebug. Will it be possible to using XDebug to accurately inspect variables
at any point in time while the JIT is running? If not, that would be a big
tooling regression.I think those are the main points that come to mind right now...
Regards,
Nikita
I strongly with Nikita's points on cost/benefit analysis. I have
written a lot but thrown it away because I think this point is so
important:
It appears that the JIT does not work on Clang or MSVC compilers. As
such, I consider this dead on arrival, even if it's considered
experimental. There are cross-platform JIT's out there -- how do they
manage it? I think that's the next critical step.
On Sat, Feb 2, 2019, 12:46 AM Levi Morrison
I strongly with Nikita's points on cost/benefit analysis. I have
written a lot but thrown it away because I think this point is so
important:It appears that the JIT does not work on Clang or MSVC compilers.
It must some changes needed for php or simply lack of time to test on
MSVC. LibJit and DynAsm support it
As
such, I consider this dead on arrival, even if it's considered
experimental. There are cross-platform JIT's out there -- how do they
manage it? I think that's the next critical step.
I'm glad to finally propose including JIT into PHP.
I don't see anywhere in this RFC how it would affect thigns that do
sneaky things with internals, such as Xdebug. How is that going to be
affected?
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an
experimental feature.
I do not believe that something major like this should make it into any
PHP 7.x release. Having it as experimental new feature in the master/PHP
8.0 branch makes the most sense to me.
cheers,
Derick
--
https://derickrethans.nl | https://xdebug.org | https://dram.io
Like Xdebug? Consider a donation: https://xdebug.org/donate.php,
or become my Patron: https://www.patreon.com/derickr
twitter: @derickr and @xdebug
I'm glad to finally propose including JIT into PHP.
I don't see anywhere in this RFC how it would affect thigns that do
sneaky things with internals, such as Xdebug. How is that going to be
affected?
I suppose Xdebug should work on non-JIT-ed versions of the functions.
Even JVM deoptimizes to bytecode when debugging.
Thanks. Dmitry.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an
experimental feature.I do not believe that something major like this should make it into any
PHP 7.x release. Having it as experimental new feature in the master/PHP
8.0 branch makes the most sense to me.cheers,
Derick
I'm glad to finally propose including JIT into PHP.
I don't see anywhere in this RFC how it would affect thigns that do
sneaky things with internals, such as Xdebug. How is that going to be
affected?I suppose Xdebug should work on non-JIT-ed versions of the functions.
Even JVM deoptimizes to bytecode when debugging.
So, in that case, I think I would need to be able to instruct the PHP
JIT engine to be turned off. Perhaps through an API?
Similarly, I think it might be useful for OPcache as well, as I am
getting more people confused why some breakpoints don't work, or
variables don't exist:
https://bugs.xdebug.org/view.php?id=1609
cheers,
Derick
I'm glad to finally propose including JIT into PHP.
I don't see anywhere in this RFC how it would affect thigns that do
sneaky things with internals, such as Xdebug. How is that going to be
affected?I suppose Xdebug should work on non-JIT-ed versions of the functions.
Even JVM deoptimizes to bytecode when debugging.So, in that case, I think I would need to be able to instruct the PHP
JIT engine to be turned off. Perhaps through an API?Similarly, I think it might be useful for OPcache as well,
Use zend_alter_ini_entry() to set "opcache.enable" to "0".
Better to do it at RINIT.
Thanks. Dmitry.
as I am
getting more people confused why some breakpoints don't work, or
variables don't exist:
https://bugs.xdebug.org/view.php?id=1609cheers,
Derick
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
I would like to check if the JIT provides an improvement for PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible with
git clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunit
I tried to debug this. Unfortunately my gdb doesn't seem to work with JIT:
It hangs when the script starts running, on line Zend/zend_gdb.c:84 in
zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).
Nikita
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Thanks. Dmitry.
I would like to check if the JIT provides an improvement for PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible withgit clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunitI tried to debug this. Unfortunately my gdb doesn't seem to work with JIT:
It hangs when the script starts running, on line Zend/zend_gdb.c:84 in
zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).Nikita
Another project that I would like to test is amp
(git@github.com:amphp/amp.git).
Here I am getting a segfault only on shutdown, after tests finished
running. However there are a number of test failures, all basically looking
the same:
- Amp\Test\AllTest::testPendingPromiseArray
TypeError: Return value of Amp\Loop\Internal\TimerQueue::removeAndRebuild()
must be an instance of Amp\Loop\Internal\TimerQueueEntry, null returned
/home/nikic/amp/lib/Loop/Internal/TimerQueue.php:100
/home/nikic/amp/lib/Loop/Internal/TimerQueue.php:64
/home/nikic/amp/lib/Loop/NativeDriver.php:107
/home/nikic/amp/lib/Loop/Driver.php:134
/home/nikic/amp/lib/Loop/Driver.php:72
/home/nikic/amp/lib/Loop.php:84
/home/nikic/amp/test/AllTest.php:52
Here is the line that incorrectly gets a null:
https://github.com/amphp/amp/blob/c6f8425473ecc1cfc6909cf42b39abb39a11c837/lib/Loop/Internal/TimerQueue.php#L100
Nikita
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
I would like to check if the JIT provides an improvement for PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible withgit clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunitI tried to debug this. Unfortunately my gdb doesn't seem to work with
JIT: It hangs when the script starts running, on line Zend/zend_gdb.c:84
in zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).
GDB takes enormous time registering too many JIT-ed functions...
It should be possible to catch the name of problematic functions and the
JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but
most probably, only on next week.
Thanks. Dmitry.
Nikita
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
I would like to check if the JIT provides an improvement for PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible withgit clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunitI tried to debug this. Unfortunately my gdb doesn't seem to work with
JIT: It hangs when the script starts running, on line Zend/zend_gdb.c:84
in zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).GDB takes enormous time registering too many JIT-ed functions...
It should be possible to catch the name of problematic functions and the
JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but
most probably, only on next week.
I fixed the problem caused JIT to fail on PHP-Parser tests (it was
related to changes introduced by typed properties patch).
I'm also going to disable automatic JIT code registration in GDB.
Thanks. Dmitry.
Thanks. Dmitry.
Nikita
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
I would like to check if the JIT provides an improvement for PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible withgit clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunitI tried to debug this. Unfortunately my gdb doesn't seem to work with
JIT: It hangs when the script starts running, on line Zend/zend_gdb.c:84
in zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).GDB takes enormous time registering too many JIT-ed functions...
It should be possible to catch the name of problematic functions and the
JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but
most probably, only on next week.I fixed the problem caused JIT to fail on PHP-Parser tests (it was
related to changes introduced by typed properties patch).I'm also going to disable automatic JIT code registration in GDB.
Thanks. Dmitry.
Thanks. I was now able to run a PHP-Parser benchmark, which showed ~1.5x
speedup with default JIT configuration. That's promising :)
Next I want to try https://github.com/amphp/hpack (part of HTTP 2
implementation), where I also expect good results. Currently there is a
segfault while running tests.
Nikita
On Mon, Feb 4, 2019 at 2:26 PM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> > > >> On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> >> <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: >> >> Hi Internals, >> >> >> I'm glad to finally propose including JIT into PHP. >> >> >> https://wiki.php.net/rfc/jit >> >> >> In the current state it may be included both into PHP-8, where we >> are going to continue active improvement, and into PHP-7.4, as an >> experimental feature. >> >> >> Thanks. Dmitry. >> >> >> I would like to check if the JIT provides an improvement for PHP-Parser. >> Unfortunately I'm getting a segfault when running the tests. Should be >> reproducible with >> >> git clone git@github.com:nikic/PHP-Parser.git >> cd PHP-Parser >> composer install >> php-jit vendor/bin/phpunit >> >> I tried to debug this. Unfortunately my gdb doesn't seem to work with >> JIT: It hangs when the script starts running, on line Zend/zend_gdb.c:84 >> in zend_gdb_register_code. I don't know if that's a bug or I need to do >> something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3) >> 8.1.0.20180409-git). > > GDB takes enormous time registering too many JIT-ed functions... > It should be possible to catch the name of problematic functions and the > JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but > most probably, only on next week. I fixed the problem caused JIT to fail on PHP-Parser tests (it was related to changes introduced by typed properties patch). I'm also going to disable automatic JIT code registration in GDB. Thanks. Dmitry.
Thanks. I was now able to run a PHP-Parser benchmark, which showed ~1.5x
speedup with default JIT configuration. That's promising :)Next I want to try https://github.com/amphp/hpack (part of HTTP 2
implementation), where I also expect good results. Currently there is a
segfault while running tests.
Could you provide a quick instruction, how to reproduce this (in the
same way like with PHP-Parser).
Thanks. Dmitry.
Nikita
On Mon, Feb 4, 2019 at 2:26 PM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> > > >> On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> >> <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: >> >> Hi Internals, >> >> >> I'm glad to finally propose including JIT into PHP. >> >> >> https://wiki.php.net/rfc/jit >> >> >> In the current state it may be included both into PHP-8, where we >> are going to continue active improvement, and into PHP-7.4, as an >> experimental feature. >> >> >> Thanks. Dmitry. >> >> >> I would like to check if the JIT provides an improvement for PHP-Parser. >> Unfortunately I'm getting a segfault when running the tests. Should be >> reproducible with >> >> git clone git@github.com:nikic/PHP-Parser.git >> cd PHP-Parser >> composer install >> php-jit vendor/bin/phpunit >> >> I tried to debug this. Unfortunately my gdb doesn't seem to work with >> JIT: It hangs when the script starts running, on line Zend/zend_gdb.c:84 >> in zend_gdb_register_code. I don't know if that's a bug or I need to do >> something additional here (I'm using GNU gdb (Ubuntu
8.1-0ubuntu3)
>> 8.1.0.20180409-git). > > GDB takes enormous time registering too many JIT-ed functions... > It should be possible to catch the name of problematic functions and the > JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but > most probably, only on next week. I fixed the problem caused JIT to fail on PHP-Parser tests (it was related to changes introduced by typed properties patch). I'm also going to disable automatic JIT code registration in GDB. Thanks. Dmitry.
Thanks. I was now able to run a PHP-Parser benchmark, which showed ~1.5x
speedup with default JIT configuration. That's promising :)Next I want to try https://github.com/amphp/hpack (part of HTTP 2
implementation), where I also expect good results. Currently there is a
segfault while running tests.Could you provide a quick instruction, how to reproduce this (in the
same way like with PHP-Parser).
The reproduce steps are basically the same in this case, just on a
different repo:
git clone git@github.com:amphp/hpack.git
cd hpack
composer install
php-jit vendor/bin/phpunit
Nikita
On Mon, Feb 4, 2019 at 4:11 PM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> On Mon, Feb 4, 2019 at 2:26 PM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> > <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: > > > > On 2/1/19 4:23 PM, Dmitry Stogov wrote: > > > > > > On 2/1/19 3:09 PM, Nikita Popov wrote: > >> On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> > <mailto:dmitry@zend.com <mailto:dmitry@zend.com>> > >> <mailto:dmitry@zend.com <mailto:dmitry@zend.com> <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>>> wrote: > >> > >> Hi Internals, > >> > >> > >> I'm glad to finally propose including JIT into PHP. > >> > >> > >> https://wiki.php.net/rfc/jit > >> > >> > >> In the current state it may be included both into PHP-8, > where we > >> are going to continue active improvement, and into PHP-7.4, > as an > >> experimental feature. > >> > >> > >> Thanks. Dmitry. > >> > >> > >> I would like to check if the JIT provides an improvement for > PHP-Parser. > >> Unfortunately I'm getting a segfault when running the tests. > Should be > >> reproducible with > >> > >> git clone git@github.com:nikic/PHP-Parser.git > >> cd PHP-Parser > >> composer install > >> php-jit vendor/bin/phpunit > >> > >> I tried to debug this. Unfortunately my gdb doesn't seem to work > with > >> JIT: It hangs when the script starts running, on line > Zend/zend_gdb.c:84 > >> in zend_gdb_register_code. I don't know if that's a bug or I > need to do > >> something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3) > >> 8.1.0.20180409-git). > > > > GDB takes enormous time registering too many JIT-ed functions... > > It should be possible to catch the name of problematic functions > and the > > JIT only them (using PHPDOC trigger). I'll try to analyze the > crash, but > > most probably, only on next week. > > I fixed the problem caused JIT to fail on PHP-Parser tests (it was > related to changes introduced by typed properties patch). > > I'm also going to disable automatic JIT code registration in GDB. > > Thanks. Dmitry. > > > Thanks. I was now able to run a PHP-Parser benchmark, which showed ~1.5x > speedup with default JIT configuration. That's promising :) > > Next I want to try https://github.com/amphp/hpack (part of HTTP 2 > implementation), where I also expect good results. Currently there is a > segfault while running tests. Could you provide a quick instruction, how to reproduce this (in the same way like with PHP-Parser).
The reproduce steps are basically the same in this case, just on a
different repo:git clone git@github.com:amphp/hpack.git
cd hpack
composer install
php-jit vendor/bin/phpunitNikita
Fixed.
On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Thanks. Dmitry.
I would like to check if the JIT provides an improvement for
PHP-Parser.
Unfortunately I'm getting a segfault when running the tests. Should be
reproducible withgit clone git@github.com:nikic/PHP-Parser.git
cd PHP-Parser
composer install
php-jit vendor/bin/phpunitI tried to debug this. Unfortunately my gdb doesn't seem to work with
JIT: It hangs when the script starts running, on line
Zend/zend_gdb.c:84
in zend_gdb_register_code. I don't know if that's a bug or I need to do
something additional here (I'm using GNU gdb (Ubuntu 8.1-0ubuntu3)
8.1.0.20180409-git).GDB takes enormous time registering too many JIT-ed functions...
It should be possible to catch the name of problematic functions and the
JIT only them (using PHPDOC trigger). I'll try to analyze the crash, but
most probably, only on next week.I fixed the problem caused JIT to fail on PHP-Parser tests (it was
related to changes introduced by typed properties patch).I'm also going to disable automatic JIT code registration in GDB.
Thanks. Dmitry.
Thanks. I was now able to run a PHP-Parser benchmark, which showed ~1.5x
speedup with default JIT configuration. That's promising :)
Unfortunately I made a mistake here and benchmarked against vanilla PHP
without opcache (and more importantly the optimizer in opcache). Here are
the correct results (for repeated parsing of a large file):
PHP: 3.7s
PHP+optimizer: 3.2s
PHP+optimizer+JIT: 2.4s
So the speedup is ~1.3x rather than ~1.5x, which is still good.
I also ran the hello-world.php example of
https://github.com/amphp/http-server against wrk -c100 -d30 -t4 and got the
following results:
PHP: 9950 rps
PHP+optimizer: 10750 rps
PHP+optimizer+JIT: 11350 rps
So in this case the improvement is about 5%. (This is the HTTP 1.1 server,
HTTP 2 would also be interesting to try, but needs some more setup.)
Nikita
After figuring out that opcache.jit_buffer_size is specified in bytes
(not in megabytes, as RFC states) I got ~5% speedup running
vimeo/psalm (static analyzer) on its own codebase with default
JIT flags and ~7.3% with minimal JIT (1201).
PHP+optimizer (-dopcache.jit_buffer_size=0): 32.29s (100%)
PHP+optimizer+JIT (-dopcache.jit_buffer_size=50000000): 30.72s (95.1%)
PHP+optimizer+minimalJIT (-dopcache.jit_buffer_size=50000000
-dopcache.jit=1201): 29.95s (92.7%)
After figuring out that opcache.jit_buffer_size is specified in bytes
(not in megabytes, as RFC states)
Thanks for catching this. Fixed.
I got ~5% speedup running
vimeo/psalm (static analyzer) on its own codebase with default
JIT flags and ~7.3% with minimal JIT (1201).PHP+optimizer (-dopcache.jit_buffer_size=0): 32.29s (100%)
PHP+optimizer+JIT (-dopcache.jit_buffer_size=50000000): 30.72s (95.1%)
PHP+optimizer+minimalJIT (-dopcache.jit_buffer_size=50000000
-dopcache.jit=1201): 29.95s (92.7%)
It may be interesting to try -dopcache.jit=1235. It should JIT only hot
functions and requires some warm-up.
Thanks. Dmitry.
PHP+optimizer (-dopcache.jit_buffer_size=0): 32.29s (100%)
PHP+optimizer+JIT (-dopcache.jit_buffer_size=50000000): 30.72s (95.1%)
PHP+optimizer+minimalJIT (-dopcache.jit_buffer_size=50000000
-dopcache.jit=1201): 29.95s (92.7%)It may be interesting to try -dopcache.jit=1235. It should JIT only hot
functions and requires some warm-up.
For this use case 1201 was the fastest of all the options I tried
(including 1235).
Dmitry Stogov wrote:
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature.
Thanks. Dmitry.
Hi Dmitry,
Thank you for making an RFC for this. That makes it possible to have a
proper discussion about the JIT idea.
A concern I have with the current RFC is a lack of a good case for why
it should be necessary; the case for JIT is based on performance
benefits, but the examples provided are unconvincing to me because they
seem too contrived. Both bench.php and drawing fractals represent a
best-case example for a JIT, small programs which do heavy arithmetic
and not much else. Maybe PHP being able to be used for this kind of
software would be cool, but it wouldn't justify the added complexity
(and for that matter security headaches) of adding a JIT to PHP given C,
C++, FORTRAN and so on already exist and are better-suited to it.
I guess what I am saying is that the JIT RFC could benefit from
real-world examples that show a benefit to having it. The ideal
application is something in between WordPress and your Mandelbrot
example, one which has significant complexity (i.e. a plausible
real-world application), hot code which a JIT can actually make notably
faster than the current Zend VM, and is something not too far away
from the kinds of applications people write in PHP today — even if you
could write applications focussed on high-performance heavy
number-crunching in PHP, I don't expect people would want to, even if it
becomes less slow.
Thanks,
Andrea
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.
Can you give some information on if there are pre-conditions that must hold
for a function to be jitted, or quit conditions that force the JIT to be
reverted for a function? In addition, it would be helpful for testing if
there was a way to find out if a function was jitted, maybe through
ReflectionMethod/Function or opcache_get_status()
?
Thanks. Dmitry.
On Mon, Feb 4, 2019 at 10:29 PM Benjamin Eberlei kontakt@beberlei.de
wrote:
Hi Internals,
I'm glad to finally propose including JIT into PHP.
In the current state it may be included both into PHP-8, where we are
going to continue active improvement, and into PHP-7.4, as an experimental
feature.Can you give some information on if there are pre-conditions that must
hold for a function to be jitted, or quit conditions that force the JIT to
be reverted for a function? In addition, it would be helpful for testing if
there was a way to find out if a function was jitted, maybe through
ReflectionMethod/Function oropcache_get_status()
?
And as a follow up, the JIT seems to affect zend_execute_ex and
zend_execute_internal based profiling (tested with tideways_xhprof) in a
way that all Jitted functions are not called through those two hooks
anymore, and don't appear in profiling data anymore. Is that a correct
description? The number of parent=>child call entries drops from 88 to 12
in my sample code when jit is activated.
Is that a desired side-effect?
Thanks. Dmitry.
On Mon, Feb 4, 2019 at 10:29 PM Benjamin Eberlei <kontakt@beberlei.de
mailto:kontakt@beberlei.de> wrote:On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com>> wrote: Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Can you give some information on if there are pre-conditions that must hold for a function to be jitted, or quit conditions that force the JIT to be reverted for a function?
-dopcache.jit=1245 will lead to JIT only functions with @jit doc-comment
tag. It's possible to extend this manual control.
In addition, it would be helpful for testing if there was a way to find out if a function was jitted, maybe through ReflectionMethod/Function or `opcache_get_status()` ?
yes. This makes sense.
And as a follow up, the JIT seems to affect zend_execute_ex and
zend_execute_internal based profiling (tested with tideways_xhprof) in a
way that all Jitted functions are not called through those two hooks
anymore, and don't appear in profiling data anymore. Is that a correct
description? The number of parent=>child call entries drops from 88 to
12 in my sample code when jit is activated.Is that a desired side-effect?
Yes. This is, at least expected.
PHP profilers/debuggers may disable JIT and opcache for particular
request, setting "opcache.enable=0" in RINIT.
In addition, JIT-ed functions now may be tracked by Linux perf (oprofile
and Intel VTune).
$ perf record php -d opcache.huge_code_pages=0 -d opcache.jit_debug=0x10
bench.php
$ perf report
Thanks. Dmitry.
Thanks. Dmitry.
On Mon, Feb 4, 2019 at 10:29 PM Benjamin Eberlei <kontakt@beberlei.de
mailto:kontakt@beberlei.de> wrote:On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com>> wrote: Hi Internals, I'm glad to finally propose including JIT into PHP. https://wiki.php.net/rfc/jit In the current state it may be included both into PHP-8, where we are going to continue active improvement, and into PHP-7.4, as an experimental feature. Can you give some information on if there are pre-conditions that must hold for a function to be jitted, or quit conditions that force the JIT to be reverted for a function?
-dopcache.jit=1245 will lead to JIT only functions with @jit doc-comment
tag. It's possible to extend this manual control.
@jit works if I have full control over my code-base, but whenever I use
libraries/frameworks this kind of configuration is too static, and puts a
burden on open-source maintainers to figure out what they want to jit or
not for users.
This option will not be very useful from a distributed maintenance
perspective, especially if you don't know if users pick 4 or 3, this is too
much configuration details/micro-management in my opinion, especially given
your argument that JIT is supposed to be as transparent and behind the
scenes as possible for users.
In my opinion 4 should not be available to users.
In addition, it would be helpful for testing if there was a way to find out if a function was jitted, maybe through ReflectionMethod/Function or `opcache_get_status()` ?
yes. This makes sense.
And as a follow up, the JIT seems to affect zend_execute_ex and
zend_execute_internal based profiling (tested with tideways_xhprof) in a
way that all Jitted functions are not called through those two hooks
anymore, and don't appear in profiling data anymore. Is that a correct
description? The number of parent=>child call entries drops from 88 to
12 in my sample code when jit is activated.Is that a desired side-effect?
Yes. This is, at least expected.
PHP profilers/debuggers may disable JIT and opcache for particular
request, setting "opcache.enable=0" in RINIT.
This may be acceptable for development profilers, but it is not for
production profiling such as Blackfire and Tideways. I see that overwriting
internal function pointers still works for hooks, so that doesn't need
improvement, but PHP extensions need a way to control zend_execute_ex
behavior, or get an alternative hook for jit based execution.
For Xhprof style profilers, a hook that gets the class + function name
alone would be enough.
For tracing profilers based on a whitelist of a few instrumented functions
like tideways, NewRelic and probably all other APM vendor extensions, there
needs to be a hook to selectively decide "don't JIT this function", that
can be hooked into from 0 to many extensions.
Example, Tideways hooks into the userland function Mage::logException(), to
detect that Magento has thrown an exception that leads to a 500 page being
rendered. It should be possible to make sure this function never gets
jitted, so that I see its execution in zend_execute_ex.
In addition, JIT-ed functions now may be tracked by Linux perf (oprofile
and Intel VTune).$ perf record php -d opcache.huge_code_pages=0 -d opcache.jit_debug=0x10
bench.php
$ perf report
I think you overestimate PHP users savyness in Linux level profiling, maybe
1 in 100 knows how to use perf. In addition many PHP users don't have root
on their servers (managed). And within Docker you don't even get there to
start perfing. Profilers that put user experience first must be PHP
extensions, so we need to make sure the basic level of hooking is possible
even though we have a JIT.
Thanks. Dmitry.
Thanks. Dmitry.
On Tue, Feb 5, 2019 at 7:46 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> > > On Mon, Feb 4, 2019 at 10:29 PM Benjamin Eberlei <kontakt@beberlei.de <mailto:kontakt@beberlei.de> > <mailto:kontakt@beberlei.de <mailto:kontakt@beberlei.de>>> wrote: > > > > On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> > <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: > > Hi Internals, > > > I'm glad to finally propose including JIT into PHP. > > > https://wiki.php.net/rfc/jit > > > In the current state it may be included both into PHP-8, where > we are going to continue active improvement, and into PHP-7.4, > as an experimental feature. > > > Can you give some information on if there are pre-conditions that > must hold for a function to be jitted, or quit conditions that force > the JIT to be reverted for a function? -dopcache.jit=1245 will lead to JIT only functions with @jit doc-comment tag. It's possible to extend this manual control.
@jit works if I have full control over my code-base, but whenever I use
libraries/frameworks this kind of configuration is too static, and puts
a burden on open-source maintainers to figure out what they want to jit
or not for users.This option will not be very useful from a distributed maintenance
perspective, especially if you don't know if users pick 4 or 3, this is
too much configuration details/micro-management in my opinion,
especially given your argument that JIT is supposed to be as transparent
and behind the scenes as possible for users.In my opinion 4 should not be available to users.
In some cases it may help (similar to "inline" in C).
For better performance, I would recomend "hot counters trigger" - 3 or
everything - 0.
> In addition, it would be > helpful for testing if there was a way to find out if a function was > jitted, maybe through ReflectionMethod/Function or > opcache_get_status() ? yes. This makes sense. > > And as a follow up, the JIT seems to affect zend_execute_ex and > zend_execute_internal based profiling (tested with tideways_xhprof) in a > way that all Jitted functions are not called through those two hooks > anymore, and don't appear in profiling data anymore. Is that a correct > description? The number of parent=>child call entries drops from 88 to > 12 in my sample code when jit is activated. > > Is that a desired side-effect? Yes. This is, at least expected. PHP profilers/debuggers may disable JIT and opcache for particular request, setting "opcache.enable=0" in RINIT.
This may be acceptable for development profilers, but it is not for
production profiling such as Blackfire and Tideways. I see that
overwriting internal function pointers still works for hooks, so that
doesn't need improvement, but PHP extensions need a way to control
zend_execute_ex behavior, or get an alternative hook for jit based
execution.
JIT doesn't make a lot of sense if it doesn't optimize the overhead of
interpretation (nested calls to execute_ex, etc). It's clear, that it's
more difficult to debug optimized native code. Most implementations
fallback to interpretation when need debugging. Profiling of optimized
code is possible, but requires additional hooks.
For Xhprof style profilers, a hook that gets the class + function name
alone would be enough.For tracing profilers based on a whitelist of a few instrumented
functions like tideways, NewRelic and probably all other APM vendor
extensions, there needs to be a hook to selectively decide "don't JIT
this function", that can be hooked into from 0 to many extensions.
Example, Tideways hooks into the userland function Mage::logException(),
to detect that Magento has thrown an exception that leads to a 500 page
being rendered. It should be possible to make sure this function never
gets jitted, so that I see its execution in zend_execute_ex.
It's easily possible to disable JIT-ing by implementing @nojit (it's
pity, we didn't get attributes).
Thanks. Dmitry.
In addition, JIT-ed functions now may be tracked by Linux perf (oprofile and Intel VTune). $ perf record php -d opcache.huge_code_pages=0 -d opcache.jit_debug=0x10 bench.php $ perf report
I think you overestimate PHP users savyness in Linux level profiling,
maybe 1 in 100 knows how to use perf. In addition many PHP users don't
have root on their servers (managed). And within Docker you don't even
get there to start perfing. Profilers that put user experience first
must be PHP extensions, so we need to make sure the basic level of
hooking is possible even though we have a JIT.Thanks. Dmitry. > > > > Thanks. Dmitry.
On Tue, Feb 5, 2019 at 7:46 AM Dmitry Stogov <dmitry@zend.com
mailto:dmitry@zend.com> wrote:> > > On Mon, Feb 4, 2019 at 10:29 PM Benjamin Eberlei <kontakt@beberlei.de <mailto:kontakt@beberlei.de> > <mailto:kontakt@beberlei.de <mailto:kontakt@beberlei.de>>> wrote: > > > > On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov <dmitry@zend.com <mailto:dmitry@zend.com> > <mailto:dmitry@zend.com <mailto:dmitry@zend.com>>> wrote: > > Hi Internals, > > > I'm glad to finally propose including JIT into PHP. > > > https://wiki.php.net/rfc/jit > > > In the current state it may be included both into PHP-8, where > we are going to continue active improvement, and into PHP-7.4, > as an experimental feature. > > > Can you give some information on if there are pre-conditions
that
> must hold for a function to be jitted, or quit conditions that force > the JIT to be reverted for a function? -dopcache.jit=1245 will lead to JIT only functions with @jit doc-comment tag. It's possible to extend this manual control.
@jit works if I have full control over my code-base, but whenever I use
libraries/frameworks this kind of configuration is too static, and puts
a burden on open-source maintainers to figure out what they want to jit
or not for users.This option will not be very useful from a distributed maintenance
perspective, especially if you don't know if users pick 4 or 3, this is
too much configuration details/micro-management in my opinion,
especially given your argument that JIT is supposed to be as transparent
and behind the scenes as possible for users.In my opinion 4 should not be available to users.
In some cases it may help (similar to "inline" in C).
For better performance, I would recomend "hot counters trigger" - 3 or
everything - 0.> In addition, it would be > helpful for testing if there was a way to find out if a function was > jitted, maybe through ReflectionMethod/Function or > `opcache_get_status()` ? yes. This makes sense. > > And as a follow up, the JIT seems to affect zend_execute_ex and > zend_execute_internal based profiling (tested with tideways_xhprof) in a > way that all Jitted functions are not called through those two
hooks
> anymore, and don't appear in profiling data anymore. Is that a correct > description? The number of parent=>child call entries drops from 88 to > 12 in my sample code when jit is activated. > > Is that a desired side-effect? Yes. This is, at least expected. PHP profilers/debuggers may disable JIT and opcache for particular request, setting "opcache.enable=0" in RINIT.
This may be acceptable for development profilers, but it is not for
production profiling such as Blackfire and Tideways. I see that
overwriting internal function pointers still works for hooks, so that
doesn't need improvement, but PHP extensions need a way to control
zend_execute_ex behavior, or get an alternative hook for jit based
execution.JIT doesn't make a lot of sense if it doesn't optimize the overhead of
interpretation (nested calls to execute_ex, etc). It's clear, that it's
more difficult to debug optimized native code. Most implementations
fallback to interpretation when need debugging. Profiling of optimized
code is possible, but requires additional hooks.
I understand, but its not about preventing execute_ex for all calls, just
for the 50ish that I am interested in, high level framework functions that
are probably not efficently Jitted anyways.
For Tideways as production profiler, I am obviously interested in users
having great performance, but our users trust us to instrument what is
necessary to find out what might be wrong.
For Xhprof style profilers, a hook that gets the class + function name
alone would be enough.For tracing profilers based on a whitelist of a few instrumented
functions like tideways, NewRelic and probably all other APM vendor
extensions, there needs to be a hook to selectively decide "don't JIT
this function", that can be hooked into from 0 to many extensions.
Example, Tideways hooks into the userland function Mage::logException(),
to detect that Magento has thrown an exception that leads to a 500 page
being rendered. It should be possible to make sure this function never
gets jitted, so that I see its execution in zend_execute_ex.It's easily possible to disable JIT-ing by implementing @nojit (it's
pity, we didn't get attributes).
Sorry, but I can't add @nojit or @jit to third party frameworks or
libraries. And this is what most Profiling/APM extensions are explicitly
hooking into. A third party extension must control this somehow, without
users having to have to change their code at all.
ZEND_API extern int (*opcache_jit_accept_handler)(zend_string *class_name,
zend_string *function_name);
Then i can overwrite it in my own extension:
int tideways_jit_accept_handler(zend_string *class_name, zend_string
*function_name) {
if (zend_hash_key_exists(TRG(callbacks), class_name)) {
return DENY;
}
if (!class_name && zend_hash_key_exists(TRG(callbacks),
function_name)) {
return DENY;
}
return original_jit_accept_handler(class_name, function_name);
}
Problem with this hook would be that it needed to be available in Zend/ and
not in ext-opcache so i can trust this global variable to exist in every
compile such as zend_execute_ex.
Thanks. Dmitry.
In addition, JIT-ed functions now may be tracked by Linux perf (oprofile and Intel VTune). $ perf record php -d opcache.huge_code_pages=0 -d opcache.jit_debug=0x10 bench.php $ perf report
I think you overestimate PHP users savyness in Linux level profiling,
maybe 1 in 100 knows how to use perf. In addition many PHP users don't
have root on their servers (managed). And within Docker you don't even
get there to start perfing. Profilers that put user experience first
must be PHP extensions, so we need to make sure the basic level of
hooking is possible even though we have a JIT.Thanks. Dmitry. > > > > Thanks. Dmitry.
Can you give some information on if there are pre-conditions that must hold for a function to be jitted, or quit conditions that force the JIT to be reverted for a function?
-dopcache.jit=1245 will lead to JIT only functions with @jit doc-comment
tag. It's possible to extend this manual control.
Shouldn't we introduce annotations instead of relying on doc comments?
Regards, Niklas
Den tir. 5. feb. 2019 kl. 20.48 skrev Niklas Keller me@kelunik.com:
Shouldn't we introduce annotations instead of relying on doc comments?
Yeah I'm not too happy with that approach either. I would rather see
another way to do this and like you said; annotations is probably the
best way to go about it as introducing a new keyword is not very
suitable imo.
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Den tir. 5. feb. 2019 kl. 20.48 skrev Niklas Keller me@kelunik.com:
Shouldn't we introduce annotations instead of relying on doc comments?
Yeah I'm not too happy with that approach either. I would rather see
another way to do this and like you said; annotations is probably the
best way to go about it as introducing a new keyword is not very
suitable imo.
Attributes were proposed ~3 years ago.
https://wiki.php.net/rfc/attributes
There were few other releted proposals.
But they didn't pass.
Thanks. Dmitry.
Den tir. 5. feb. 2019 kl. 20.48 skrev Niklas Keller me@kelunik.com:
Shouldn't we introduce annotations instead of relying on doc comments?
Yeah I'm not too happy with that approach either. I would rather see
another way to do this and like you said; annotations is probably the
best way to go about it as introducing a new keyword is not very
suitable imo.Attributes were proposed ~3 years ago.
https://wiki.php.net/rfc/attributes
There were few other releted proposals.
But they didn't pass.
Understanding and adoptions of annotations (Doctrine mainly afaics)
have change. I think it is tricky to define it in a way that it can be
useful and adopted as a core language feature, meaning being flexible
enough to be extendable and usable as a base for userland extensions.
That latter part is the biggest challenge. What do the actual
users/authors of the current userland implementation think? (pls other
thread? :)
Best,
Pierre
@pierrejoye