Skip to content

perf(binding): cache chunk and chunk group collection reads - #23

Open
guru-irl wants to merge 2 commits into
mainfrom
perf-chunk-collection-cache
Open

guru-irl wants to merge 2 commits into
mainfrom
perf-chunk-collection-cache

Conversation

@guru-irl

@guru-irl guru-irl commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Motivation

Changes

  • While an asset-processing callback runs, repeated reads of chunk.files, chunk.groupsIterable and chunkGroup.chunks reuse one snapshot instead of asking Rust again.
  • Each read still returns a new Set or array, so callers can't affect each other. Snapshots are checked on every read, so files added or removed during the callback are always visible, and they are dropped when the callback returns.
  • Reads after an await, outside asset-processing callbacks, from another compilation, and of other collections work as before.

Tests: new configCases/compilation/chunk-collection-snapshots fails on main; existing chunk, chunk group and process-assets cases cover the rest.

Performance

Public synthetic fixtures using the TanStack/router#8588 read pattern, one compiler, seven paired fresh-process runs per row on Linux x64 (WSL2, 16 vCPUs). Memory is the paired median change.

Chunks Tap time Peak V8 heap V8 heap after GC Process memory at end
760 20.7 → 18.5 ms +80 KiB +20 KiB +0.4 MiB
3,245 134.0 → 115.9 ms +957 KiB +27 KiB -0.5 MiB

The peak increase lasts only while a callback runs and V8 heap after GC stays within the 64 KiB run-to-run floor; a build that never reads these collections showed no measurable change (4,657 vs 4,595 ms at 3,245 chunks, within run-to-run noise), and Windows was not measured.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

📦 Binary Size-limit

Comparing 35aeb9b to fix(watcher): report recreated files by their final state (#16040) by Guru 🦄

❌ Size increased by 16.00KB from 67.26MB to 67.27MB (⬆️0.02%)

@github-actions

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 529.6 KB 0 0
react-10k 5.4 MB 1.3 MB 0 0
react-1k 827.7 KB 226.6 KB 0 0
react-5k 2.6 MB 670.9 KB 0 0
ui-components 4.7 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

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