Skip to content

Optimization: Don't stat every cached gofer file during checkpoint when restore does not validate metadata #16208

Description

@milantracy

The idea

During PrepareSave, the gofer filesystem gets fresh metadata for each cached regular file whose cached metadata is not authoritative (for example, on shared mounts). This is one stat per file, done in series while the sandbox is paused. The result is used only to validate file size and mtime during restore, and runsc never enables that validation.

Do the stat calls only when a save option says that restore will validate metadata. Keep the option off by default.

Evidence

  • pkg/sentry/fsimpl/gofer/save_restore.go:124-130, 180-187: stat calls in PrepareSave.
  • pkg/sentry/fsimpl/gofer/gofer.go:1085-1086: metadata is not authoritative on shared mounts.
  • runsc/boot/restore.go:546: restore passes &vfs.CompleteRestoreOptions{}, so both validation options are false.

Related: syncRemoteFileLocked drops fsync errors during save (gofer.go:2326-2343).

Performance impact

Not measured yet. The cost grows with the number of cached files on shared mounts.

How to verify

Checkpoint a sandbox with many open files on a shared bind mount. Compare the time from "Sandbox save started" to "Kernel save took", before and after, to significance (n=32, benchstat).

Metadata

Metadata

Assignees

Labels

area: performance

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions