-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
module: ignore package.json/ directories #18261
Conversation
Could this be handled at the C++ level of the |
@jdalton could, but then it won't be in the stat cache. |
Is there a way to share a cache between C++ helpers and external... |
@jdalton the |
Ah, okay. |
If |
|
||
try { | ||
require(fixtures.path('module-package-json-directory')); | ||
process.exit(1); |
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.
Would it be better to assert.fail
here instead? I'm thinking from the point of view of how it might look in the CI if the test failed here.
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.
Can't we just use assert.throws()
?
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.
it would just be caught by the catch
below.
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 @richardlau's comment fixed.
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.
This shouldn't land as-is. A lot of time and effort has been spent on making this particular code path fast.
lib/module.js
Outdated
@@ -123,6 +123,10 @@ function readPackage(requestPath) { | |||
return entry; | |||
|
|||
const jsonPath = path.resolve(requestPath, 'package.json'); | |||
const rc = stat(jsonPath); |
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.
Don't introduce extra system calls that are practically never necessary. Handle it inside InternalModuleReadJSON()
, it's the CHECK_GE(numchars, 0)
in that function.
edit: since it's easier to just write it than try and explain it: #18270
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.
resolved
@bnoordhuis your requests have been upstreamed to this PR |
@guybedford changed to use "" @jdalton moved to InternalModuleReadJSON |
there was a bug in how |
@bmeck Taking my code and merging that as your own without attribution or even so much as a thank you... that's not a nice thing to do. |
@bnoordhuis I'd agree but have similar thoughts on repeated interactions with you. I'll add your attribution, you didn't seem to have any attribution or care about my efforts on your PR either though. |
Author: Ben Noordhuis <info@bnoordhuis.nl>
That's because there's nothing to attribute, I didn't take code or ideas from this PR. |
@bnoordhuis your statements reinforce my feelings being similar to yours at being upset at the other person. |
moving conversation to @bnoordhuis 's PR after having problems with differences in internal consistency choices. it ended up expanding the decision making process and can be discussed there. |
Moved to #18270. |
Reopened for comparative review from @nodejs/tsc . |
Actual benchmark run so we're not just guessing about potential perf impact: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/109/console |
At least for the module-loader microbenchmarks, there is no appreciable impact ...
Not sure how much (if at all, that benchmark exercises this code, however) |
FWIW, I benchmark using one of the loopback sample apps (loads ~5,000 files and did something like 250K stat calls at first, IIRC) but any biggish real-world application should do. Warming up the disk cache with a few trial runs is a good idea. |
Ok, do you have any numbers from the loopback sample that show the changes in this PR being a problem? |
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
I am not against this PR but I would prefer to have the cache changes in a separate one |
Closed in favor of #18270. (If that's not the right thing to do, by all means, re-open!). |
Fixes: #8307
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
module