Skip to content

Move pinring to its own sidecar binary rather than the gofer. - #14546

Closed
EtiennePerot wants to merge 1 commit into
gvisor:masterfrom
EtiennePerot:pinring-sidecar
Closed

EtiennePerot wants to merge 1 commit into
gvisor:masterfrom
EtiennePerot:pinring-sidecar

Conversation

@EtiennePerot

Copy link
Copy Markdown
Member

Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (runsc-fd-parking, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

@ayushr2 ayushr2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Honestly, I didn't review fdparking.c too well since I can't verify that level of assembly code on the top of my head. But I trust you've done a good job at it and it's agent reviewed.

But it seems a bit overly complex. We're writing assembly code for invoking syscalls and there's micro optimizations like the entire park_stack thing. Quite complex. The entire slim() hackery is quite something deep as well. I assume it's needed for the process memory footprint to be lower? But I wonder how much we save here. Is all this needed to not regress our benchmarks? If not, then we'd benefit with lesser/simpler code than these optimizations. Will leave it up to you.

@EtiennePerot

Copy link
Copy Markdown
Member Author

But it seems a bit overly complex. We're writing assembly code for invoking syscalls and there's micro optimizations like the entire park_stack thing. Quite complex. The entire slim() hackery is quite something deep as well. I assume it's needed for the process memory footprint to be lower? But I wonder how much we save here. Is all this needed to not regress our benchmarks? If not, then we'd benefit with lesser/simpler code than these optimizations. Will leave it up to you.

I take comfort in the facts that:

  • It's a very small binary that does a very specific task, almost no branching paths
  • The only syscalls it ever has instructions to do are close_range, munmap, ppoll, scheduler settings, and writing to stderr (I was actually considering adding a seccomp filter on it after it finishes init, though that increases its kernel memory footprint of course)
  • The assembly patterns used here are already used in other sidecar binaries, they're just "call a syscall" and "jump to a function"

Other runtimes benchmark themselves in single-digit megabytes of memory overhead, which is a resolution where every 4KiB page matters :)

@EtiennePerot EtiennePerot added the ready to pull Causes the PR to be imported into Google. Will be removed soon. label Sep 1, 2026
@EtiennePerot EtiennePerot removed the ready to pull Causes the PR to be imported into Google. Will be removed soon. label Sep 12, 2026
Previously, the ring was held by the gofer, which works well for the
case where the gofer is 1-to-1 with the Sentry. This isn't true for
multi-container sandboxes (where the current approach means we wait
500ms for each container doing nothing on exit), and it's also not
going to work well with the no-root-container mode introduced by
PR gvisor#13981.

This instead moves the job of holding the ring to a separate tiny C
sidecar binary (`runsc-fd-parking`, named such to make its purpose
obvious in the process table). Because this sidecar binary's job is
very unimportant during startup, it defers as much of its work as
possible, and because it must run for the whole lifetime of the
sandbox, it minimizes its own memory footprint as aggressively as
possible.

Benchmarks show no measurable startup or teardown latency regression,
and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).
@EtiennePerot EtiennePerot added the ready to pull Causes the PR to be imported into Google. Will be removed soon. label Sep 12, 2026
copybara-service Bot pushed a commit that referenced this pull request Sep 12, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 12, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 12, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 12, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 13, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 13, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 13, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 13, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 976115235
copybara-service Bot pushed a commit that referenced this pull request Sep 13, 2026
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981.

This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible.

Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).

COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d
PiperOrigin-RevId: 980553731
@EtiennePerot

Copy link
Copy Markdown
Member Author

This was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull Causes the PR to be imported into Google. Will be removed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants