-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Process aborts with 'out of memory' when using 2.0.0 #143
Comments
Thanks for issue, investigate |
Just information, change this line to:
and see what happens. Error appears on source map generation step:
Use |
Looks terser leaking |
Why problem appears: Before for only one file we run new thread for uglification, now we use same thread for this. Removing But another problem occurred - memory leak. Simple investigation, i used this code:
and put this lines after https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/index.js#L272 New version (we don't create new thread for one file):
Old version (new thread for one file):
Around 700 MB leaking /cc @fabiosantoscode |
/cc @nick also
Caches is not working in your app, long cache term also |
@nick try to use https://github.com/webpack-contrib/terser-webpack-plugin/releases/tag/v2.0.1, anyway we need investigate why terser consume a lot of memory Let's wait @fabiosantoscode answer |
Thanks for looking this so quickly, @evilebottnawi - and thanks for the tip on the cache issue 😊 Can confirm 2.0.1 works as before. Feel free to close unless you want to keep it open for the memory issue. |
Interesting. I'll try to come up with the exact tag where this started to happen. |
But I kind of have something else I have to fix first, though. |
@fabiosantoscode 👍 yep, feel free to ping me i can help you with memory leak searching |
I tried creating a file that attempts to encrypt a lot of things to try and create a memory leak, but I can't reproduce this at all. I looked into the commit that fixes this. Isn't this just a 2.0.0 specific problem? |
@fabiosantoscode no, we just run terser in separate thread instead using currently, but looks terser have memory leak, because no problem in parallel mode, but problem when you use only one thread |
Can this be reproduced with the default options? The Terser tests aren't leaking memory at all. |
In my experience, there hasn't been any significant difference in memory usage. Both V1 and V2 are hovering around 500MB of memory (and same compilation time) for one of our smaller apps. Measured with |
@eliseumds it is expected because terser still consume many memory, need search way to optimize terser and decrease uglify time |
Build time more than doubled from 6 minutes to 14 minutes in one of our bigger projects by just updating to version 2 of this dependency. |
Our build time also doubled when upgrading to version 2 |
@rrelmy @JoshRobertson sorry but your comments is not helpful. Please provide information what version you use before, also we have breaking change and generate source maps bsed on devtool value, so now you can generate source map and it is increase build time |
Same story here. After we upgraded The error that we get (it is reported 3 times in a row):
Below are the results summarized in a table:
Note: in all 3 cases above everything else remained unchanged, only 2 variables changed: the version and the parallel option of the plugin. |
@korya can you create reproducible test repo? |
@evilebottnawi Sorry, I will probably won't able to do it. Our repository is private, and coming up with an artificial example to reproduce this issue would be a nightmare. It seems that the memory consumption of the plugin just grew up. The Again these are just my thoughts, I did not perform any deep analysis. I am sorry that I cannot help any more than that. If I will have some time, I will try to gather more info. But I don't believe I can easily come up with a reproducible test. |
@korya anyway thanks for feedback, yes new version require more memory:
All this requires a little more memory. We have an issue to reduce memory/cpu usage terser/terser#478. |
@korya We had the same error and the same behaviour. The childprocesses immediately return with an error code of 1 and after a number of retries the error message occurs. I turned off the silent option in ChildProcessWorker.js (of jest-worker). Our build scripts had --trace-deprecation enabled and somehow the childprocess is not able to handle this option. I just disabled it for now. Temporarily replace |
@mateder Can you create minimum reproducible test repo? |
Same problem started to appear for us & nothing changed other than adding a new package to our build. In our case also, I tried these versions, |
@ahmedelgabri maybe you can create reproducible test repo, i will investigate that |
I think I was able to solve this problem, big thanks @cjlarose for inspiration and great idea, honestly I don’t know how I didn’t get to this decision before. Now I run tests to put them here, I think today we release a patch version and close that problem. I want to warn that this reduces consumption, but for real big projects, for example 5000+ entries, you need increase node memory usage |
Release will be today, evening, want to add more tests (increase coverage) |
* Caused by Webpack and Karma * webpack-contrib/terser-webpack-plugin#143 * Fix karma freezing * Avoiding compiling unnecessary assets (again) * Not using webpacker full config file
This seems to be causing the image build machines to OOM. Perhaps related to webpack-contrib/terser-webpack-plugin#143
This seems to be causing the image build machines to OOM. Perhaps related to webpack-contrib/terser-webpack-plugin#143
Hey guys just want to comment that this parallism is still unstable but it honestly seems very close to the bare metal here. I'm on a ryzen 5800 and Ubuntu 20.04. If i let it figure out parallel itself, my cpu and ram max out and the process ends up killed. If I use say an env variable and set it to 6, i borderline max memory usage. If i run this on one of our web nodes which are typically 4 core amazon t3 instances running 18.04, the build seems to work just fine. All were ran on node v14.17.0 and the latest webpack and babel versions. I have limited understanding as to what is happening under the hood but I can say that we have many 'entry' apps, around 30+. If I cull these entries just for sanity check purposes it does seem to help but I still max out and die. There's something going on here with how it forks and utilizes system resources and like I said it may be only affecting my hardware group here. If anyone is finding there way to this comment here's an example of how I solved my issue:
|
Terser webpack plugin has memory leaks in version 2.0.0 until version 3. To avoid major bugs from 3.0.0, bumping to one major update past 3.0.x to get most stable bug fixes for 3.x version. Source: webpack-contrib/terser-webpack-plugin#143 Also, fix the package-lock.json with npm 8.0.0 cause I'm tired of seeing the "package-lock.json created with older version of npm" plus the long running "fixing it up: this is a one-time operation" that adds bloat to our already long builds.
This is last version before 5.x that drops source map support. It has a lot of downloads and has ^4.4.3 versions of terser as a dependency which has major improvements for memory usage as is stated in the following comment from the devs: webpack-contrib/terser-webpack-plugin#143 (comment)
This will limit the amount of heap each worker thread of terser can produce when uglifying and minifying our code. Holding it to 4 worker threads gives us enough of a boost from parallelism but less than 2 GB of RAM usage for the build making it comfortable to run on low-end systems or CI while doing other build tasks. Suggest from devs of terser here: webpack-contrib/terser-webpack-plugin#143 (comment)
* Update terser-webpack-plugin to 3.1.0 or greater Terser webpack plugin has memory leaks in version 2.0.0 until version 3. To avoid major bugs from 3.0.0, bumping to one major update past 3.0.x to get most stable bug fixes for 3.x version. Source: webpack-contrib/terser-webpack-plugin#143 Also, fix the package-lock.json with npm 8.0.0 cause I'm tired of seeing the "package-lock.json created with older version of npm" plus the long running "fixing it up: this is a one-time operation" that adds bloat to our already long builds. * Up terser-webpack-plugin to v4.2.3 This is last version before 5.x that drops source map support. It has a lot of downloads and has ^4.4.3 versions of terser as a dependency which has major improvements for memory usage as is stated in the following comment from the devs: webpack-contrib/terser-webpack-plugin#143 (comment) * Set terser parallelism to 4 This will limit the amount of heap each worker thread of terser can produce when uglifying and minifying our code. Holding it to 4 worker threads gives us enough of a boost from parallelism but less than 2 GB of RAM usage for the build making it comfortable to run on low-end systems or CI while doing other build tasks. Suggest from devs of terser here: webpack-contrib/terser-webpack-plugin#143 (comment)
* Update terser-webpack-plugin to 3.1.0 or greater Terser webpack plugin has memory leaks in version 2.0.0 until version 3. To avoid major bugs from 3.0.0, bumping to one major update past 3.0.x to get most stable bug fixes for 3.x version. Source: webpack-contrib/terser-webpack-plugin#143 Also, fix the package-lock.json with npm 8.0.0 cause I'm tired of seeing the "package-lock.json created with older version of npm" plus the long running "fixing it up: this is a one-time operation" that adds bloat to our already long builds. * Up terser-webpack-plugin to v4.2.3 This is last version before 5.x that drops source map support. It has a lot of downloads and has ^4.4.3 versions of terser as a dependency which has major improvements for memory usage as is stated in the following comment from the devs: webpack-contrib/terser-webpack-plugin#143 (comment) * Set terser parallelism to 4 This will limit the amount of heap each worker thread of terser can produce when uglifying and minifying our code. Holding it to 4 worker threads gives us enough of a boost from parallelism but less than 2 GB of RAM usage for the build making it comfortable to run on low-end systems or CI while doing other build tasks. Suggest from devs of terser here: webpack-contrib/terser-webpack-plugin#143 (comment)
Expected Behavior
Process does not abort
Actual Behavior
Code
https://github.com/OriginProtocol/origin/blob/master/dapps/marketplace/webpack.config.js
How Do We Reproduce?
The text was updated successfully, but these errors were encountered: