| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Why was the lazy-loading of the extensions removed?
Sorry, something went wrong.
There was a problem hiding this comment.
Simplified the control flow, since tryFindPath was split out in order to reduce redundancy (just like readFilePath).
More than happy to add it back in, but seemed like a very marginal cost to me.
Sorry, something went wrong.
Sorry, something went wrong.
|
Looks like it's causing test-cwd-enoent-preload.js to fail just about everywhere. |
Sorry, something went wrong.
|
Despite the test failure, I ran the module loader benchmark before and after this change (and after fixing a const causing an aborted optimization): module/module-loader.js thousands=50 fullPath=true: ./node-new: 9.8836 ./node-old: 11.831 .. -16.46% module/module-loader.js thousands=50 fullPath=false: ./node-new: 8.3574 ./node-old: 9.4516 . -11.58% |
Sorry, something went wrong.
|
@mscdex Yes, this is expected, since now we need to check if the prefixed symlink exists for every required module. I don't think there is any way around in any of the proposed solution. Update Actually there is, but is means the precedence changes (default to new behaviour if both files exist). |
Sorry, something went wrong.
There was a problem hiding this comment.
The above two lines are contributing to v8 aborting optimization of Module._findPath() because of the const usage. They should be reverted to var for now.
Sorry, something went wrong.
|
@alexanderGugel ... Thank you very much for this. I'm still skeptical if this is the right approach. As an interim solution, I'm currently leaning towards a flag based fix that conditionally reverts the change that was made with the long term solution being closer to the two cache model I described. I'll have some time to walk through this PR in detail soon tho. Really appreciate you putting this together tho! |
Sorry, something went wrong.
Since nodejs#5950, `require('some-symlink')` no longer resolves the module to its real path, but instead uses the path of the symlink itself as a cache key. This change allows users to resolve dependencies to their real path when required using the _-prefix. Example using old mechanism (pre v6.0.0): --- node_modules/_real-module -> ../real-module real-modules/index.js require('./real_module') === require('real_module') Example using new mechanism (post v6.0.0): --- node_modules/real-module -> ../real-module real-modules/index.js require('./real_module') !== require('real_module') As discussed in nodejs#3402
|
Sorry, was too fast. Didn't actually fix the process.cwd() issue. |
Sorry, something went wrong.
That way stat() only needs to be called once in most cases (assuming non _-prefixed symlinks are more common).
|
@mscdex How can I run those benchmarks? 37b7b5e should fix the perf issue. This also makes this change mostly backwards compatible with the symlink change introduced in v6.0.0. |
Sorry, something went wrong.
| // If _basePath is a symlink, use the real path rather than the path of the | ||
| // symlink as cache key. | ||
| const _basePath = path.resolve(curPath, '_' + request); | ||
| const basePath = path.resolve(curPath, request); |
There was a problem hiding this comment.
The above two lines need to be changed to use var instead of const to avoid aborted optimziations of _findPath() by v8.
Sorry, something went wrong.
There was a problem hiding this comment.
fixed.
Sorry, something went wrong.
const in for-loop can not be optimized.
* Fixes `test-cwd-enoent-preload.js` * Minor performance improvement
| for (var i = 0; i < paths.length; i++) { | ||
| // Don't search further if path doesn't exist | ||
| const curPath = paths[i]; | ||
| var curPath = paths[i]; |
There was a problem hiding this comment.
Actually, this line was fine. It was just the other 3 that were causing problems.
Sorry, something went wrong.
Sorry, something went wrong.
|
@alexanderGugel Assuming node-old is a copy of the binary representing node before this PR, you'd do something like: node benchmark/compare -r -g ./node ./node-old -- module module-loader With the most recent changes I now see: module/module-loader.js thousands=50 fullPath=true: ./node: 11.377 ./node-old: 11.781 . -3.43% module/module-loader.js thousands=50 fullPath=false: ./node: 9.4919 ./node-old: 9.504 . -0.13% |
Sorry, something went wrong.
|
@mscdex Thanks. I would assume the performance regression is most likely because of functions not being optimised rather than unneeded syscalls, since the benchmarks most likely don't even cover those. |
Sorry, something went wrong.
|
@alexanderGugel Can you explain what you mean by "not being optimized?" |
Sorry, something went wrong.
|
37b7b5e means there are no additional stats when the module can be found via a non _-prefixed linkname, meaning that the only scenario in which an additional stat is needed is when the module could not be found, and we need to check if a _-prefixed version exists. Going to bed now. |
Sorry, something went wrong.
|
I will look into additional optimizations |
Sorry, something went wrong.
Ensure that `require('some-module/index.js')` is being resolved properly when
`some-module` is a _-prefixed symlink.
Sorry, something went wrong.
|
@alexanderGugel I haven't had time yet unfortunately. I will try to dig into it this week though. |
Sorry, something went wrong.
|
It looks like the commit that broke this in the first place is about to be reverted, which would render this PR obsolete (#6537). So maybe the default should be changed... use the realpath of symlinks by default and use the path of the symlink if the linkname starts with _ - so exactly the other way around. That way backwards compatibility with v5.0.0 could be preserved while adding the ability to conditionally use the v6.0.0 mechanism (= path of symlink). |
Sorry, something went wrong.
+1 as a possible way to address the peer dependency bug. However, we should explore other ideas as well. |
Sorry, something went wrong.
|
Since we reverted to the old behavior and put the new behavior behind a flag is it safe to close this? |
Sorry, something went wrong.
|
Yup, although there is still no way to have both solutions. |
Sorry, something went wrong.
|
We still need a way get both behaviors working without a flag -- but I don't think this option was going to work (at least not on its own). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
Description of change
Since #5950, require('some-symlink') no longer resolves the module to its
real path, but instead uses the path of the symlink itself as a cache key.
This change allows users to resolve dependencies to their real path when
required using the _-prefix.
Example using old mechanism (pre v6.0.0):
Example using new mechanism (post v6.0.0):
As discussed in #3402