# @@Jit Attribute Considerations

- Thread: https://externals.io/message/111300
- Original archive: https://news-web.php.net/php.internals/111300
- Started by Benjamin Eberlei on 2020-08-03T17:44:46+00:00
- Messages: 10
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #111300 — Benjamin Eberlei — 2020-08-03T17:44:46+00:00

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

Hi,

I am going to pick up a discussion from
https://github.com/php/php-src/pull/5915 about the @@Jit attribute.

Nikita mentioned he is still not 100% clear what the usecase is for @@Jit
attribute and asked to discuss here.

The reason is that the default tracing JIT is clever to decide itself when
to JIT or not, better not interfere with that. In case you run the tracing
JIT, only @@Jit("off") has an effect the others @@Jit("tracing") and
@@Jit("function") get ignored.

Only the trigger mode 4 (attributes) is actually using @@Jit("tracing") and
"function". This trigger mode feels like micro-management for developers
and since it has virtually no spotlight in discussions and blog posts about
the JIT at the moment, we don't know if it brings benefits.

Maybe for now it would be better to remove docblock / attribute support for
the JIT, and take a new attempt at it in 8.1? That prevents us from rolling
something we regret having to maintain later.

greetings
Benjamin

---

## #111301 — Stanislav Malyshev — 2020-08-03T18:51:43+00:00

URL: https://externals.io/message/111300#111301 · In reply to: #111300

Hi!

> Only the trigger mode 4 (attributes) is actually using @@Jit("tracing") and
> "function". This trigger mode feels like micro-management for developers
> and since it has virtually no spotlight in discussions and blog posts about
> the JIT at the moment, we don't know if it brings benefits.

I think turning JIT off is a valid use case, the rest looks much more
iffy. I am not sure we want to let people tell the engine to JIT certain
functions - are there a lot of cases where the engine wouldn't do it but
it's actually the right thing to do?

Don't see any use for "opcache.jit=attributes".

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #111302 — Benjamin Eberlei — 2020-08-03T19:20:35+00:00

URL: https://externals.io/message/111300#111302 · In reply to: #111301

On Mon, Aug 3, 2020 at 8:51 PM Stanislav Malyshev <smalyshev@gmail.com>
wrote:

> Hi!
>
> > […]
> and
> > […]
> about
> > […]
>
> I think turning JIT off is a valid use case, the rest looks much more
> iffy. I am not sure we want to let people tell the engine to JIT certain
> functions - are there a lot of cases where the engine wouldn't do it but
> it's actually the right thing to do?
>

In that case maybe we should rename the attribute to @@DisableJit ? This
would not clutter the global namespace with a "jit" class.

>
> Don't see any use for "opcache.jit=attributes".
>
> --
> Stas Malyshev
> smalyshev@gmail.com

---

## #111303 — Peter Bowyer — 2020-08-03T19:39:32+00:00

URL: https://externals.io/message/111300#111303 · In reply to: #111301

> I think turning JIT off is a valid use case, the rest looks much more
> iffy. I am not sure we want to let people tell the engine to JIT certain
> functions - are there a lot of cases where the engine wouldn't do it but
> it's actually the right thing to do?
>

Wouldn't a use case be profiling code, to see if JIT makes a difference to
a specific function? So I can profile with JIT disabled globally and @@JIT
on specific code, modify my code and see if it improves the JIT performance?

I'm basing this on my experience with the @jit annotation in Numba (
http://numba.pydata.org/) where it's useful to see the effect on small
pieces of code.

Peter

---

## #111304 — Derick Rethans — 2020-08-03T20:27:14+00:00

URL: https://externals.io/message/111300#111304 · In reply to: #111302

>In that case maybe we should rename the attribute to @@DisableJit ?
>This
>would not clutter the global namespace with a "jit" class.

Things with a negative name are usually a code smell. I'm not keen on a @[disableJit] attribute name.

cheers,
Derick

---

## #111305 — Benas IML — 2020-08-03T20:36:05+00:00

URL: https://externals.io/message/111300#111305 · In reply to: #111304

`@@NoJit` sounds pretty alright to me.



> On 3 August 2020 20:20:35 BST, Benjamin Eberlei <kontakt@beberlei.de>
> wrote:
>
> > […]
>
> Things with a negative name are usually a code smell. I'm not keen on a
> @[disableJit] attribute name.
>
> cheers,
> Derick
>
> --
> 
> To unsubscribe, visit: https://www.php.net/unsub.php

---

## #111306 — Benjamin Eberlei — 2020-08-04T07:15:43+00:00

