Engine: Compute the project path lazily - #2310
Merged
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit b79c119
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
This pull request stops `VisitorContext` from asking the operating system where it is for every template it builds a context for. `coerce_project_path` falls back to `Pathname.new(Dir.pwd)` when no project path is given, and it ran during construction. The project path is only read when a visitor, a diagnostic, an overlay or the relative file path asks for it, so a template compiled without any of those still paid for a `getcwd` and two allocations. Deriving it on demand takes about 7% off compile time over the `examples/` corpus, measured A/B interleaved against `main`. The value is unchanged. `coerce_project_path` keeps its behavior for a caller that passes a path, and the derived one is cached through the same mutable holder #2262 introduced for the relative file path, so the context can stay frozen. Follow-up to #2262, which left this the last eagerly computed field on the context.
marcoroth
force-pushed
the
engine/lazy-project-path
branch
from
August 20, 2026 04:08
b79c119 to
1cb3115
Compare
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
@herb-tools/client
@herb-tools/core
@herb-tools/dev-tools
@herb-tools/formatter
@herb-tools/language-server
@herb-tools/linter
commit: |
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.
This pull request stops
VisitorContextfrom asking the operating system where it is for every template it builds a context for.coerce_project_pathfalls back toPathname.new(Dir.pwd)when no project path is given, and it ran during construction. The project path is only read when a visitor, a diagnostic, an overlay or the relative file path asks for it, so a template compiled without any of those still paid for agetcwdand two allocations.Deriving it on demand takes about 7% off compile time over the
examples/corpus.The value is unchanged.
coerce_project_pathkeeps its behavior for a caller that passes a path, and the derived one is cached through the same mutable holder #2262 introduced for the relative file path, so the context can stay frozen.Follow-up to #2262.