[PR #87] [MERGED] perf(launch): cut fixed costs from the container create/start hot path #87

Closed
opened 2026-10-15 12:51:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/87
Author: @JBailes
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @JBailes

Base: fix/gc-reaps-creating-container ← Head: perf/launch-fast-paths


📝 Commits (1)

  • bfee100 perf(launch): cut fixed costs from the container create/start hot path

📊 Changes

2 files changed (+114 additions, -20 deletions)

View changed files

📝 internal/lxc/manager.go (+83 -12)
📝 internal/lxc/pve_tarball.go (+31 -8)

📄 Description

Four independent latency reductions on the PVE container create/start hot path. Each is self-contained and falls back safely.

1. allocateVMID no longer shells out to pvesh

pvesh get /cluster/nextid loads the entire PVE Perl API (~0.5–1s) on every invocation and runs once or twice per create. Replaced with usedVMIDs(), a direct glob of /etc/pve/lxc/*.conf + /etc/pve/qemu-server/*.conf. A package-level vmidMu + vmidReserved set closes the same-instant race two concurrent creates would otherwise hit (reservations self-prune once committed to disk).

2. ProxmoxCT-on-ZFS gets a CoW path

A UI-visible CT (ProxmoxCT) on ZFS previously fell through to createPVEFromTarball, re-extracting the whole rootfs tarball via pct create on every launch. ZFS backs CT linked clones, so it now routes through createPVELinkedCloneFromTarball. Ephemeral ZFS containers still take the faster raw zfs clone path (caught first in the dispatch).

3. maybeLeaseLANDHCP PID poll ramped

Changed the flat 300ms × 30 init-PID poll to a 20ms → 300ms backoff against a 9s deadline, matching startPVEContainer. A DHCP LAN container whose PID is ready fast is leased in tens of ms instead of waiting out a fixed tick.

4. Per-image template locks

Replaced the single global tmplMu with a tmplMu-guarded map[string]*sync.Mutex (one lock per image). Launches of different images now materialize their templates in parallel; same-image launches still serialize.

Notes

  • None of these change the default gow/Wolf ZFS ephemeral launch path, which was already pvesh/pct-free — #1 and #2 benefit the lvmthin and UI-visible-CT paths, #3 only DHCP LAN containers, #4 only cold first-launches.
  • go build ./..., go vet, and the full go test ./... suite pass.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/87 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/16/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `fix/gc-reaps-creating-container` ← **Head:** `perf/launch-fast-paths` --- ### 📝 Commits (1) - [`bfee100`](https://github.com/games-on-whales/LXC2Docker/commit/bfee10059895f47c3e260d84c839b9afc56d3a96) perf(launch): cut fixed costs from the container create/start hot path ### 📊 Changes **2 files changed** (+114 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `internal/lxc/manager.go` (+83 -12) 📝 `internal/lxc/pve_tarball.go` (+31 -8) </details> ### 📄 Description Four independent latency reductions on the PVE container create/start hot path. Each is self-contained and falls back safely. ## 1. `allocateVMID` no longer shells out to `pvesh` `pvesh get /cluster/nextid` loads the entire PVE Perl API (~0.5–1s) on every invocation and runs once or twice per create. Replaced with `usedVMIDs()`, a direct glob of `/etc/pve/lxc/*.conf` + `/etc/pve/qemu-server/*.conf`. A package-level `vmidMu` + `vmidReserved` set closes the same-instant race two concurrent creates would otherwise hit (reservations self-prune once committed to disk). ## 2. ProxmoxCT-on-ZFS gets a CoW path A UI-visible CT (`ProxmoxCT`) on ZFS previously fell through to `createPVEFromTarball`, re-extracting the whole rootfs tarball via `pct create` on **every** launch. ZFS backs CT linked clones, so it now routes through `createPVELinkedCloneFromTarball`. Ephemeral ZFS containers still take the faster raw `zfs clone` path (caught first in the dispatch). ## 3. `maybeLeaseLANDHCP` PID poll ramped Changed the flat `300ms × 30` init-PID poll to a `20ms → 300ms` backoff against a 9s deadline, matching `startPVEContainer`. A DHCP LAN container whose PID is ready fast is leased in tens of ms instead of waiting out a fixed tick. ## 4. Per-image template locks Replaced the single global `tmplMu` with a `tmplMu`-guarded `map[string]*sync.Mutex` (one lock per image). Launches of **different** images now materialize their templates in parallel; same-image launches still serialize. ## Notes - None of these change the default gow/Wolf ZFS *ephemeral* launch path, which was already `pvesh`/`pct`-free — #1 and #2 benefit the lvmthin and UI-visible-CT paths, #3 only DHCP LAN containers, #4 only cold first-launches. - `go build ./...`, `go vet`, and the full `go test ./...` suite pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:54 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#87
No description provided.