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

Remove path-array #990

Closed
wants to merge 3 commits into from
Closed

Remove path-array #990

wants to merge 3 commits into from

Conversation

mhart
Copy link
Contributor

@mhart mhart commented Jul 12, 2016

This reverts commits 81eadc5 and ff88e5f.

Of the 5.5MB footprint of node-gyp, path-array makes up 3.6MB.

Removing this reduces the weight of npm (and ultimately node) appreciably (by 20%)

mhart added 2 commits July 12, 2016 15:42
This reverts commit ff88e5f.

Of the 5.5MB footprint of node-gyp, path-array makes up 3.6MB.

Removing this reduces the weight of npm (and thus node) appreciably.
@mhart mhart changed the title Remove path array Remove path-array Jul 12, 2016
@rvagg
Copy link
Member

rvagg commented Jul 13, 2016

Does this actually work though? I was looking at this a while back because the dependency depth here bothers me too but I wasn't sure that the same functionality could be replicated quite as easily.

Perhaps it's really this easy but since we don't have test cases around this I'm not overly confident! We can certainly give it a try in v4 pre-releases which I'm planning on spinning up soon but tests would be nice. Any chance you'd like to write us some tests for this?

@mhart
Copy link
Contributor Author

mhart commented Jul 13, 2016

Sure – I mean, I believe it was only added by @TooTallNate originally because he thought it was a good fit for the path-array module – not because the original code, written by @timbertson was faulty in any way: https://github.com/nodejs/node-gyp/pull/509/files#r20182682

I just reverted those lines to how they were when #509 was merged.

Kinda seems like overkill to add a module for just a single string join, no?

var pypath = new PathArray(process.env, 'PYTHONPATH')
pypath.unshift(path.join(__dirname, '..', 'gyp', 'pylib'))
var pypath = process.env.PYTHONPATH ? [process.env.PYTHONPATH] : []
pypath.unshift(path.resolve(__dirname, '..', 'gyp', 'pylib'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, just noticed this should stay as path.join – will add that.

@mhart
Copy link
Contributor Author

mhart commented Jul 13, 2016

I'll add some tests tomorrow if I can figure out how 👍

pypath.unshift(path.join(__dirname, '..', 'gyp', 'pylib'))
process.env.PYTHONPATH = pypath.join(process.platform === 'win32' ? ';' : ':')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's arguably a bit nicer to wrap it in a if ('PYTHONPATH' in process.env) { ... }.

Can you replace the process.platform === 'win32' ? ';' : ':' with win ? ';' : ':'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say wrap in an if, what did you have in mind?

I can certainly do:

var pypath = 'PYTHONPATH' in process.env ? [process.env.PYTHONPATH] : []

Or would you prefer something like:

var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
if ('PYTHONPATH' in process.env) {
  pypath.push(process.env.PYTHONPATH)
}
process.env.PYTHONPATH = pypath.join(win ? ';' : ':')

(I kinda prefer that over an unshift anyway tbh)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the second one. I wrote 'PYTHONPATH' in process.env but perhaps checking for truthiness / non-emptiness (i.e., just process.env.PYTHONPATH) is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
if (process.env.PYTHONPATH) pypath.push(process.env.PYTHONPATH)
process.env.PYTHONPATH = pypath.join(win ? ';' : ':')

Preferences on indentation, braces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node-gyp uses two spaces and (predominantly, I think) braces.

@TooTallNate
Copy link
Contributor

It's only so big because of es6-symbol... I wonder if there's a smaller polyfill.

@mhart
Copy link
Contributor Author

mhart commented Jul 13, 2016

@rvagg added some tests 👍

@mhart mhart force-pushed the remove-path-array branch from c35dfd9 to 3d603ce Compare July 13, 2016 15:04
mhart added a commit to lambci/npm that referenced this pull request Jul 13, 2016
This saves 3.6MB of cruft.

See: nodejs/node-gyp#990
@mhart
Copy link
Contributor Author

mhart commented Jul 19, 2016

@rvagg let me know if those tests look ok, or if there's anything you need further to get this through

@mhart
Copy link
Contributor Author

mhart commented Aug 18, 2016

Hi all – any movement on this?

FWIW, I've been building a tool to track down size regressions (and other issues with sub-deps) – you can see an example of it coming to life here: http://pkgsize.com.s3.amazonaws.com/node-gyp.html (hovering over should show you what events caused certain size changes)

Obviously, path-array and request are the big offenders. Considering that path-array is literally just used for one string join here and has such a deep dep tree, it really will reduce the risk of even further bloat to remove it.

@bnoordhuis
Copy link
Member

LGTM. CI: https://ci.nodejs.org/view/All/job/nodegyp-test-commit/12/

This probably also needs a CI run with v0.10 and v0.12.

@mhart
Copy link
Contributor Author

mhart commented Aug 31, 2016

@bnoordhuis would love to get this in – how do I get a CI run with v0.10 and v0.12?

@bnoordhuis
Copy link
Member

https://ci.nodejs.org/view/All/job/nodegyp-test-commit/13/ - v0.10.46
https://ci.nodejs.org/view/All/job/nodegyp-test-commit/14/ - v0.12.15

@nodejs/build Can someone take a look at why the win2012r2 bot complains about this:

c:\workspace\nodegyp-test-commit\nodes\win2012r2\local_node>mkdir npm-cache 

c:\workspace\nodegyp-test-commit\nodes\win2012r2\local_node>call "c:\workspace\nodegyp-test-commit\nodes\win2012r2\local_node\npm.cmd" config set cache "c:\workspace\nodegyp-test-commit\nodes\win2012r2\local_node\npm-cache" 
The system cannot execute the specified program.

From https://ci.nodejs.org/view/All/job/nodegyp-test-commit/13/nodes=win2012r2/console.

@bnoordhuis
Copy link
Member

The ubuntu buildbot seems pretty happy though so I think this is good to go. @mhart Can you squash it into what you think are logical/reasonable commits?

@mhart
Copy link
Contributor Author

mhart commented Sep 2, 2016

@bnoordhuis Sure thing – I'll keep the original "revert" commits separate and squash the rest

@mhart mhart force-pushed the remove-path-array branch from 3d603ce to bb835d6 Compare September 2, 2016 13:38
@mhart
Copy link
Contributor Author

mhart commented Sep 2, 2016

@bnoordhuis done – let me know if you want me to squash further

Using push instead of the original unshift makes the logic a little cleaner to read here.
@mhart mhart force-pushed the remove-path-array branch from bb835d6 to f658da7 Compare September 2, 2016 13:42
@joaocgreis
Copy link
Member

The job was trying to download node.exe from the wrong place, so it was getting a html page instead of a exe, hence the "cannot execute" error. Also, npm was interfering with the CITGM job. Both fixed.

Started two jobs with similar parameters:

Seems good!

@mhart
Copy link
Contributor Author

mhart commented Sep 20, 2016

Anything more need to be done on this? If so lemme know 👍

@mhart
Copy link
Contributor Author

mhart commented Oct 6, 2016

Hey all, just checking in on this PR. Let me know if there are any more concerns?

bnoordhuis pushed a commit that referenced this pull request Oct 7, 2016
This reverts commit ff88e5f.

Of the 5.5MB footprint of node-gyp, path-array makes up 3.6MB.

Removing this reduces the weight of npm (and thus node) appreciably.

PR-URL: #990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
bnoordhuis pushed a commit that referenced this pull request Oct 7, 2016
This reverts commit 81eadc5.

PR-URL: #990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
bnoordhuis pushed a commit that referenced this pull request Oct 7, 2016
Using push instead of the original unshift makes the logic a little
cleaner to read here.

PR-URL: #990
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@bnoordhuis
Copy link
Member

I think we were (and are) just waiting for the next node-gyp release. I've landed it in 9c8d275...ddac348, thanks!

@bnoordhuis bnoordhuis closed this Oct 7, 2016
@mhart
Copy link
Contributor Author

mhart commented Oct 7, 2016

Great, thanks @bnoordhuis 👍

Once it makes it to Node.js it'll be the first drop in size we've seen in years – here's hoping!

@jbergstroem
Copy link
Member

This is pretty awesome. Thanks for the effort!

@mhart
Copy link
Contributor Author

mhart commented Jan 13, 2017

Thanks for pushing this out – npm@4.1.2 has just included it and has reaped the benefits of an 18% reduction in size 👍

mhart added a commit to lambci/npm that referenced this pull request Jan 24, 2017
This saves 3.6MB of cruft.

See: nodejs/node-gyp#990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants