-
Notifications
You must be signed in to change notification settings - Fork 323
Replace builtin modules in compiled script #473
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
base: master
Are you sure you want to change the base?
Conversation
Conflicts: bytecode.go
test: concurrent test for ReplaceBuiltinModule
|
Thanks for the PR. This looks like a good idea overall. On a high level this looks good to me, but will review deeper today/tomorrow. @d5 can you take a look as well please? |
geseq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
| return nil | ||
| } | ||
|
|
||
| func (c *Compiled) prepareForModulesUpdate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just inline this into ReplaceBuiltinModule or lock the mutex here. Otherwise someone has to remember to lock correctly if they were reusing this function in the future
Compiled code can be executed concurrently out of the box thanks to
Clone()method of compiled script.The problem is that custom builtin module, given to the script as a 'dependency' may not support this. Or it may require customisation for each clone to work properly (say, you provide a driver, transaction, connection or whatever else that should be unique for each script).
Inability to update/replace builtin modules inside script after compilation makes it impossible to re-use compiled script and requires compilation for each run.
This PR solves the mentioned limitation by extending compiled script's API.
The change is implemented maintaining backward compatibility with old behaviour, where bytecode was shared across several cloned instances of script.
Bytecode gets copied only when builtin modules need to be replaced after compilation (kind of 'copy-on-write' approach)