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

Fix reduce memory usage #211

Merged
merged 13 commits into from
Jan 28, 2020
Merged

Fix reduce memory usage #211

merged 13 commits into from
Jan 28, 2020

Conversation

alexander-akait
Copy link
Member

@alexander-akait alexander-akait commented Jan 27, 2020

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

reduce memory usage

fixes #143

Breaking Changes

No

Additional Info

  • lazy task generation
  • fix concurrency for workers

@codecov
Copy link

codecov bot commented Jan 27, 2020

Codecov Report

Merging #211 into master will decrease coverage by 10.67%.
The diff coverage is 95.52%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #211       +/-   ##
===========================================
- Coverage    98.2%   87.53%   -10.68%     
===========================================
  Files           7        7               
  Lines         391      393        +2     
  Branches      157      152        -5     
===========================================
- Hits          384      344       -40     
- Misses          7       44       +37     
- Partials        0        5        +5
Impacted Files Coverage Δ
src/index.js 94.68% <94.94%> (-4.41%) ⬇️
src/TaskRunner.js 98.11% <97.14%> (+0.81%) ⬆️
src/Webpack5Cache.js 0% <0%> (-88.47%) ⬇️
src/minify.js 87.8% <0%> (-12.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de02f7b...2680f94. Read the comment docs.

if (this.cache.isEnabled()) {
return this.cache.get(task).then((data) => data, enqueue);
}
return enqueue(task);

Choose a reason for hiding this comment

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

I don't think plimit makes any guarantee about the order of execution of the enqueued functions. I think this means that enqueue(task) can be called in any order and therefore task.callback(taskResult) can be, too.

This seems like it has the potential to introduce non-determinism whenever parallelism is enabled. That is, if I run my webpack build twice, I expect it to produce the same outputs. This change seems to break that guarantee whenever extractComments is on since comment extraction depends on processing the results in a particular order.

It is important that this plugin is deterministic because nondeterministic builds needlessly invalidate long-term caches.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we need sort properties of allExtractedComments here https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/index.js#L509

Copy link
Member Author

Choose a reason for hiding this comment

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

I will fix it in near future

Copy link
Member Author

@alexander-akait alexander-akait Jan 29, 2020

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Ok, I think you're right. Since comments are sorted and then de-duped after being collected in allExtractedComments, I think the output is deterministic.

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.

Process aborts with 'out of memory' when using 2.0.0
2 participants