Shave ~150ms off gVisor startup by making host membarrier lazy + async.#13692
Merged
Conversation
480dd4e to
989de27
Compare
Host membarrier support lookup and registation used to run as part of `init`
for the `hostmm` package. Due to `runsc` being a monolithic binary, this
executes unconditionally several times during the sandbox startup process.
This change skips this process for all `runsc` invocations that don't need
it by moving it to the Platform constructors, and makes initialization
itself async because the `MEMBARRIER_CMD_PRIVATE_EXPEDITED` probe can take
tens of milliseconds by itself.
Benchmarks:
```
# Plain Docker, Systrap in a VM, running just
# `docker run --runtime=runsc --rm alpine true`:
│ before │ after │
│ sec │ sec vs base │
DockerRunBinTrue 836.5m ± 4% 674.6m ± 4% -19.35% (p=0.000 n=16)
# Kubernetes with containerd, measuring time-to-first-log latency
# minus Kubernetes scheduling overhead:
│ before │ after │
│ totalruntimeinit-min-sec │ totalruntimeinit-min-sec vs base │
StartUp 1083.7m ± 2% 943.9m ± 3% -12.91% (p=0.000 n=16)
│ before │ after │
│ before │ after │
│ totalruntimeinit-p50-sec │ totalruntimeinit-p50-sec vs base │
StartUp 1083.7m ± 2% 943.9m ± 3% -12.91% (p=0.000 n=16)
│ before │ after │
│ totalruntimeinit-p95-sec │ totalruntimeinit-p95-sec vs base │
StartUp 1083.7m ± 2% 943.9m ± 3% -12.91% (p=0.000 n=16)
```
PiperOrigin-RevId: 947382582
989de27 to
00160b9
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.
Shave ~150ms off gVisor startup by making host membarrier lazy + async.
Host membarrier support lookup and registation used to run as part of
initfor the
hostmmpackage. Due torunscbeing a monolithic binary, thisexecutes unconditionally several times during the sandbox startup process.
This change skips this process for all
runscinvocations that don't needit by moving it to the Platform constructors, and makes initialization
itself async because the
MEMBARRIER_CMD_PRIVATE_EXPEDITEDprobe can taketens of milliseconds by itself.
Benchmarks: