Repository navigation
[Performance] Avoid a redundant existence check on every theme file read - #8944
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
readThemeFile stat'd each file before reading it, so every file that does exist paid for two filesystem round-trips instead of one. Detect the missing file from the failed read instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
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.
WHY are these changes introduced?
readThemeFilechecked that a file existed and then read it, so every file thatdoes exist — which is nearly all of them — paid for two filesystem round-trips
instead of one. It runs once per theme file when mounting the theme file system,
so the cost scales with theme size on
theme push,theme pull, andtheme devstartup.
WHAT is this pull request doing?
Read the file directly and treat an
ENOENT/ENOTDIRfailure as the "filedoesn't exist" case, which removes the extra
fileExistscall from the commonpath. The returned value, the
undefinedresult for a missing file, and thedebug log are unchanged; read errors that are not a missing file still propagate
rather than being swallowed as
undefined.Measured on a 1000-file theme, reading every file (12 iterations, 3 rounds, after
warm-up):
A consistent 12–16% reduction in the read phase; the saving grows with file count.
How to manually test your changes?
Pulling into a directory where some files are absent should still download them,
and a theme with no local copy of a file should behave exactly as before.
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add