Skip to content

refactor: share a single tokio runtime across volumes in sidecar mode #96

@XciD

Description

@XciD

Context

In sidecar mode, each volume mount calls build() which creates its own tokio::runtime::Runtime (multi-threaded). With N volumes, we get N full runtimes (~4 threads each).

Current behavior

main() spawns N threads
  thread 1: build(vol1) -> new Runtime -> mount_fuse
  thread 2: build(vol2) -> new Runtime -> mount_fuse

Proposed

Split build() to accept an existing runtime handle:

// main creates one runtime
let runtime = tokio::runtime::Builder::new_multi_thread().build()?;

// Each volume reuses it
let setup1 = build_with_runtime(source1, opts1, runtime.handle());
let setup2 = build_with_runtime(source2, opts2, runtime.handle());

This requires MountSetup to hold a Handle instead of owning the Runtime, and the caller to keep the Runtime alive.

Impact

Low priority. With 1-2 volumes per pod (typical), the overhead is ~4 extra threads. Worth doing as part of a broader build() / MountSetup refactor.

Related: #86 (sidecar PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions