Skip to content

perf(core): reduce memory filesystem buffer allocations - #8507

Merged
chenjiahan merged 2 commits into
mainfrom
chenjiahan/perf-memfs-buffer-allocation
Sep 17, 2026
Merged

chenjiahan merged 2 commits into
mainfrom
chenjiahan/perf-memfs-buffer-allocation

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Motivation

memfs reserves extra Buffer capacity to support future appends. Rsbuild usually writes complete assets, and rebuilds truncate files before rewriting them, so that extra capacity goes unused.

Changes

Allocate a buffer matching the file size when writing a complete asset to an empty or truncated file. The input is still copied, and plugins retain the full memfs API through compiler.outputFileSystem. Other writes keep memfs's existing behavior.

Pin memfs and its storage extension to matching versions.

Memory results

Measured in a real-world dev project. Buffer capacity measures file-buffer allocations; process memory uses macOS Physical Footprint.

Metric Before After Change Paired result
Buffer capacity after rebuilds 2,479.44 MiB 1,728.86 MiB −30.27% 750.6 MiB lower
Process memory after startup 16.477 GiB 16.086 GiB −2.37% 93–639 MiB lower
Process memory after rebuilds 17.807 GiB 17.413 GiB −2.21% 94–571 MiB lower
Peak process memory 21.495 GiB 21.057 GiB −2.04% 350–662 MiB lower

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T10:09:35.488668Z c8b1369 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chenjiahan
chenjiahan merged commit 392acde into main Sep 17, 2026
7 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/perf-memfs-buffer-allocation branch September 17, 2026 11:06
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