frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Use auto_globals_jit to make classic mode like worker mode for some use-cases

Open withinboredom opened this issue 2 months ago • 4 comments

Describe your feature request

Is your feature request related to a problem? Please describe.

We (myself and @SpencerMalone) were discussing how to use workers to 'bootstrap' an application, then wait for a request, then die() to allow for classical applications to get some performance without having to rewrite them for worker mode.

Describe the solution you'd like

We could maybe specify in the caddyfile:

preheat public/index.php

for a route, then we spawn up some workers that start up the file and once a superglobal is accessed, we pause execution until a request comes through, fill in the superglobals, then continue the script. This requires the use of auto_globals_jit to make work, but older/custom applications will be able to take advantage of performance from frankenphp while implementing worker scripts.

withinboredom avatar Oct 12 '25 19:10 withinboredom

That would lead to problem with things like db connections that aren't properly refreshed from the point of pre-heating to the actual execution of a script.

The use-case here is legitimate of course, but I don't think we should particularly advertise it to the public API.

henderkes avatar Oct 12 '25 21:10 henderkes

Interesting idea, but probably very complex to do. _GET, _POST, _COOKIE and _FILES do not have jit enabled, you'd have to do modifications here in php-src.

AlliBalliBaba avatar Oct 13 '25 19:10 AlliBalliBaba

I've never really understood why only some of the super globals are affected by that option :(

SpencerMalone avatar Oct 17 '25 05:10 SpencerMalone

I dont have much to contribute here, but this is a fascinating idea. I really hope that it could be made to work - even if it is limited.

nickchomey avatar Oct 17 '25 12:10 nickchomey