-
Notifications
You must be signed in to change notification settings - Fork 748
FIO-9783: evaluate code on demand #1968
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
Open
brendanbond
wants to merge
30
commits into
master
Choose a base branch
from
FIO-9783-ivm-alt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…gh working, takes some shortcuts with @formio/js, so do not use this commit until fixed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-9783
Description
We've identified a bottleneck in the way we perform form validation in our Enterprise Server - creating VM contexts per request and executing the entire form orchestration pipeline in those contexts turns out to be kind of slow and expensive. To mitigate this, I've made changes to the core and vm library to enable extending the Evaluator and injecting a vm directly into the evaluator, very similar to how we used to leverage VM2.
This PR introduces the
IsolateVMEvaluator
, an extension of @formio/core'sEvaluator
class that uses the newIsolateVM
from @formio/vm to sandbox and execute JavaScript on demand rather than compiling the entire process into the VM per request. My informal benchmarks show a speedup on certain types of requests of around 5x. It also moves logic that was previously in the vm library to where it belongs - where it is executed (e.g. email rendering).Breaking Changes / Backwards Compatibility
Although this introduces a lot of risk, there are no intentional breaking changes here.
Dependencies
@formio/core#245
@formio/vm#58
How has this PR been tested?
Tests (including new email rendering tests) are all passing. I've additionally that were originally in the @formio/vm library into this repository as appropriate.
Checklist: