perf(env): memoize + claim-scope host probe — 12s→0.4s default env create#240
Conversation
…eate
A default `h5i env create` re-ran `probe_host()` 9 times, each shelling
out to `podman info` (~1.3s) — ~12s of pure runtime probing for a tier
(supervised) that never consults the container runtime.
Two layers of fix:
1. Memoize `probe_host()` in a process-wide OnceLock (host kernel + Podman
capabilities are immutable for a process's life; never persisted so a
later process re-probes).
2. Probe Podman only when a container tier with an image is actually in
play. `resolve` reads container_runtime solely inside the Container arm
(after the image check), so:
- split into `probe_host` (full) vs `probe_host_kernel` (no Podman
shell-out) + `probe_host_for(claim)` selector;
- `effective_auto` skips the imageless Container candidate and probes
per-tier scoped;
- `supervisor::probe` uses the kernel-only probe (only ever read kernel
bits);
- the post-create discoverability tip uses a cheap `podman --version`
presence check instead of full `podman info`.
Auto-pick still lands on supervised; container resolve + env probe/doctor
still get the full Podman-aware probe. ~30x faster (12.2s→~0.4s), zero
`podman info` calls on the default path.
🪙 50% AI-authored · 4 files · prompt 60/100
💬 The ask
📍 What shipped
Note 🌿 Prompt maturity: 60/100 · proficient · 1 prompt scored (100% of AI commits) 📊 heuristic breakdown
Readability (display-only): Flesch 64 · FK grade 8.0 · Gunning Fog 10.2 Offline classical-NLP score — no LLM. Higher = more specific, bounded, and grounded prompting. Tip ✅ Security scan cleanNo credentials leaked in this branch's diff. h5i scanned every added line against the secret rule pack and found nothing to rotate. Note Duplicate-code scan clean — no copy-paste blocks introduced. 🧠 Reasoning by file — 10294 nodes across 5 lanes, latest 24 only%%{init: {"flowchart": {"nodeSpacing": 42, "rankSpacing": 48, "diagramPadding": 14}, "themeVariables": {"fontSize": "18px"}} }%%
flowchart TB
subgraph lane_0["💭 Reasoning · 9 steps"]
direction LR
n_lane_0_0["THINK · Let me restructure the probe into a kernel-only path + a claim-scoped se…"]:::t
n_lane_0_1["THINK · Let me find where `env run` resolves its policy (the frequent path) and …"]:::t
n_lane_0_2["THINK · Let me find all callers of `container::probe()` and check if the agent p…"]:::t
n_lane_0_3["THINK · Let me instrument the full `probe_host()` to dump a backtrace and find t…"]:::t
n_lane_0_4["THINK · Let me confirm that and then run clippy + the full suite, since this tou…"]:::t
n_lane_0_5["THINK · Let me smoke-test that `env probe` still reports the container runtime c…"]:::t
n_lane_0_6["THINK · Let me test whether fsync is a factor (a potentially safe win for a *dis…"]:::t
n_lane_0_7["THINK · Let me confirm the working tree is clean (committed work intact) and — i…"]:::t
n_lane_0_8["NOTE · DEFERRAL (~/Dev/h5i/src/main.rs): rift, confirmed identical on the paren…"]:::n
n_lane_0_0 --> n_lane_0_1
n_lane_0_1 --> n_lane_0_2
n_lane_0_2 --> n_lane_0_3
n_lane_0_3 --> n_lane_0_4
n_lane_0_4 --> n_lane_0_5
n_lane_0_5 --> n_lane_0_6
n_lane_0_6 --> n_lane_0_7
n_lane_0_7 --> n_lane_0_8
end
subgraph lane_1["📄 src/env.rs · 8 ops"]
direction LR
n_lane_1_0["READ × 2"]:::o
n_lane_1_1["EDIT × 6"]:::a
n_lane_1_0 --> n_lane_1_1
end
subgraph lane_2["📄 src/main.rs · 3 ops"]
direction LR
n_lane_2_0["READ"]:::o
n_lane_2_1["EDIT × 2"]:::a
n_lane_2_0 --> n_lane_2_1
end
subgraph lane_3["📄 src/container.rs · 2 ops"]
direction LR
n_lane_3_0["READ"]:::o
n_lane_3_1["EDIT"]:::a
n_lane_3_0 --> n_lane_3_1
end
subgraph lane_4["📄 src/sandbox.rs · 2 ops"]
direction LR
n_lane_4_0["EDIT × 2"]:::a
end
classDef o fill:#dbeafe,stroke:#1e3a8a,color:#0b1c4a;
classDef t fill:#fef3c7,stroke:#92400e,color:#3f2d05;
classDef a fill:#dcfce7,stroke:#166534,color:#0a2e16;
classDef n fill:#ede9fe,stroke:#5b21b6,color:#221251;
classDef m fill:#e5e7eb,stroke:#374151,color:#0b0f17;
💬 Agent coordination — 4 messages across 4 threadsFrom 🟡 ASK · human → milo · 2026-06-29 22:09 — 'h5i env create' is currently slow, and I want to improve this speed without sacrificing any security gurantee or usability 🟡 ASK · human → iris · 2026-06-29 22:09 — 'h5i env create' is currently slow, and I want to improve this speed without sacrificing any security gurantee or usability 🟡 ASK · human → milo · 2026-06-29 22:08 — is currently slow, and I want to improve this speed without sacrificing any security gurantee or usability 🟡 ASK · human → iris · 2026-06-29 22:08 — is currently slow, and I want to improve this speed without sacrificing any security gurantee or usability Note 🪙 Token reduction — 8 captured tool outputs kept out of context: 64229 → 1752 tokens (97% saved, 62477 tokens). Full output is recoverable with By tool
📜 Per-commit provenance
|
No description provided.