URL: https://externals.io/message/111300#111306 · In reply to: #111305

Alternatively make it @@Jit("off") only and any other argument will lead to
an error for now.

Then the problem left becomes "Jit" being a very short global class.



> `@@NoJit` sounds pretty alright to me.
>
> 
>
> > […]

---

## #111311 — Benjamin Eberlei — 2020-08-04T08:11:35+00:00

URL: https://externals.io/message/111300#111311 · In reply to: #111300

> Hi,
>
> I am going to pick up a discussion from
> https://github.com/php/php-src/pull/5915 about the @@Jit attribute.
>
> Nikita mentioned he is still not 100% clear what the usecase is for @@Jit
> attribute and asked to discuss here.
>
> The reason is that the default tracing JIT is clever to decide itself when
> to JIT or not, better not interfere with that. In case you run the tracing
> JIT, only @@Jit("off") has an effect the others @@Jit("tracing") and
> @@Jit("function") get ignored.
>
> Only the trigger mode 4 (attributes) is actually using @@Jit("tracing")
> and "function". This trigger mode feels like micro-management for
> developers and since it has virtually no spotlight in discussions and blog
> posts about the JIT at the moment, we don't know if it brings benefits.
>
> Maybe for now it would be better to remove docblock / attribute support
> for the JIT, and take a new attempt at it in 8.1? That prevents us from
> rolling something we regret having to maintain later.
>

I updated the PR https://github.com/php/php-src/pull/5915 with the
following things:

- Removed attribute trigger mode for now.
- Removed obsolete doc comment trigger mode
- Add @@Jit("off") to disable JIT for an op_array or script

Open questions:
- Are we ok with removing @Jit("on"), @@Jit("tracing") and
@@Jit("function") for now to thoroughly discuss best approach for 8.1?
- Rename @@Jit to something more specific like @@JitOptions or @@JitHint?
- Remove the attribute trigger constant 4, and move tracing JIT to use 4
instead of 5?

Outlook:

We need to think about what the @@Jit attribute should actually mean in
context of the function or tracing JIT. Personally it probably means
"Always Jit this function regardless of hot counter or tracing results".
I believe we don't need the attributes trigger mode, as everything happens
either in context of function or tracing JIT.


> greetings
> Benjamin

---

## #111348 — Dmitry Stogov — 2020-08-06T06:50:35+00:00

URL: https://externals.io/message/111300#111348 · In reply to: #111311

My solution:

- remove doc-comment trigger. It doesn't make sense.
- add @@Jit("off") only. Later we may extend this.


On Tue, Aug 4, 2020 at 11:11 AM Benjamin Eberlei <kontakt@beberlei.de>
wrote:

> On Mon, Aug 3, 2020 at 7:44 PM Benjamin Eberlei <kontakt@beberlei.de>
> wrote:
>
> > […]
> when
> > […]
> tracing
> > […]
> blog
> > […]
>
> I updated the PR https://github.com/php/php-src/pull/5915 with the
> following things:
>
> - Removed attribute trigger mode for now.
> - Removed obsolete doc comment trigger mode
> - Add @@Jit("off") to disable JIT for an op_array or script
>
> Open questions:
> - Are we ok with removing @Jit("on"), @@Jit("tracing") and
> @@Jit("function") for now to thoroughly discuss best approach for 8.1?
> - Rename @@Jit to something more specific like @@JitOptions or @@JitHint?
> - Remove the attribute trigger constant 4, and move tracing JIT to use 4
> instead of 5?
>
> Outlook:
>
> We need to think about what the @@Jit attribute should actually mean in
> context of the function or tracing JIT. Personally it probably means
> "Always Jit this function regardless of hot counter or tracing results".
> I believe we don't need the attributes trigger mode, as everything happens
> either in context of function or tracing JIT.
>
>
> > […]

---

## #111356 — Aleksander Machniak — 2020-08-06T08:44:25+00:00

URL: https://externals.io/message/111300#111356 · In reply to: #111348

> My solution:
> 
> - remove doc-comment trigger. It doesn't make sense.
> - add @@Jit("off") only. Later we may extend this.

There are pros and cons to the "Jit" attribute name, please consider
@@JitOff (and @@JitOn).

Also make sure to define what happens if you use the attribute on a
function as well as class or e.g. class constant. In other words, when
it's not applicable will it be ignored or throw a warning/error?

-- 
Aleksander Machniak
Kolab Groupware Developer        [https://kolab.org]
Roundcube Webmail Developer  [https://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com
