Uh oh!
There was an error while loading. Please reload this page.
src: port initializeImportMeta to native - #57286
Conversation
nodejs-github-bot
commented
Mar 3, 2025
Review requested:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #57286 +/- ##
==========================================
- Coverage 90.28% 90.26% -0.02%
==========================================
Files 630 630 Lines 186158 186208 +50 Branches 36484 36488 +4 ==========================================
+ Hits 168067 168077 +10 - Misses 10974 10987 +13 - Partials 7117 7144 +27
🚀 New features to boost your workflow:
|
JakobJingleheimer
left a comment
There was a problem hiding this comment.
I'm not great with cpp, but it looks fine AFAICT, and conceptually checks out 🙂
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jsumners-nr
left a comment
There was a problem hiding this comment.
I think the original implementation is much easier to understand and maintain.
aduh95
commented
Mar 6, 2025
Do you have any suggestions on how to improve it? |
jsumners-nr
commented
Mar 10, 2025
Not with it all being in C++. The original was plain JavaScript that only required JavaScript domain knowledge. This PR shifts it all in to C++, thus requiring the reader to know that language along with all of the underlying APIs used to implement the feature. |
CI: https://ci.nodejs.org/job/node-test-pull-request/65676/ Results |
Banchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1680/ Results |
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1682/ ResultsIt's not any better, reverting |
nodejs-github-bot
commented
Mar 13, 2025
There was a problem hiding this comment.
Nit: remove the v8:: qualifier and add v8::PropertyCallbackInfo to the using section at the top if it is not already there.
There was a problem hiding this comment.
Setting Data to a single internal object that has both dirname and filename set on it the first time either is accessed on it should work, yes?
There was a problem hiding this comment.
Nit: can these please avoid the use of Check() and propagate errors up correctly?
jsumners-nr
commented
Mar 13, 2025
The actual benchmarks site is asking for a login. How do we interpret this snippet? |
jasnell
commented
Mar 13, 2025
hmm... looking at the benchmark results there it's just not clear to me that moving the init to native code has enough realized benefit. Moving into native does make the code a bit more difficult to maintain while also being slight slower. A lazy getter defined in JavaScript could likely achieve the same result while being easier for more people to help maintain. Not going to block on it tho... just not seeing the full benefit. |
aduh95
commented
Mar 13, 2025
It's unclear whether a JS getter would be spec compliant, see the discussion in #57003 – that being said, I'm also a bit puzzled by the benchmark results |
JakobJingleheimer
commented
Mar 30, 2025
What you've done here is pretty cool. But if the c++ implementation isn't faster, and we can stay spec compliant (which that discussion seemed to end that it is), I think the JS implementation would be better because it's more maintainable. |
f38430c to
e7c7320CompareBenchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1697/ Results |
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1698/ Results |
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1699/ Results |
aduh95
commented
Apr 29, 2025
Landed in 50cfc6c |
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
PR-URL: #57286 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Supersedes #57003.
We should probably avoid translating the URL to a path twice when the user needs both
dirnameandfilename, but I'm not sure if there's an elegant way to do it without crossing the C++/JS bundary.