Skip to content

P4: worker-process parallelism — does N microvm-worker processes give N× throughput? #259

Closed

Description

@pdettori

Summary

E11's density sweep (c = 1…64, knee at c=8, bound: replenishment) ran its entire ladder against exactly one microvm-worker process — confirmed directly from deploy/microvm/e11-density.sh (start_microvm_stack starts one worker per (D, GuestRAMBytes) slice and the whole ACTIVE_RUNS sweep runs against it before teardown). This issue asks whether running multiple independent worker processes on the same host multiplies the ~39-43 execs/sec ceiling, or whether some shared host-level resource (snapshot I/O, the pinned memfile, virtiofsd, cgroup hierarchy) caps the host, not the process.

Why this matters

  • This is the item most directly tied to the "multiple users, multiple sessions... optimized for throughput" goal at a service level. One worker's ceiling only matters for capacity planning if it's also the service's ceiling.
  • Host resource headroom is enormous at the tested range (hostCpuFraction ~0.001 flat, Σ PSS ≤ 0.41 GB at 128 resident microVMs — see remote-worker/internal/vmpool/pin_linux.go's CoW-sharing comment), so there's no obvious resource reason a second worker couldn't run alongside the first. Whether it actually scales throughput is untested.
  • The P6 density work already hit an analogous trap in a different tier: doubling worker count there moved the ceiling by -6%, because the host was already saturated and the bottleneck wasn't per-worker. Worth checking whether the same trap applies here before assuming linear scaling.

What's already known / where to look

  • Driver: deploy/microvm/e11-density.sh, specifically start_microvm_stack/stop_microvm_stack (one process per config slice, each with its own SANDBOX_ID, binding its own relay port) and the outer loop in main() that currently never starts two microVM stacks concurrently.
  • Config: each worker process holds one vmpool.Config (remote-worker/internal/vmpool/config.go) — one SnapshotDir, one StandbyDepth, one GuestRAMBytes, fixed at process start. Two workers pointed at the same SnapshotDir would each independently PinMemoryFile it — worth checking whether that's safe/redundant (two MAP_SHARED+mlock mappings of the same file should just double-count the lock accounting, not the physical pages, but this hasn't been verified under concurrent worker processes).
  • Host-level shared resources to watch for contention: the golden snapshot's memfile (page-cache reads), /srv/jail and /srv/workspaces (per-VM directories — see the "chroot base / run dir must share a device with the snapshot" fix round in deploy/microvm/EXPERIMENTS.md), the jailer/cgroup hierarchy (microvm.slice), and vsock connection setup if it goes through any shared kernel structure.

Open questions for the spec

  1. Should the two (or N) workers share one SnapshotDir, or does each need its own copy to rule out I/O contention as a confound? (Sharing is more realistic for a production deployment; separate copies isolate the variable better.)
  2. What's the right topology to test first — 2 workers at moderate concurrency each, or N workers each pinned to c=8 (the known-healthy single-worker operating point)?
  3. Does this need its own relay/Redis instance per worker, or can they share the existing single relay from e11-density.sh?

Suggested scope for a first cut

Start two microvm-worker processes (same snapshot, same D/RAM config) on the same metal host, repeat the c-sweep against each independently and simultaneously, and compare combined throughput/latency against 2x the single-worker c=8 numbers (39.04/s → expect ~78/s if it scales cleanly).


Part of rossoctl/moca-experiments#3 (P4 epic: next experiments after the metal STOP).

