workflow: support to using a shared sandbox for all workflow invocations - #310
Open
msullivan wants to merge 1 commit into
Open
workflow: support to using a shared sandbox for all workflow invocations#310msullivan wants to merge 1 commit into
msullivan wants to merge 1 commit into
Conversation
Importing everything on every workflow invocation is quite slow, especially when using pydantic or similar. I am planning to add automatic support for using pydantic to serialize/validate arguments, and regenerating the pydantic validators on every invocation will make it even more expensive. Using a shared sandbox eliminates that problem. Using a shared sandbox means that we still get all of the benefits of preventing nondeterminstic calls, but that modifications to global variables will stay visible. But I think a good workflow shouldn't really be using globals *anyway*, so... I think I'm planning to basically immediately make a PR that will switch the default to `share_sandboxes=True`, but for cleanliness I'm separating it. To do this, I: * Add a Sandbox class entered with enter() * Add a policy flag for it * Make `Workflows` responsible for producing a sandbox * Hold a sandbox-scoped lock while *importing* the module, to avoid weird cyclic init races. * A bunch of tweaks to serde's registries Questions: * Are we nervous about sharing a sandbox for genuinely concurrent runs? If so, we can maintain a pool of unused sandboxes and create a new one when necessary.
Member
Each workflow run in the shared sandbox is sequential and serialized, right? Like workflow A starts an event loop, run to suspension, shutdown that loop, THEN workflow B can only start a new event loop after that, and do B things? I think I'm okay with shared sandboxes for this case. |
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
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.
Importing everything on every workflow invocation is quite slow,
especially when using pydantic or similar.
I am planning to add automatic support for using pydantic to
serialize/validate arguments, and regenerating the pydantic validators
on every invocation will make it even more expensive. Using a shared
sandbox eliminates that problem.
Using a shared sandbox means that we still get all of the benefits of
preventing nondeterminstic calls, but that modifications to global
variables will stay visible.
But I think a good workflow shouldn't really be using globals
anyway, so...
I think I'm planning to basically immediately make a PR that will
switch the default to
share_sandboxes=True, but for cleanliness I'mseparating it.
To do this, I:
Workflowsresponsible for producing a sandboxweird cyclic init races.
Questions:
runs? If so, we can maintain a pool of unused sandboxes and create
a new one when necessary.