-
Notifications
You must be signed in to change notification settings - Fork 59
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
Recycle Otto VMs #77
Comments
Just some quick thoughts for now:
|
I'll see how much performance I can get without tackling this problem: I'm lazy, and you've brought up several good points.
|
Re trusted code: Yeah, that notion suggests a better switch name: |
As much as I like |
I've been simmering on this for a couple weeks and have two different options. The functionality for either would live behind a default-off toggle as discussed:
I really want the |
dop251/goja#291 has been raised to see if |
I'm wondering if your switch for |
I like it. That would lend to another name change to something like |
hmmm. I've written maybe a dozen lines of javascript before, but there is another headache that's arising: variable declaration like (function(){x=1})()
x Declaring with It falls into the same category of "when this switch is thrown, assumptions change like needing a I'm still planning on raising a PR, but enabling it is a bit scarier than I'd hoped. |
Closing due to inactivity (and I'm no longer involved in any project that uses this) |
I think I've figured out a safe-ish way to recycle an otto VM for javascript execution. By adding an
*otto.Otto
to the Context struct and using a subcontext forExecRuleAction
's goroutine and in the javascriptProcessEvent
callable we can prevent concurrent access.In theory, there's a bug where altered state can be accessed between usages. In practice I haven't observed this causing a problem but I'm hesitant to consider it bug-free.
I think it should be possible to guarantee stateless executions with a few changes:
env
and bindings mapsIf this works, it should guarantee no leakage between VM usages, as any code blocks live in their own function and state changes would live on that function's stack and be thrown away after the function is invoked. Users wouldn't have to make any changes as these changes would live entirely within
javascript.go
Let me know if you have some thoughts on this. I did look into
goja
, and foundotto
to still be faster and less memory intensive for no-op benchmarks:The text was updated successfully, but these errors were encountered: