# [RFC] [Discussion] A new JIT implementation based on IR Framework

- Thread: https://externals.io/message/121108
- Original archive: https://news-web.php.net/php.internals/121108
- Started by Dmitry Stogov on 2023-09-21T08:26:34+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #121108 — Dmitry Stogov — 2023-09-21T08:26:34+00:00

URL: https://externals.io/message/121108#121108

Hi Internals,

After all the Poll Request discussions (see
https://github.com/php/php-src/pull/12079), code-reviews and internal
discussions with core developers we decided to move this through the RFC
process.

Thanks to all participants.

The RFC is open for discussion: https://wiki.php.net/rfc/jit-ir

Thanks. Dmitry.

---

## #121109 — tim@bastelstu.be — 2023-09-21T09:13:14+00:00

URL: https://externals.io/message/121108#121109 · In reply to: #121108

Hi


> After all the Poll Request discussions (see
> https://github.com/php/php-src/pull/12079), code-reviews and internal
> discussions with core developers we decided to move this through the RFC
> process.
> 
> Thanks to all participants.
> 
> The RFC is open for discussion: https://wiki.php.net/rfc/jit-ir

Thank you. I find it important to follow the formal process, even if 
many folks are not able to make a meaningful decision due to the lack of 
knowledge about the topic. This includes me.

That said, I'd like to add my two cents to the "Open Issues" section:

My understanding is that even if the new JIT might not (yet) be better 
than the old one, it is not worse and it is more maintainable. The 
reactions from more knowledgeable folks were pretty positive overall.

So if the new JIT passes the existing test suite without issues, I don't 
see a reason why the old JIT should not be replaced right away. By 
immediately removing the old JIT (ideally in a separate commit) the 
codebase is cleaned up and users that want to test PHP 8.4 (or whatever 
that version may be in the end) will be forced to also test the new JIT 
which is probably a good thing.

Best regards
Tim Düsterhus

---

## #121110 — Sebastian Bergmann — 2023-09-21T09:21:59+00:00

URL: https://externals.io/message/121108#121110 · In reply to: #121109

Am 21.09.2023 um 11:13 schrieb Tim Düsterhus:
> Thank you. I find it important to follow the formal process, even if many 
> folks are not able to make a meaningful decision due to the lack of 
> knowledge about the topic. This includes me.

I'm in the same boat.

> My understanding is that even if the new JIT might not (yet) be better 
> than the old one, it is not worse and it is more maintainable. The 
> reactions from more knowledgeable folks were pretty positive overall.

That is my understanding as well.

> So if the new JIT passes the existing test suite without issues, I don't 
> see a reason why the old JIT should not be replaced right away. By 
> immediately removing the old JIT (ideally in a separate commit) the 
> codebase is cleaned up and users that want to test PHP 8.4 (or whatever 
> that version may be in the end) will be forced to also test the new JIT 
> which is probably a good thing.

I agree.

As a sidenote: most of the teams that I work with use PHP 8 in production. 
However, none of them use the current JIT. It either caused problems 
(especially during early PHP 8.0 versions), or does not bring any 
significant performance improvement. Against that backdrop, I would be 
interested in whether you, Dmitry or Zend, can share some insight from 
real-world usage of the JIT.

---

## #121111 — Dmitry Stogov — 2023-09-21T09:25:42+00:00

URL: https://externals.io/message/121108#121111 · In reply to: #121109

Hi Tim.



> Hi
>
> 
> > […]
>
> Thank you. I find it important to follow the formal process, even if
> many folks are not able to make a meaningful decision due to the lack of
> knowledge about the topic. This includes me.
>
> That said, I'd like to add my two cents to the "Open Issues" section:
>
> My understanding is that even if the new JIT might not (yet) be better
> than the old one, it is not worse and it is more maintainable. The
> reactions from more knowledgeable folks were pretty positive overall.
>
> So if the new JIT passes the existing test suite without issues,


Passing test suites doesn't mean we couldn't have other problems.


> I don't
> see a reason why the old JIT should not be replaced right away. By
> immediately removing the old JIT (ideally in a separate commit)
>

I'm going to agree to remove the old JIT and I like the idea of removing it
in a separate commit.

Thanks. Dmitry.


>
> Best regards
> Tim Düsterhus

---

## #121112 — Deleu — 2023-09-21T09:31:22+00:00

URL: https://externals.io/message/121108#121112 · In reply to: #121109

> Hi
>
> 
> My understanding is that even if the new JIT might not (yet) be better
> than the old one, it is not worse and it is more maintainable. The
> reactions from more knowledgeable folks were pretty positive overall.
>
> So if the new JIT passes the existing test suite without issues, I don't
> see a reason why the old JIT should not be replaced right away. By
> immediately removing the old JIT (ideally in a separate commit) the
> codebase is cleaned up and users that want to test PHP 8.4 (or whatever
> that version may be in the end) will be forced to also test the new JIT
> which is probably a good thing.
>

If I understand correctly, the only way to fallback to the JIT 1.0
implementation is by compiling PHP with a new introduced flag, so the JIT
2.0 needs to be opt-out. The RFC doesn't mention the configurations for new
JIT (init settings) which makes me assume that they're exactly the same? If
these assumptions are right, I think the matter of keeping or removing JIT
1.0 implementation is mostly a matter of what makes Dmitry more
comfortable. Removing it straight-away might result in adding more pressure
in getting bug fixes on the new one, while keeping it might make it
possible for whoever is relying heavily on JIT to still compile new PHP
releases with JIT 1.0 to give more time to iron out the final details on
JIT 2.0.

Of course this is a very basic analysis on my part which mixes my
experience in replacing PHP running-systems with new rewrites and it's much
more comfortable to me to have a fallback mechanism in place which may or
may not be entirely relevant here.

-- 
Marco Deleu

---

## #121113 — Dmitry Stogov — 2023-09-21T09:37:17+00:00

URL: https://externals.io/message/121108#121113 · In reply to: #121110

Hi Sebastian,

On Thu, Sep 21, 2023 at 12:22 PM Sebastian Bergmann <sebastian@php.net>
wrote:

> Am 21.09.2023 um 11:13 schrieb Tim Düsterhus:
> > […]
> many
> > […]
>
> I'm in the same boat.
>
> > […]
>
> That is my understanding as well.
>
> > […]
>
> I agree.
>
> As a sidenote: most of the teams that I work with use PHP 8 in production.
> However, none of them use the current JIT. It either caused problems
> (especially during early PHP 8.0 versions), or does not bring any
> significant performance improvement. Against that backdrop, I would be
> interested in whether you, Dmitry or Zend, can share some insight from
> real-world usage of the JIT.
>

I still don't recommend using JIT for production without serious testing
and benchmarking for each concrete case.
If you see less than 5% speedup - you probably don't need JIT; if an AMPHP
bsed server becomes 1.5 times faster it's a different story.

Thanks. Dmitry.


> --
> 
> To unsubscribe, visit: https://www.php.net/unsub.php

---

## #121114 — Dmitry Stogov — 2023-09-21T09:47:46+00:00

URL: https://externals.io/message/121108#121114 · In reply to: #121112

Hi Deleu,



>
>
> 
>
> > […]
>
> If I understand correctly, the only way to fallback to the JIT 1.0
> implementation is by compiling PHP with a new introduced flag, so the JIT
> 2.0 needs to be opt-out. The RFC doesn't mention the configurations for new
> JIT (init settings) which makes me assume that they're exactly the same? If
> these assumptions are right, I think the matter of keeping or removing JIT
> 1.0 implementation is mostly a matter of what makes Dmitry more
> comfortable. Removing it straight-away might result in adding more pressure
> in getting bug fixes on the new one, while keeping it might make it
> possible for whoever is relying heavily on JIT to still compile new PHP
> releases with JIT 1.0 to give more time to iron out the final details on
> JIT 2.0.
>

In the current state the Pull Request starts using the new JIT
implementation by default, but keeps the old implementation.
It's a question, if we need to keep it for a while or remove it immediately.
Now I think it's going to be removed in PR/RFC before starting the voting.


> Of course this is a very basic analysis on my part which mixes my
> experience in replacing PHP running-systems with new rewrites and it's much
> more comfortable to me to have a fallback mechanism in place which may or
> may not be entirely relevant here.
>

Keeping the disabled old JIT, we won't test it anyway and this won't
guarantee anything.
In case the new JIT will cause really serious problems we may consider
reverting it.

Thanks. Dmitry
.

>
> --
> Marco Deleu

---

## #121234 — Dmitry Stogov — 2023-10-05T16:44:05+00:00

URL: https://externals.io/message/121108#121234 · In reply to: #121108

Hi Internals,

I've published a presentation about the IR Framework design and
implementation details.
See
https://www.researchgate.net/publication/374470404_IR_JIT_Framework_a_base_for_the_next_generation_JIT_for_PHP
It explains many complex things in simple pictures.

Thanks. Dmitry.

On Thu, Sep 21, 2023 at 11:26 AM Dmitry Stogov <dmitrystogov@gmail.com>
wrote:

> Hi Internals,
>
> After all the Poll Request discussions (see
> https://github.com/php/php-src/pull/12079), code-reviews and internal
> discussions with core developers we decided to move this through the RFC
> process.
>
> Thanks to all participants.
>
> The RFC is open for discussion: https://wiki.php.net/rfc/jit-ir
>
> Thanks. Dmitry.

---

## #121235 — Paul Dragoonis — 2023-10-05T17:20:54+00:00

URL: https://externals.io/message/121108#121235 · In reply to: #121234

> Hi Internals,
>
> I've published a presentation about the IR Framework design and
> implementation details.
> See
>
> https://www.researchgate.net/publication/374470404_IR_JIT_Framework_a_base_for_the_next_generation_JIT_for_PHP
> It explains many complex things in simple pictures.
>

Hi Dmitry,

Thanks for helping explain things in graphical format. I will for sure
study the material closely.

As for the point around keeping the old JIT around as a safety measure and
fallback.

I think this is an excellent idea and may give good peace of mind and
confidence for new adopters, that they can easily "switch back" to JIT 1.0
if any edge cases occur we didn't find yet in JIT 2.0, without waiting for
future PHP releases (patches) to come out.

It can be months before people get new patched PHP versions (think about
centos or Debian distributions, or Docker images of PHP)

Just like we've done with many things over the years, we first deprecated
something and keep it in the language and in future release we remove it
completely.

Many thanks,
Paul



> Thanks. Dmitry.
>
> On Thu, Sep 21, 2023 at 11:26 AM Dmitry Stogov <dmitrystogov@gmail.com>
> wrote:
>
> > […]
