Conversation
…elization, stealth caching 1. Reuse VM sandbox context in pipeline template engine instead of creating a new vm.createContext() on every expression evaluation. This eliminates ~0.3ms per call in map/filter loops over large arrays. 2. Cache sanitizeContext() results via WeakMap keyed by object reference. In pipeline loops, `args` and `data` are the same object across all iterations — the expensive JSON round-trip now runs only once per step. 3. Parallelize independent startup I/O: built-in CLI discovery now runs concurrently with ensureUserCliCompatShims and ensureUserAdapters, saving ~30-50ms on cold start. 4. Cache the stealth JS string (350 lines, pure static) after first generation — every subsequent goto() reuses the cached string.
1. sanitizeContext: cache JSON string instead of parsed object to prevent sandbox mutation from polluting subsequent calls 2. VM sandbox: clean non-whitelisted properties before each execution to prevent cross-expression state leakage 3. Startup parallelization: document registry overwrite semantics and confirm no shared-state race between parallel tasks
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.
Summary
vm.createContext()sandbox across pipeline expression evaluations instead of creating a new V8 context per call. In map/filter loops over large arrays, this eliminates the most expensive operation (~0.3ms/call → amortized to ~0).JSON.parse(JSON.stringify())results via WeakMap.argsanddataare the same object reference across loop iterations — deep copy now runs once per step instead of once per item.ensureUserCliCompatShims()andensureUserAdapters()since they operate on independent paths. Saves ~30-50ms on cold start.goto()call was regenerating the same string.Test plan
npx tsc --noEmitpassesopencli listand verify startup feels snappy