sandboxset: thread-safe sandbox pool (issue #217)#425
Draft
AmiBuch wants to merge 11 commits intoopen-lambda:mainfrom
Draft
sandboxset: thread-safe sandbox pool (issue #217)#425AmiBuch wants to merge 11 commits intoopen-lambda:mainfrom
sandboxset: thread-safe sandbox pool (issue #217)#425AmiBuch wants to merge 11 commits intoopen-lambda:mainfrom
Conversation
…ace and microservice like architecture
tylerharter
requested changes
Mar 5, 2026
tylerharter
reviewed
Mar 13, 2026
Member
tylerharter
left a comment
There was a problem hiding this comment.
I think I forgot to click submit on the feedback, sorry!
tylerharter
reviewed
Mar 13, 2026
Member
tylerharter
left a comment
There was a problem hiding this comment.
Good work! Getting closer.
tylerharter
requested changes
Mar 20, 2026
go/worker/sandboxset/sandboxset.go
Outdated
| set *sandboxSetImpl | ||
| Broken bool // public: caller sets true if request failed; Put will destroy instead of recycle | ||
| inUse bool // true when checked out; false when idle in pool | ||
| destroyed atomic.Bool // set atomically after Destroy(); guards against concurrent Close + Put |
Member
There was a problem hiding this comment.
no atomic, then mutex of the containing sandbox set should be used to protect this.
Member
There was a problem hiding this comment.
instead of destroyed, perhaps sb can just be nil?
go/worker/sandboxset/sandboxset.go
Outdated
| // sandboxSetImpl is the private concrete type returned by New. | ||
| // All mutable state is guarded by mu. | ||
| type sandboxSetImpl struct { | ||
| mu sync.Mutex |
Member
There was a problem hiding this comment.
pattern I like:
things not protected by the lock
mu synt.Mutex // protects below members
things protected by the lock
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.
sandboxset: thread-safe sandbox pool (issue #217)API
GetOrCreateUnpausedreturns a*SandboxRef— a handle that wraps thesandbox with a back-pointer to its parent set. The caller uses
ref.Sandbox()to access the container. When done, setref.Broken = trueif the sandbox is unhealthy, then always call
ref.Put()— it recyclesthe sandbox if healthy or destroys it if broken.
For explicit teardown with a reason,
ref.Destroy("reason")is also available.SandboxRef
SandboxSet interface
Config
Flow
File structure
Dependencies
sandboxset is a thin layer on top of sandbox — no new abstractions:
Testing
Unit tests (3 tests): Use
MockSandboxPoolfromsandbox/mock.go.Fast, no Docker needed.
Integration tests (4 tests): Use real
DockerPoolwithol-minimage. Gated with
//go:build integration. Verify real containers arecreated, paused, unpaused, and destroyed.
Next steps
LambdaInstancegoroutines with aSandboxSetSandboxSetas the node in the zygote tree