DiskFileSystem: store Effect full_path as Arc<Path>#94332
Open
sokra wants to merge 1 commit into
Open
Conversation
Switches the `full_path` field in `WriteEffect` and `WriteLinkEffect` from `Arc<PathBuf>` to `Arc<Path>`, avoiding the extra indirection and allocation of a `PathBuf` inside the `Arc`. Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Tobias Koppers <sokra@users.noreply.github.com>
Contributor
Failing test suitesCommit: 06948a9 | About building and testing Next.js
Expand output● app dir - navigation › hash › should scroll to the specified hash Other failing CI jobs |
Contributor
Stats skippedCommit: 06948a9 |
mischnic
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
In the
DiskFileSystemwriteandwrite_linkimplementations (turbopack/crates/turbo-tasks-fs/src/lib.rs), change thefull_pathfield on theWriteEffectandWriteLinkEffectstructs fromArc<PathBuf>toArc<Path>.Why?
Arc<PathBuf>stores two heap allocations and an extra indirection: theArcallocation holds aPathBuf(Vec<u8>-like), which in turn points to the actual path bytes.Arc<Path>is a thin/wide-pointer to a single allocation containing the path bytes inline next to theArcheader, which is both smaller (no separatePathBufcapacity field) and removes one level of pointer chasing on every access.These effects are cloned per write side-effect and live until the effect is applied, so the saved allocation/indirection is a small but free win.
How?
full_pathfield type onWriteEffectandWriteLinkEffectfromArc<PathBuf>toArc<Path>.Arc::new(full_path)toArc::from(full_path), which uses the standard library'sFrom<PathBuf> for Arc<Path>impl to move the path bytes directly into a singleArc<Path>allocation.No call sites needed updating: all existing uses (
validate_path_length(&self.full_path),self.inner.invalidate_from_write(&self.full_path),self.full_path.as_os_str()) already only need&Path, which is reached viaDereffrom bothArc<PathBuf>andArc<Path>.Verified locally with
cargo check -p turbo-tasks-fsandcargo clippy -p turbo-tasks-fs --all-targets.