-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Cache non-symlinks in realpathSync #10253
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
Conversation
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. Signed-off-by: Jeremy Yallop <yallop@docker.com>
|
What about |
We removed the cache argument in v6. The cache in |
addaleax
left a comment
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.
LGTM with green CI
CI: https://ci.nodejs.org/job/node-test-commit/6630/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/479/
|
Thanks for the reviews. I'm not sure why the test/arm CI failed, but let me know if there's anything more I need to do here. |
|
CI 2: https://ci.nodejs.org/job/node-test-commit/6831/ (ARM failures were probably machine issues) |
|
OS X failure looks like an unrelated race condition in |
|
Hmmm, now an AIX failure, also seemingly unrelated. Peculiar. Let's try again: |
|
There we go. CI is ✅ |
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Landed in 5dc4487 |
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
|
I've gone ahead and backported to v6.x, but am a little bit wary. Is this a good change to backport? It did not land cleanly on v4.x, which makes sense to me. As such I added the appropriate don't land label |
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Extend `fs.realpathSync` to cache the results for paths that are not symlinks in addition to caching symlink mappings. PR-URL: #10253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Notable Changes: The SEMVER-MINOR changes include: * crypto: allow adding extra certs to well-known CAs (Sam Roberts) #9139 * deps: Upgrade INTL ICU to version 58 (Steven R. Loomis) #9234 * process: add `process.memoryUsage.external` (Fedor Indutny) #9587 * src: add wrapper for process.emitWarning() (Sam Roberts) #9139 Notable SEMVER-PATCH changes include: * fs: cache non-symlinks in realpathSync. (Jeremy Yallop) #10253 * repl: allow autocompletion for scoped packages (Evan Lucas) #10296
Notable Changes: The SEMVER-MINOR changes include: * crypto: allow adding extra certs to well-known CAs (Sam Roberts) #9139 * deps: Upgrade INTL ICU to version 58 (Steven R. Loomis) #9234 * process: add `process.memoryUsage.external` (Fedor Indutny) #9587 * src: add wrapper for process.emitWarning() (Sam Roberts) #9139 Notable SEMVER-PATCH changes include: * fs: cache non-symlinks in realpathSync. (Jeremy Yallop) #10253 * repl: allow autocompletion for scoped packages (Evan Lucas) #10296 PR-URL: #10974
Notable Changes:
The SEMVER-MINOR changes include:
* crypto: allow adding extra certs to well-known CAs (Sam Roberts)
nodejs/node#9139
* deps: Upgrade INTL ICU to version 58 (Steven R. Loomis)
nodejs/node#9234
* process: add `process.memoryUsage.external` (Fedor Indutny)
nodejs/node#9587
* src: add wrapper for process.emitWarning() (Sam Roberts)
nodejs/node#9139
Notable SEMVER-PATCH changes include:
* fs: cache non-symlinks in realpathSync. (Jeremy Yallop)
nodejs/node#10253
* repl: allow autocompletion for scoped packages (Evan Lucas)
nodejs/node#10296
Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
Notable Changes:
The SEMVER-MINOR changes include:
* crypto: allow adding extra certs to well-known CAs (Sam Roberts)
nodejs/node#9139
* deps: Upgrade INTL ICU to version 58 (Steven R. Loomis)
nodejs/node#9234
* process: add `process.memoryUsage.external` (Fedor Indutny)
nodejs/node#9587
* src: add wrapper for process.emitWarning() (Sam Roberts)
nodejs/node#9139
Notable SEMVER-PATCH changes include:
* fs: cache non-symlinks in realpathSync. (Jeremy Yallop)
nodejs/node#10253
* repl: allow autocompletion for scoped packages (Evan Lucas)
nodejs/node#10296
Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
Background
The
fs.realpathSyncfunction synchronously traverses paths componentwise to resolve symbolic links.The optional cache argument stores the results of resolution to avoid repeated lookups. The cache can be used to override resolution and to store the results of calls to
readlinkSync.However, the cache only records paths that
lstatreveals to be symlinks. Consequently, a call tofs.realpathSyncfor a path without symlinks may result in many calls tolstat, even if most parts of the path have been resolved in an earlier call.Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
fs
Description of change
This tiny patch extends
fs.realpathSyncto record the results for paths that are not symlinks. The code suggests that this was originally the intention, since the cache is expected to contain entries that resolve to themselves:With this patch a run of
ember buildon a fresh application makes around 6,200 fewerlstatcalls (out of a total of around 70,000 syscalls). On a typical native file system the performance difference is negligible, but in situations where a syscall has more significant overhead it can be a worthwhile saving. For example, with a file system that forwards operations over a socket via FUSE this patch saves around 10% of the build time.