Activity

  1. pdettori commented on Sep 17, 2026

    @pdettori
    MemberAuthor

    Epic: rossoctl/rossoctl#2546 (Stream 2 — microVM sandbox tier, via sub-epic rossoctl/serverless-harness#256)

    Status update (2026-09-17)

    Still open, no PR yet. Motivated by E11's finding that the c=8 knee is
    replenishment-bound with CPU/memory nowhere near saturated (hostCpuFraction flat at
    0.001 through c=64) — this issue asks whether more microvm-worker processes turn that
    slack into throughput. No change since filing.

    Assisted-By: Claude (Anthropic AI) [email protected]

  2. pdettori commented on Sep 21, 2026

    @pdettori
    MemberAuthor

    Plan written, and the baselines in this issue need correcting before it runs

    Runbook: docs/notes/e259-worker-parallelism-runbook.md (PR #301), in the same shape as the #294
    comparison runbook.

    Three things changed since this issue was drafted, from the #291 re-run on srv-r16b14s16:

    1. The baselines are stale. This issue says "39.04/s → expect ~78/s if it scales cleanly".
    Those are pre-#291 numbers. With the repaired driver and the Go Exec client:

    c one worker, Exec/s two workers, if linear
    8 80.62 ~161
    16 62.99 ~126
    64 62.28 ~125

    So the two-worker target at the healthy operating point is ~161/s, not ~78/s. c=8 is the
    comparison that matters; at c≥16 coldAcquireRate is already 1.00 and a second worker there
    measures recovery from saturation rather than clean scaling.

    2. Two of this issue's premises are now measured, and one is wrong. The headroom argument
    holds and is stronger than stated — but not at the numbers quoted here:

    3. SH_MAX_COMMITTED_MB is per worker process. Each worker holds its own vmpool.Config and
    its own admission budget, so two workers at 409600 can commit 800 GiB against 754 GiB of RAM. A
    budget above installed memory means the gate cannot refuse before the OOM killer arrives, and every
    density number becomes a measurement of the OOM killer. The runbook flags this as a sizing step, not
    a detail.

    Prerequisite: PR #299

    Without it the microVM ladder will abort partway. pss_bytes_for_pids refused on a dying VMM — a
    pid kill -0 reports alive whose address space is already gone — and in host_signals_snapshot's
    idle-standby-residency poll that refusal is fatal. It fires 4–5 times per microVM rung and
    killed the first three-arm run at c=4; two of four short runs died on it.

    A per-session ceiling this issue does not mention

    runPool.execGate is a one-slot channel per run pool, held from a successful acquire until that
    VM is destroyed, whenever the launcher reports SerializesExecsPerRun() — true for Firecracker,
    deliberately, because the workspace ext4 image is not a shared-disk filesystem and two guests
    mounting it rw would corrupt it (spec §4.3).

    So one session executes one Exec at a time, and cannot exceed ~1/47.75 ms ≈ 21 Exec/s. The
    measured 17.56 at c=1 is that ceiling, not a mystery. It does not serialize across users
    (different workspace_keys → different run pools → different gates), so it is not the multi-user
    bottleneck this issue is about — but it is a hard capacity-planning fact worth having in the epic:
    no per-user SLO above ~20 Exec/s is reachable without a shared-disk workspace filesystem.

    Why this is the right next experiment, and what it decides

    Restores are not serialized by the pool mutex — replenishOne calls p.mu.Unlock() before
    p.warm(...) — so they already can overlap across run pools within one worker. Yet 62 Exec/s
    against E10's 23.06 ms restore implies only about 1.4-way effective restore concurrency.
    Something in the restore path serializes and it is not pool.mu.

    This experiment is the cheapest test of whether that serializer is per-process or host-wide, and the
    answer decides what work is worth doing at all:

    observation reading
    T2 >= 1.8 × T1 per-process. Scale out; find practical N by extending the experiment
    1.2 × T1 < T2 < 1.8 × T1 partial. Report the fraction; do not round it into either story
    T2 <= 1.2 × T1 host-wide. Stop scaling out; run the isolated-snapshot variant, then the code

    #260 is now closed on its stated scope: the D sweep was run (D=2/4/8) and the knee does not
    move, because the bound is the serialized 200 ms replenishment rate, not pool capacity. Its
    remaining diagnostic half — per-pool vs pool-wide replenishment concurrency — belongs with this
    issue's outcome, and if #259 comes back "host-wide" it becomes the main event.

  3. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Answered — but the answer is the opposite of the recommendation, and #301 now carries the correction

    Answer: N = 1. Do not scale out.

    The measurements in this issue's results doc reproduce and stand. What they measured is not what they
    were read as. The per-process component was a hard-coded constant — session.DefaultConcurrency = 4,
    a fixed pool of 4 goroutines draining the Exec queue per worker, which e11-density.sh never
    overrode (#305). So the two arms here compared 8 slots against 4, and the 1.82x is what that
    ratio yields once per-worker throughput drops the measured 8.8%. Scale-out "worked" by multiplying
    the constant.

    configuration Exec/s vs 1 worker at the default
    1 worker, MaxConcurrent=4 (default) 62.99 1.00x
    2 workers, 4 each — this issue 123.57 1.96x
    1 worker, MaxConcurrent=16 172.88 2.74x
    1 worker, 64 slots 577.55 9.2x

    Raising one environment variable on a single worker beat this entire two-worker result by 1.40x,
    at +3.6% p95, with none of the separations two workers need.

    And with the cap lifted, scale-out is worth nothing. Holding total slots constant and varying only
    process count (same host, 2026-09-22):

    arm total slots aggregate Exec/s host CPU
    1 × 64 64 580.60 65.3%
    2 × 32 64 580.58 68.2%
    1 × 64 (drift repeat) 64 563.66 67.2%

    0.02 Exec/s apart, against 2.9% measured session drift, for +2.9 points of host CPU. Host CPU never
    leaves 65–73% across one or two processes and 64/128/256 slots, so the idle third of the host is not
    reachable by adding workers — what serialises is host-wide, in the restore path.

    What this issue contributed, and is credited with

    This issue's own instruction was "N should be found by extending this experiment, not by assuming
    linearity continues."
    That was right, it was followed, and it is what produced the answer.

    Also kept and used downstream: the overlap proof and the "coresBusy must NOT be summed"
    corollary.
    That is what made the later two-worker comparison auditable at all — per-worker figures
    matching (49.1/49.1) are the evidence the processes genuinely overlapped, and summing would have
    destroyed it. Likewise the foreign-load sampling discipline and the instrument defects.

    Revised guidance: one worker per host with WORKER_MAX_CONCURRENT raised. Add hosts to add
    capacity; raise the per-host number by needing fewer restores per Exec (#274).

    PR #301 now opens the results doc with this correction. Ready to close once it merges.

  4. pdettori commented on Sep 23, 2026

    @pdettori
    MemberAuthor

    Closing — answered, with the correction now on main.

    Answer: N = 1. The per-process component this issue found was session.DefaultConcurrency = 4 (#305, closed), so the two arms compared 8 slots against 4 and the 1.82x is what that ratio yields once per-worker throughput drops the measured 8.8%. Raising that one value on a single worker gave 172.88 Exec/s, beating this entire two-worker result (123.57) by 1.40x. With the cap raised, a second worker is worth 1.00x: holding total slots at 64 and varying only process count, 2x32 = 580.58 against 1x64 = 580.60 — 0.02 Exec/s apart against 2.9% measured session drift, for +2.9 points of host CPU.

    docs/notes/e259-worker-parallelism-results.md (PR #301, merged) now opens with that correction. The measurements in it stand and reproduce; only the recommendation changed.

    This issue got the method right, and that is why the answer exists. Its own instruction — "N should be found by extending this experiment, not by assuming linearity continues" — was followed, and extending it in both directions is what produced N = 1. Two things from it are still load-bearing downstream:

    • The overlap proof and the "coresBusy must NOT be summed" corollary. That is what made the later two-worker comparison auditable at all: per-worker figures matching (49.1/49.1, 52.5/52.2) are the evidence the processes genuinely overlapped, and summing a host-wide counter would have destroyed exactly that evidence.
    • The foreign-load sampling discipline, and the instrument defects it found.

    Revised guidance: one worker per host with WORKER_MAX_CONCURRENT raised — fewer ports, relays, Redises, admission budgets and supervision paths, and none of the seven separations two workers need. Add hosts to add capacity. Raise the per-host number by needing fewer restores per Exec (#274), since what serialises is host-wide: CPU never leaves 65-73% across one or two processes and 64/128/256 slots.

    Campaign record: docs/notes/2026-09-22-exec-throughput-campaign-results.md.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions