cache module with same version and same registry#3289
cache module with same version and same registry#3289hustxiaoc wants to merge 1 commit intonodejs:masterfrom
Conversation
lib/module.js
Outdated
|
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. |
|
It's good idea, it can reduce memory. Modules: Memory: After this idea: It can reduce 2 modules. |
|
Maybe enabled by cli parameter is better? |
lib/module.js
Outdated
There was a problem hiding this comment.
Where does the _resolved property come from?
There was a problem hiding this comment.
{
"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": "tj@vision-media.ca"
},
"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": "commander@2.6.0",
"_shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d",
"_from": "commander@2.6.0",
"_npmVersion": "2.1.12",
"_nodeVersion": "0.11.14",
"_npmUser": {
"name": "zhiyelee",
"email": "zhiyelee@gmail.com"
},
"maintainers": [
{
"name": "tjholowaychuk",
"email": "tj@vision-media.ca"
},
{
"name": "somekittens",
"email": "rkoutnik@gmail.com"
},
{
"name": "zhiyelee",
"email": "zhiyelee@gmail.com"
},
{
"name": "thethomaseffect",
"email": "thethomaseffect@gmail.com"
}
],
"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!"
}
There was a problem hiding this comment.
I see. What if _resolved is not as unique as this patch assumes? Things will break badly, won't they?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
_resolved is private property from npm registry, should not use it.
|
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 |
|
I'm inclined to agree. It looks to me like the fallout potential is non-zero. That would make it an automatic no-go. |
|
Also, measuring the memory usage savings in % is inapplicable here. It doesn't scale. |
|
so what's the best way to solve this problem ? |
|
afaik |
|
How to move deps up in this scene? |
|
@yaniswang can you use those real npm package names instead of a, b, c, d for examples? |
|
@yaniswang that's the edge case 😸 (btw nodejs/NG#20 is another approach to handle this) btw you should create PRs in |
|
|
Btw, something is wrong with your numbers here. |
|
@ChALkeR ? |
|
@hustxiaoc @ChALkeR meaning heapTotal real is |
|
Closing since module resolving algorithm is locked |


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%↓, heapTotal1.59%↓, heapUsed13.3%↓