Skip to content

perf(sdk): hash an unchanged bundle once per deployment - #12894

Merged
cv merged 1 commit into
v1from
perf/sdk-bundle-verification
Oct 9, 2026
Merged

cv merged 1 commit into
v1from
perf/sdk-bundle-verification

Conversation

@cv

@cv cv commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Part of #12882.

Failure

Every Deployment operation hashed every bundle file before running, about 350 MB on linux_arm64. In e2e deployment, profiling found 171 verifications taking 32 s, about 6.5% of the module's time. Each one re-hashed a bundle whose files had not changed. Long-lived SDK callers pay the same cost on every plan, apply, export, or destroy.

Decision

  • Cache: a Deployment, and its clones, remembers the verified bundle together with the metadata of manifest.json and every file the manifest lists: length, modification time, and on Unix the device, inode, and inode change time. A writer can set the modification time back, but not the inode change time.
  • When it hashes again: the next operation hashes again only when that metadata differs, so a written, replaced, or removed file still fails verification. Metadata is read before hashing, so a write during verification is caught next time. A failed verification is not remembered.
  • Unchanged: the bundle.verify timing event is still reported for every operation. The CLI runs one operation per process and is unaffected.
  • Docs: docs/build.md states when a deployment verifies its bundle.

Validation

  • New unit test: an unchanged bundle is hashed once across operations. Rewriting a file with the same length fails verification, and the failure is not remembered. Replacing a file with an identical copy verifies again, and another directory is verified on its own. The test failed to compile before VerifiedBundle existed.
  • End to end: deployment::web_search_cli_export_reapply_and_destroy takes 100 s locally instead of 109 s. It runs 48 SDK operations across 6 lifecycles, each lifecycle creating its own deployment.
  • Checks: nemoclaw-sdk tests pass (573), and workspace clippy at -D warnings and fmt are clean.

Every Deployment operation hashed every bundle file, about 350 MB, before
running. In the deployment end-to-end tests that was 171 verifications
taking 32 s, about 6.5% of the module's time, and a long-lived caller
paid it on every plan, apply, export, or destroy.

A Deployment, and its clones, now remembers the verified bundle with the
metadata of the manifest and every file it lists: length, modification
time, and on Unix the device, inode, and inode change time, which a
writer cannot set back. The next operation hashes again only when that
metadata changes, and a failed verification is not remembered. The CLI
runs one operation per process and is unchanged.

Part of #12882.
@cv cv added area: e2e End-to-end tests, nightly failures, or validation infrastructure v1 NemoClaw v1 branch labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 748b17c into v1 Oct 9, 2026
27 checks passed
@cv
cv deleted the perf/sdk-bundle-verification branch October 9, 2026 09:48
cv added a commit that referenced this pull request Oct 9, 2026
Part of #12876.

## Failure

Tests overlapped across layers, and nothing measured or limited how long they ran. On `v1` before this PR:

- On `linux_amd64` the `test` step took 78 s wall for 620 s of tests.
- The lifecycle step took 744 s wall for 2,948 s of tests.
- Three end-to-end modules accounted for 82% of the lifecycle time.
- Many end-to-end tests repeated full deployments to cover variants that the SDK already proves equivalent.

## Decision

Make test time visible first. Then move each group of tests to the layer that owns its behavior, keeping one end-to-end check per behavior.

- **Timing report (#12877):** after the test, lifecycle, and live steps, `cargo ci` prints where the time went: wall and summed time, time per binary and module, and the slowest tests. It also writes the report to the GitHub job summary. Each lifecycle partition reports its own tests. The report reads nextest's JUnit output with `quick-junit`, and the `test` step's JUnit report is now uploaded.
- **`deployment`:**
  - Each configuration variant deploys once: `web_search`, `execution_settings`, `tool_disclosure`, and `provider_definitions` ran 15 lifecycles and now run 6.
  - `cli_redaction` checks each redaction rule once through the CLI.
  - The SDK tests that own each dropped variant are named in the commits.
- **`remote_service`:**
  - The Hermes lifecycle without authentication repeated the OpenClaw one, so it is removed.
  - Pi stops after admission and refused sandbox changes.
  - Refused changes export once instead of eight times.
- **`opentofu_openshell`:** the reference graph surfaces each gateway capability failure kind once through OpenTofu, in 14 runs instead of 23. `nemoclaw-openshell` observation tests own the reasons.
- **`fabric_deployment`:** every harness applies, reapplies, exports, and destroys. Only OpenClaw and Pi also run the harness-independent model change and refusals.
- **`inference_discovery`:** each catalog response is planned once. `nemoclaw-discovery` owns the classification.
- **Optimized dependencies:** dependencies build at `opt-level` 2 in development and test builds, and workspace crates stay unoptimized. Unoptimized JSON Schema validation dominated the onboarding journeys.
- **Onboarding wizard (#12901, merged into this branch):** the wizard resolves an unchanged journey once.

## Validation

Measured in CI run [37916518035](https://github.com/NVIDIA/NemoClaw/actions/runs/37916518035), with cold dependency caches:

| linux_amd64 | Before | After |
|---|---|---|
| `test` step | 78 s wall, 620 s summed | 24 s wall, 189 s summed |
| Lifecycle, summed | 2,948 s | 1,898 s |
| Lifecycle shards, wall | 744 s unsharded | 309 s and 262 s |
| `deployment` | 1,331 s | 922 s |
| `remote_service` | 697 s | 433 s |
| `fabric_deployment` | 379 s | 164 s |
| `opentofu_openshell` | 230 s | 155 s |

`linux_arm64` follows the same pattern: the `test` step went from 44 s to 19 s wall, and lifecycle from 2,642 s to 1,845 s summed.

- **Cost:** optimizing dependencies lengthens a cold build. "Build test executables" took 315 s instead of 118–155 s on the previous cold run. Only `v1` pushes save the dependency cache, and `.cargo/config.toml` is part of its key, so pull request runs build cold until this merges.
- **Local checks for each commit:** each changed test passes against a rebuilt bundle. Workspace clippy at `-D warnings` and fmt are clean. A new `nemoclaw-build` test covers the timing report.

## Follow-ups

- #12894 hashes an unchanged bundle once per deployment.
- `deployment` is still 922 s summed across about 31 distinct failure and recovery scenarios. The remaining cost is each OpenTofu operation, which a follow-up will address.
- Enforcing the per-layer budgets remains in #12877.
@wscurran wscurran added area: performance Latency, throughput, resource use, benchmarks, or scaling refactor PR restructures code without intended behavior change security area: security Security controls, permissions, secrets, or hardening and removed security labels Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure area: performance Latency, throughput, resource use, benchmarks, or scaling area: security Security controls, permissions, secrets, or hardening refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants