Skip to content

Shave ~150ms off gVisor startup by making host membarrier lazy + async.#13692

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test/cl947260727
Jul 14, 2026
Merged

Shave ~150ms off gVisor startup by making host membarrier lazy + async.#13692
copybara-service[bot] merged 1 commit into
masterfrom
test/cl947260727

Conversation

@copybara-service

Copy link
Copy Markdown

Shave ~150ms off gVisor startup by making host membarrier lazy + async.

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)

@copybara-service copybara-service Bot added the exported Issue was exported automatically label Jul 13, 2026
@copybara-service copybara-service Bot force-pushed the test/cl947260727 branch 4 times, most recently from 480dd4e to 989de27 Compare July 14, 2026 02:07
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
@copybara-service copybara-service Bot merged commit 00160b9 into master Jul 14, 2026
0 of 2 checks passed
@copybara-service copybara-service Bot deleted the test/cl947260727 branch July 14, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant