Open
Conversation
29f9064 to
1aaa866
Compare
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.
Description
This PR improves the Ruby runtime performance in serverless-offline by adopting a persistent process model, and adds hot-reload support for local development.
ruby invoke.rbprocess viaexeca(), executed the handler, and then the process exited.RubyRunneris constructed. The process runs in a persistent loop, reading JSON payloads fromstdinand writing results tostdout. Subsequent invocations reuse the same process by writing tostdin.require'd once at Ruby process startup, eliminating interpreter initialization and file loading overhead on every invocation.Hot reload support
rubyWatchDirsoption. When specified, the runner watches the given directories for.rbfile changes and automatically restarts the Ruby process.#busy), it is queued and executed after the current invocation completes.Motivation and Context
The Ruby runner was the only runtime that spawned a new OS process on every Lambda invocation. This caused significant latency overhead during local development, especially for runtimes with slow startup (e.g., gems with native extensions). The Python runner already used the persistent process pattern; this PR brings the Ruby runner to parity.
The hot-reload feature improves the local development experience by automatically reflecting
.rbfile changes without requiring a manual restart of serverless-offline.How Has This Been Tested?
serverless-offlineand sending repeated HTTP requests, confirming that the Ruby process is spawned only once and responses are returned correctly across multiple invocations..rbhandler file whileserverless-offlineis running withrubyWatchDirsconfigured, confirming that the Ruby process restarts and subsequent requests use the updated handler.tests/integration/docker/ruby/pass without modification.Screenshots (if appropriate):
N/A