Skip to content

fix: reduce daemon and worker startup memory - #1375

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/daemon-startup-memory
Oct 16, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/daemon-startup-memory

Conversation

@willkill07

@willkill07 willkill07 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Overview

Reduce the memory used when starting nemo-relay daemon and nemo-relay daemon worker. The daemon now loads routing settings without checking local plugins. Gateways and workers still check plugin integrity, using file streams to avoid large temporary buffers.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Give the daemon a config resolver that skips plugin discovery and validation while keeping routing settings and their overrides.
  • Stream plugin environment hashes, snapshot hashes, runtime closure hashes, and snapshot copies in 64 KiB chunks.
  • Keep existing digest formats, file size limits, and file checks. Reject reads if a file grows or shrinks.
  • Add regression tests for config isolation, existing digest values, empty files, reads across chunk boundaries, and file length changes.
  • Clarify which processes need plugin files. No public API or plugin format changes.

On macOS, with the same installed Tokenomics plugin enabled, peak physical footprint fell from 112 MiB to 9.1 MiB for the daemon and from 561 MiB to 12.5 MiB for the worker. The worker completed plugin validation and reached readiness with its existing attestation.

Validation:

  • env -u NEMO_RELAY_LOG -u NEMO_RELAY_LOG_STDERR_FORMAT just test-rust: all 5,903 tests passed. The inherited logging overrides conflicted with two CLI logging tests in the initial run.
  • uv run pre-commit run: passed, including Clippy, formatting, and documentation links.
  • Release build and macOS startup memory profiling passed.
  • Reviewed changed documentation and comments for NVIDIA style and plain language.
  • Binding suites were not run because the changes are confined to the CLI.

Where should the reviewer start?

Start with resolve_daemon_config in crates/cli/src/configuration/mod.rs and its call in crates/cli/src/daemon/broker/server.rs. Then review crates/cli/src/filesystem/bounded.rs: streamed hashes use the length and bytes from the same open file, and reads fail if the length changes. The digest compatibility test is in crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Relates to: none

Summary by CodeRabbit

  • New Features
    • Daemon startup now resolves routing and upstream settings without loading plugin files, while retaining configured overrides.
  • Improvements
    • Large files are streamed during plugin environment hashing and snapshot operations, reducing full-file memory use while preserving integrity checks and snapshot contents.
  • Documentation
    • Clarified that daemon-only hosts do not need plugin files or managed Python environments.

@willkill07
willkill07 requested review from a team as code owners October 16, 2026 14:50
@github-actions github-actions Bot added size:M PR is medium Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 9bfca6bb-d728-4359-9c35-43d3574f3d3f
📥 Commits

Reviewing files that changed from the base of the PR and between 1aeb96e and db21b7a.

📒 Files selected for processing: 9
  • crates/cli/src/configuration/mod.rs
  • crates/cli/src/daemon/broker/server.rs
  • crates/cli/src/filesystem/bounded.rs
  • crates/cli/src/plugins/lifecycle/environment.rs
  • crates/cli/src/plugins/lifecycle/mod.rs
  • crates/cli/tests/coverage/shared/config_tests.rs
  • crates/cli/tests/coverage/shared/file_io_tests.rs
  • crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs
  • docs/daemon/architecture.mdx

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 14
  • GitHub Check: Check / Run
  • GitHub Check: Rust / Package (linux-musl-amd64)
  • GitHub Check: Rust / Package (linux-musl-arm64)
  • GitHub Check: Rust / Package (macos-arm64)
  • GitHub Check: Rust / Package (windows-arm64)
  • GitHub Check: Rust / Package (linux-arm64)
  • GitHub Check: Rust / Package (linux-amd64)
  • GitHub Check: Rust / Package (windows-amd64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Preview docs
🧰 Additional context used
📚 Code guidelines: 5
.agents/skills/contribute-docs/SKILL.md — unknown
.agents/skills/review-doc-style/SKILL.md — unknown
CONTRIBUTING.md — unknown
.agents/skills/prepare-code-freeze/SKILL.md — unknown
.agents/skills/draft-release-notes/SKILL.md — unknown
📓 Path-based instructions: 7
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/daemon/architecture.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/shared/file_io_tests.rs
  • crates/cli/tests/coverage/shared/config_tests.rs
  • crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/daemon/architecture.mdx
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/daemon/architecture.mdx
Applicability reference: AGENTS.md: # NeMo Relay Repository Guidance See `CONTRIBUTING.md` and `docs/contribute/testing-and-docs.mdx` for contributor details, and `.agents/skills/README.md` for the maintainer skill boundary.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/cli/src/configuration/mod.rs
  • crates/cli/src/daemon/broker/server.rs
  • crates/cli/tests/coverage/shared/file_io_tests.rs
  • crates/cli/src/plugins/lifecycle/environment.rs
  • crates/cli/tests/coverage/shared/config_tests.rs
  • crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs
  • crates/cli/src/plugins/lifecycle/mod.rs
  • crates/cli/src/filesystem/bounded.rs
Source excerpt: Search documentation source for references to the old version and update current-version install commands, package examples, and configuration examples to `` where appropriate: Review matches before changing th...

📄 CodeRabbit inference engine (.agents/skills/prepare-code-freeze/SKILL.md)

Files:

  • docs/daemon/architecture.mdx
Source excerpt: Preserve MDX front matter and the JSX SPDX comment.

📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/SKILL.md)

