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

[BUG] Tar is very slow on npm 6.14.15 #293

Closed
Tallyb opened this issue Sep 12, 2021 · 7 comments
Closed

[BUG] Tar is very slow on npm 6.14.15 #293

Tallyb opened this issue Sep 12, 2021 · 7 comments
Labels
Enhancement new feature or improvement

Comments

@Tallyb
Copy link

Tallyb commented Sep 12, 2021

What / Why

npm 6.14.15 is horribly slow, and it seems to result from upgrading tar from 4.4.14 to 4.4.19.

To reproduce you can try and install a package that needs to extract data like geo-tz(6.0.1). On GHA we saw an increase in npm install from 1 minute to 7 minutes!!!

Check out this repo github actions timing:
https://github.com/Tallyb/slow-npm/actions/runs/1228854056

@theseion
Copy link

theseion commented Sep 24, 2021

I can confirm that. However, its not the node version but NPM, 6.14.14 was fine 6.14.15 is not. The change of the tar version is from 4.4.15 to 4.4.19.

@theseion
Copy link

I've narrowed it down to 4.4.16. Tested with material-design-icons 3.0.1.
NPM version: 6.14.14

I manually changed the tar dependency in the npm package.json to 4.4.16, then npm i (for npm). With that the processing time goes up from ~120 seconds to 300+ seconds.

@theseion
Copy link

Oh, just for future reference: I got here because my builds stopped working after the node:lts-buster image was upgraded last to use NPM 6.14.15. NPM would start timing out with "cb() never called".

@alerighi
Copy link

alerighi commented Oct 6, 2021

I have the same problem. It seems related to the directory caching mechanism in mkdir: by disabling the cache, that can simply done by changing the functions cGet and cSet in lib/mkdir.js to empty functions, I improved installation time of geo-tz from 1.33 minutes to just 10s on Linux. It seems faster to try to make the directory, and fail because the file exist, than to write and lookup in the cache, when you have a lot of directories. On Windows it took ages (10s of minutes), with this simple fix only 46 seconds.

I made other tests, and it seems that the cause is the function pruneCache that iterates on every item in the cache. By bypassing it the performance is even better but it should have implications. If I instead change the cache data structure from a Map to a Set the performance seems to improve significantly.

@kuzmeo
Copy link

kuzmeo commented Nov 15, 2021

I have similar performance issues on 7.x and 8.x npm versions as well. npm install runs 3-4 times slowly than on 6.14.14 npm version.

@psxpa3
Copy link

psxpa3 commented Nov 16, 2021

Hi @Tallyb I am trying to upgrade tar version from 4.4.8 to 6.1.9/6.1.10, however getting the following error - TypeError: Cannot destructure property isAbsolute of 'undefined' or 'null'.

5 | import * as tmp from "tmp";
6 | // import * as tar from "tar";

7 | const tar = require("tar");

Could you provide any direction on this?. It seems to be breaking at tar.extract(), but everything seems intact to me.

@theseion
Copy link

For reference, this appears to be the issue where people noticed that something was going on with NPM: npm/cli#3676

@darcyclarke darcyclarke added the Enhancement new feature or improvement label Jul 28, 2022
@isaacs isaacs closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement new feature or improvement
Projects
None yet
Development

No branches or pull requests

8 participants
@isaacs @theseion @darcyclarke @psxpa3 @Tallyb @alerighi @kuzmeo and others