-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(runtime): cache cwd lookups #12056
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not seem sound as cwd can be changed from any thread in a worker.
Yep I should have explicited the assumption here, I'll change it to use a |
Accidentally committed, denoland#12056 adds `read_128k_sync`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about this change - it might introduce some odd bugs if somehow the cwd changes outside of op_chdir.
I don't understand why caching cwd would effect readFile perf at all. readFile should not use cwd even once let alone multiple times.
See:
since file IO permission checks need to resolve the full file path, these cwd related calls accounted for ~20% of the time spent in the |
In addition, I think it's a fair assumption that the CLI should never change the CWD and thus it will only be changed by user code executed in the runtime, a |
ba879dc
to
29ffc1f
Compare
I'm also not in favor of this change. I think we should close this PR. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This caches CWD lookups,
Deno.cwd()
is ~5x faster and shaves off ~20% ofread_128k_sync
.This is a first PR of a series to optimize sync file reads, optimizing
cwd
not only helpsDeno.cwd()
but it also optimizes all file IO permission checksBench results