Files:

  • docs/daemon/architecture.mdx
🔇 Additional comments: 10
crates/cli/src/configuration/mod.rs: 1

118-139: LGTM!

crates/cli/src/daemon/broker/server.rs: 1

170-170: LGTM!

Also applies to: 186-186

crates/cli/tests/coverage/shared/config_tests.rs: 1

5279-5329: LGTM!

docs/daemon/architecture.mdx: 1

69-73: LGTM!

crates/cli/src/filesystem/bounded.rs: 1

21-25: LGTM!

Also applies to: 27-40, 66-66, 87-138

crates/cli/tests/coverage/shared/file_io_tests.rs: 1

395-436: LGTM!

crates/cli/src/plugins/lifecycle/mod.rs: 2

7-7: LGTM!

Also applies to: 31-31, 1644-1650, 1859-1878, 1899-1931

1521-1534: 🩺 Stability & Availability

The snapshot root is protected by SnapshotRootGuard before any snapshot files are copied. Any ? return from copy_snapshot_regular_file, including a stream failure, drops the guard and removes the entire root with fs::remove_dir_all. The partial file is therefore not left on disk after the function returns an error. The proposed cleanup is unnecessary.

crates/cli/src/plugins/lifecycle/environment.rs: 1

497-507: LGTM!

Also applies to: 612-624

crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs: 1

5429-5471: LGTM!

Walkthrough

The daemon now resolves routing configuration without loading plugin files. Plugin lifecycle operations stream bounded regular files for copying and digesting, with checks for length changes and tests for digest preservation.

Changes

Daemon Configuration

Layer / File(s) Summary
Resolve daemon configuration
crates/cli/src/configuration/mod.rs, crates/cli/src/daemon/broker/server.rs, crates/cli/tests/coverage/shared/config_tests.rs, docs/daemon/architecture.mdx
Daemon resolution loads configuration without plugin paths, applies server overrides, and passes the resulting GatewayConfig to DaemonState. Tests cover malformed or missing plugin configuration and required config-file behavior. Documentation describes where plugin verification occurs.

Bounded File Streaming

Layer / File(s) Summary
Open and stream bounded files
crates/cli/src/filesystem/bounded.rs, crates/cli/tests/coverage/shared/file_io_tests.rs
The bounded-file API retains an open handle and checked length, streams in 64 KiB chunks, propagates consumer errors, and detects length changes. Tests cover chunk size, output, errors, and changed lengths.
Stream lifecycle copies and digests
crates/cli/src/plugins/lifecycle/environment.rs, crates/cli/src/plugins/lifecycle/mod.rs, crates/cli/tests/coverage/shared/plugins_lifecycle_tests.rs
Snapshot copying and environment, snapshot-tree, and runtime-closure hashing stream file contents. Tests check digest values and copied bytes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to db21b

No identified issue currently blocks merging the daemon startup-memory changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description includes the required Overview, Details, reviewer guidance, checklist confirmations, and Related Issues sections. It clearly explains the memory reduction, implementation, tests, valid…
Title check Passed The title follows Conventional Commits format with the lowercase type fix, uses a concise imperative summary, stays under 72 characters, and has no trailing period. It accurately describes the pull …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required Overview, Details, reviewer guidance, checklist confirmations, and Related Issues sections. It clearly explains the memory reduction, implementation, tests, validation results, and scope.

Full details: Title check

Explanation

The title follows Conventional Commits format with the lowercase type fix, uses a concise imperative summary, stays under 72 characters, and has no trailing period. It accurately describes the pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 8 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@willkill07 willkill07 self-assigned this Oct 16, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 16, 2026
@github-actions

Copy link
Copy Markdown

Comment thread crates/cli/src/configuration/mod.rs Resolved

@bbednarski9 bbednarski9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement

@mnajafian-nv mnajafian-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@willkill07
willkill07 merged commit 2abc4f5 into NVIDIA:release/0.10 Oct 16, 2026
46 checks passed
@willkill07
willkill07 deleted the fix/daemon-startup-memory branch October 30, 2026 14:46

This branch was previously deployed

1 inactive deployment
fern — db21b7a4 Deployed Oct 16, 2026 by willkill07 via Clean up docs preview #5895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants