Skip to content

Fix reserve pitfall in printString#14835

Merged
xokdvium merged 1 commit intoNixOS:masterfrom
Zaczero:zaczero/reserve-perf
Dec 19, 2025
Merged

Fix reserve pitfall in printString#14835
xokdvium merged 1 commit intoNixOS:masterfrom
Zaczero:zaczero/reserve-perf

Conversation

@Zaczero
Copy link
Member

@Zaczero Zaczero commented Dec 19, 2025

Remove the per-call reserve() inside printString to avoid linear-growth reallocations when called in loops (e.g. printStrings). Derivation::unparse already pre-reserves a large buffer, so this remains efficient while preserving amortized growth behavior when the initial estimate is exceeded.

Motivation

#14823 (comment)

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Remove the per-call reserve() inside printString to avoid linear-growth reallocations when called in loops (e.g. printStrings). Derivation::unparse already pre-reserves a large buffer, so this remains efficient while preserving amortized growth behavior when the initial estimate is exceeded.
@Zaczero Zaczero requested a review from Ericson2314 as a code owner December 19, 2025 01:05
Copy link
Contributor

@xokdvium xokdvium left a comment

Choose a reason for hiding this comment

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

Indeed. We should just rely on exponential growth for this.

@xokdvium xokdvium added this pull request to the merge queue Dec 19, 2025
Merged via the queue into NixOS:master with commit f1f99b6 Dec 19, 2025
16 checks passed
@Zaczero Zaczero deleted the zaczero/reserve-perf branch December 19, 2025 02:59
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.

2 participants