Skip to content
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: improve getPackageType performance #57599

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dario-piotrowicz
Copy link
Contributor

packageJsonReader#getPackageType currently gets the whole package scope config from the C++ binding and then extracts its type field, my understanding is that this is wasteful (since the whole object needs to be serialized to cross the C++/JS boundary) and that gathering the type in C++ and returning only that would be more efficient, that's what I'm attempting to do in this PR 🙂 (I hope my C++ makes sense as I am pretty inexperienced with it 🤞)

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. typings labels Mar 23, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/add-getPackageType-module-binding branch from 759229d to 2c75280 Compare March 23, 2025 21:06
@GeoffreyBooth GeoffreyBooth requested a review from anonrig March 23, 2025 21:57
@anonrig
Copy link
Member

anonrig commented Mar 23, 2025

I'll review tomorrow morning.

Copy link

codecov bot commented Mar 23, 2025

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.22%. Comparing base (1123585) to head (d242ecf).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/node_modules.cc 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57599      +/-   ##
==========================================
- Coverage   90.22%   90.22%   -0.01%     
==========================================
  Files         630      630              
  Lines      185055   185064       +9     
  Branches    36216    36223       +7     
==========================================
- Hits       166975   166969       -6     
- Misses      11042    11043       +1     
- Partials     7038     7052      +14     
Files with missing lines Coverage Δ
lib/internal/modules/package_json_reader.js 99.39% <100.00%> (ø)
src/node_modules.h 100.00% <ø> (ø)
src/node_modules.cc 78.73% <91.66%> (-0.29%) ⬇️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dario-piotrowicz dario-piotrowicz force-pushed the dario/add-getPackageType-module-binding branch 3 times, most recently from 2052d4a to 3406431 Compare March 24, 2025 00:15
@dario-piotrowicz dario-piotrowicz force-pushed the dario/add-getPackageType-module-binding branch from 3406431 to 0670e6e Compare March 24, 2025 23:38
@dario-piotrowicz dario-piotrowicz force-pushed the dario/add-getPackageType-module-binding branch from 0670e6e to 46649e7 Compare March 24, 2025 23:45
@jasnell
Copy link
Member

jasnell commented Mar 25, 2025

I think this should be ready to go but we're unable to run jenkins CI on it currently due to some ongoing maintenance, Once the CI system is unrestricted again we'll get the CI run scheduled so we can get this landed.

@jasnell jasnell added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. typings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants