Skip to content

Write derivation JSON directly into the output buffer - #626

Draft
ConnorBaker wants to merge 1 commit into
numtide:mainfrom
ConnorBaker:refactor/drvshow-json-writer
Draft

ConnorBaker wants to merge 1 commit into
numtide:mainfrom
ConnorBaker:refactor/drvshow-json-writer

Conversation

@ConnorBaker

Copy link
Copy Markdown
Collaborator

The classic nix derivation show renderer already has a destination byte vector. Serialize object keys and scalar or empty values directly into it with serde_json::to_writer. This removes a temporary vector and a copy each time the renderer emits one of those values. The existing float and indentation code still controls their spelling and layout. This PR targets main directly and has no PR prerequisites.

Validation

The ordinary Nix package built on AArch64. The project's Nix formatting and AST checks passed, as did all six selected derivation-display unit tests. The release CLI matched C++ Nix 2.36.0pre20261121 byte for byte across eight combinations covering single and recursive output, compact and pretty formatting, escaped keys and values, structured attributes, and a pinned Nixpkgs hello.src. Classic fallback was disabled.

Native AArch64 measurements

Fresh CLI processes pinned to the same CPU ran each workload in all six orders of stock, candidate, and an identical stock repeat. These are geometric means of paired changes in retired user instructions for the entire command. Each measurement checked stdout against the complete C++ Nix document.

Workload Derivations shown Output bytes Instruction change
Nixpkgs hello.src, recursive compact 618 1,461,108 −2.562%
Nixpkgs hello.src, recursive pretty 618 1,965,410 −2.562%
Nixpkgs hello.src, single compact 1 3,413 −0.505%
Structured test graph, recursive compact 33 28,450 −3.749%

The one-minute host load ranged from 5.47 to 6.81. The 72 measured processes had zero major faults. Same-binary instruction differences stayed within 0.005%. A separate Callgrind run on the structured graph recorded 14,174 calls to mi_malloc_aligned on stock and 11,281 after the change. The scope of these results is derivation display.

AI assistance

OpenAI Codex assisted with implementation, review, validation, and preparation of this pull request.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5dc4d0b9-3f2d-4dfe-900d-04522087b921
Commits

Reviewing files that changed from the base of the PR and between aad8323 and c1b52af.

Files selected for processing: 1

  • src/api/drvshow.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ConnorBaker

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

ConnorBaker added a commit to ConnorBaker/iets that referenced this pull request Nov 22, 2026
ConnorBaker added a commit to ConnorBaker/iets that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant