GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cache module with same version and same registry by hustxiaoc · Pull Request #3289 · nodejs/node

Conversation

@hustxiaoc

@hustxiaoc hustxiaoc commented Oct 9, 2015

Copy link
Copy Markdown

related pr nodejs/node-v0.x-archive#8617

in my project, I start a single node process and here are the memoryUsage.

without cache
{ rss: 84873216, heapTotal: 63907840, heapUsed: 38901048 }

and with cache
{ rss: 72458240, heapTotal: 62887936, heapUsed: 33719160 }

rss 14.6%↓ , heapTotal 1.59%↓, heapUsed 13.3%↓

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
淘小杰
cache module with same version and same registry
43d874f
related pr nodejs/node-v0.x-archive#8617
JacksonTian
JacksonTian reviewed Oct 9, 2015
View reviewed changes
Comment thread lib/module.js Outdated

@JacksonTian JacksonTian Oct 9, 2015

Copy link
Copy Markdown
Contributor

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.

这个会导致内存中带有很多无关信息。

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hustxiaoc hustxiaoc Oct 9, 2015

Copy link
Copy Markdown
Author

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.

相比于多次加载模块使用的内存少多了

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Oct 9, 2015

Copy link
Copy Markdown
Member

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 you use English please?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ChALkeR

ChALkeR commented Oct 9, 2015

Copy link
Copy Markdown
Member

This is going to be solved by npm3, isn't it? I am not sure that this is a good idea to do something like that on node.js side, it could break things.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR ChALkeR added semver-major PRs that contain breaking changes and should be released in the next major version. module Issues and PRs related to the module subsystem. labels Oct 9, 2015
@yaniswang

yaniswang commented Oct 9, 2015

Copy link
Copy Markdown

It's good idea, it can reduce memory.

Modules:

a(1.0.0) -> x(1.0.0)
b(1.0.0) -> x(2.0.0)
c(1.0.0) -> x(1.0.0)
d(1.0.0) -> x(2.0.0)

Memory:

a(1.0.0)
b(1.0.0)
c(1.0.0)
d(1.0.0)
x(1.0.0)
x(2.0.0)
x(1.0.0)
x(2.0.0)

After this idea:

a(1.0.0)
b(1.0.0)
c(1.0.0)
d(1.0.0)
x(1.0.0)
x(2.0.0)

It can reduce 2 modules.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yaniswang

yaniswang commented Oct 9, 2015

Copy link
Copy Markdown

Maybe enabled by cli parameter is better?

node --module-dedupe
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Oct 9, 2015
View reviewed changes
Comment thread lib/module.js Outdated

@bnoordhuis bnoordhuis Oct 9, 2015

Copy link
Copy Markdown
Member

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.

Where does the _resolved property come from?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@yaniswang yaniswang Oct 9, 2015

Copy link
Copy Markdown

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.

{
  "name": "commander",
  "version": "2.6.0",
  "description": "the complete solution for node.js command-line programs",
  "keywords": [
    "command",
    "option",
    "parser",
    "prompt"
  ],
  "author": {
    "name": "TJ Holowaychuk",
    "email": "[email protected]"
  },
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/tj/commander.js.git"
  },
  "devDependencies": {
    "should": ">= 0.0.1"
  },
  "scripts": {
    "test": "make test"
  },
  "main": "index",
  "engines": {
    "node": ">= 0.6.x"
  },
  "files": [
    "index.js"
  ],
  "gitHead": "c6807fd154dd3b7ce8756f141f8d3acfcc74be60",
  "bugs": {
    "url": "https://github.com/tj/commander.js/issues"
  },
  "homepage": "https://github.com/tj/commander.js",
  "_id": "[email protected]",
  "_shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d",
  "_from": "[email protected]",
  "_npmVersion": "2.1.12",
  "_nodeVersion": "0.11.14",
  "_npmUser": {
    "name": "zhiyelee",
    "email": "[email protected]"
  },
  "maintainers": [
    {
      "name": "tjholowaychuk",
      "email": "[email protected]"
    },
    {
      "name": "somekittens",
      "email": "[email protected]"
    },
    {
      "name": "zhiyelee",
      "email": "[email protected]"
    },
    {
      "name": "thethomaseffect",
      "email": "[email protected]"
    }
  ],
  "dist": {
    "shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d",
    "tarball": "http://registry.npmjs.org/commander/-/commander-2.6.0.tgz"
  },
  "directories": {},
  "_resolved": "http://registry.npmjs.org/commander/-/commander-2.6.0.tgz",
  "readme": "ERROR: No README data found!"
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Oct 9, 2015

Copy link
Copy Markdown
Member

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.

I see. What if _resolved is not as unique as this patch assumes? Things will break badly, won't they?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@yaniswang yaniswang Oct 9, 2015

Copy link
Copy Markdown

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.

Or replace to shasum?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Oct 9, 2015

Copy link
Copy Markdown
Member

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.

You mean the _shasum field? Same issue: what if it's not unique, e.g., because someone accidentally copy-pasted it from one package.json to another?

You could perhaps take the SHA-1 checksum of the whole package.json file but that requires that node is compiled with openssl support. You can add workarounds for the non-openssl case but I don't know, that gets complex awfully fast.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hustxiaoc hustxiaoc Oct 9, 2015

Copy link
Copy Markdown
Author

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.

when running npm install , does it not download the source code from the _resolved url ? so the _resolved url got be unique, otherwise things will break badly, right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fengmk2 fengmk2 Oct 9, 2015

Copy link
Copy Markdown
Contributor

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 is private property from npm registry, should not use it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@yaniswang yaniswang Oct 9, 2015

Copy link
Copy Markdown

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.

Or tarball

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ChALkeR

ChALkeR commented Oct 9, 2015

Copy link
Copy Markdown
Member

As it is now, it is a semver-major change in the Modules API. Per doc, Modules system is Locked, so this should be automatically rejected.

https://nodejs.org/api/modules.html#modules_modules
https://nodejs.org/api/documentation.html#documentation_stability_index

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Oct 9, 2015

Copy link
Copy Markdown
Member

I'm inclined to agree. It looks to me like the fallout potential is non-zero. That would make it an automatic no-go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Oct 9, 2015

Copy link
Copy Markdown
Member

Also, measuring the memory usage savings in % is inapplicable here. It doesn't scale.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR ChALkeR added the memory Issues and PRs related to Node.js memory management or memory footprint. label Oct 9, 2015
@hustxiaoc

hustxiaoc commented Oct 9, 2015

Copy link
Copy Markdown
Author

so what's the best way to solve this problem ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@madbence

madbence commented Oct 9, 2015

Copy link
Copy Markdown

afaik npm3 solves this issue by moving deps up in the dep tree as much as possible (there are a few edge-cases where this cannot work of course)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yaniswang

yaniswang commented Oct 9, 2015

Copy link
Copy Markdown

How to move deps up in this scene?

a(1.0.0) -> x(1.0.0)
b(1.0.0) -> x(2.0.0)
c(1.0.0) -> x(1.0.0)
d(1.0.0) -> x(2.0.0)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fengmk2

fengmk2 commented Oct 9, 2015

Copy link
Copy Markdown
Contributor

@yaniswang can you use those real npm package names instead of a, b, c, d for examples?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@madbence

madbence commented Oct 9, 2015

Copy link
Copy Markdown

@yaniswang that's the edge case 😸 (btw nodejs/NG#20 is another approach to handle this)


btw you should create PRs in a and c to upgrade x to 2 😉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yaniswang

yaniswang commented Oct 9, 2015

Copy link
Copy Markdown

image
nodejs/NG#20
Yes, This can solve this problem, but where is module v2.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Oct 9, 2015

Copy link
Copy Markdown
Member

@hustxiaoc

without cache
{ rss: 84873216, heapTotal: 63907840, heapUsed: 38901048 }

and with cache
{ rss: 72458240, heapTotal: 62887936, heapUsed: 33719160 }

rss 14.6%↓ , heapTotal 15.9%↓, heapUsed 13.3% ↓

Btw, something is wrong with your numbers here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hustxiaoc

hustxiaoc commented Oct 9, 2015

Copy link
Copy Markdown
Author

@ChALkeR ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fengmk2

fengmk2 commented Oct 9, 2015

Copy link
Copy Markdown
Contributor

@hustxiaoc @ChALkeR meaning heapTotal not 15.9%↓

heapTotal real is 1.59%↓

(63907840 - 62887936) / 63907840 * 100
1.595898093254286
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hustxiaoc

hustxiaoc commented Oct 9, 2015

Copy link
Copy Markdown
Author

@fengmk2 @ChALkeR got it! 😊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yaniswang

yaniswang commented Oct 10, 2015

Copy link
Copy Markdown

image
My case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott
Trott force-pushed the master branch from 1e896a6 to 082cc8d Compare December 27, 2015 02:00
@vkurchatkin

vkurchatkin commented Jan 30, 2016

Copy link
Copy Markdown
Contributor

Closing since module resolving algorithm is locked

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin vkurchatkin closed this Jan 30, 2016
This was referenced May 13, 2024
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 leonardoadame/node#821
Open
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 leonardoadame/node#851
Open
This was referenced May 14, 2024
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 aliscco/alisco-node#1462
Open
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 aliscco/alisco-node#1472
Open
@aliscco aliscco mentioned this pull request May 14, 2024
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 aliscco/alisco-node#1482
Open
@leonardoadame leonardoadame mentioned this pull request May 14, 2024
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 leonardoadame/node#892
Open
This was referenced May 14, 2024
[Snyk] Fix for 2 vulnerabilities aliscco/alisco-node#1491
Open
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 aliscco/alisco-node#1548
Open
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 aliscco/alisco-node#1549
Open
This was referenced May 22, 2024
[Snyk] Fix for 2 vulnerabilities aliscco/alisco-node#1632
Open
[Snyk] Fix for 2 vulnerabilities aliscco/alisco-node#1639
Open
This was referenced May 23, 2024
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 leonardoadame/node#1033
Open
[Snyk] Security upgrade karma from 3.1.4 to 4.2.0 leonardoadame/node#1039
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

memory Issues and PRs related to Node.js memory management or memory footprint. module Issues and PRs related to the module subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@hustxiaoc @ChALkeR @yaniswang @bnoordhuis @madbence @fengmk2 @vkurchatkin @JacksonTian
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.