Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisting V8 instance between requests in php-fpm #78

Closed
esv opened this issue Oct 31, 2013 · 5 comments
Closed

Persisting V8 instance between requests in php-fpm #78

esv opened this issue Oct 31, 2013 · 5 comments

Comments

@esv
Copy link

esv commented Oct 31, 2013

Hi!

Is it possible to persist V8 instance between requests in web server? I found old issue on this topic #4 and seems it was impossible back than. Do you have plans to implement it? I think it would be useful feature, like persistent connections in mysql extensions.

@cscott
Copy link
Collaborator

cscott commented Oct 31, 2013

What exactly do you want here? Do you want global variables set in
JavaScript to persist between requests? If so, that's impossible, as PHP is
just not set up that way. But if you just want to more efficiently reload
scripts, there are ways to make that persistent.
On Oct 31, 2013 9:25 AM, "esv" notifications@github.com wrote:

Hi!

Is it possible to persist V8 instance between requests in web server? I
found old issue on this topic #4https://github.com/preillyme/v8js/issues/4and seems it was impossible back than. Do you have plans to implement it? I
think it would be useful feature, like persistent connections in mysql
extensions.


Reply to this email directly or view it on GitHubhttps://github.com//issues/78
.

@esv
Copy link
Author

esv commented Nov 1, 2013

Exactly: creating V8 instance (code "new V8Js();") on my machine takes 20ms, I want it to take <1ms.

But if you just want to more efficiently reload scripts, there are ways to make that persistent.

This can be done via V8Js::registerExtension?

@saveriocastellano
Copy link

what we want is that the v8 context is persistent accross different php requests, this doesn't refer to specific global variables in javascript but to the whole javascript context.
Currently the js context is bound to the PHP instance of the the running script, when the script completes the js context is released.

For this v8js extension to be fully usable in real scenarios it is necessary to have a way of making the context persistent so that it can be re-used accross multiple requests

@cscott
Copy link
Collaborator

cscott commented Jan 31, 2014

You would need to be running Apache in "Pre-fork" or "Worker MPM" mode (or IIS in ISAPI mode) and be using the multiprocess or multithreaded SAPI for PHP. You wouldn't be guaranteed that the context would be reused, but a small number of contexts would typically be used for a largish number of requests. Again, you couldn't share global variables, because contexts aren't guaranteed to be reused. V8 supports this; we just need to hook up some bits in v8js differently.

@stesie
Copy link
Member

stesie commented Nov 16, 2014

PHP has a "shared nothing" architecture ... and I don't think V8Js should "solve" this by decoupling PHP lifetime from V8 lifetime, contextwise. This would require to invalidate PHP objects exported to Javascript as soon as the PHP request ends (since they're forcibly destroyed by PHP engine then; and we can't and shouldn't change that), ... and that'd get really messy then.

Closing this now since there's been no discussion for a long time now.

@stesie stesie closed this as completed Nov 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants