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

[perf] Set all:false in stats.toJson call #708

Merged
merged 2 commits into from
Apr 5, 2021

Conversation

liuyenwei
Copy link
Contributor

Summary

I noticed while upgrading a codebase from webpack v4 -> v5 that there seemed to be a significant increase in incremental build times.

From a local profile, the time seemed to be spent on a stats.toJson call originating from the loadable webpack plugin
image

Updating the toJson call so that it specifies all: false improves the time spent on this call from 40seconds -> 55ms (for the specific codebase i tested on)
image

I checked this change against webpack 4 on our codebase and it also reduced the time spent from ~9s -> 500ms
image
image

Test plan

I tested this change locally against both a webpack 4 build and webpack 5 build and loadable worked as expected in both cases.

@theKashey
Copy link
Collaborator

🤯 , let me double-check the results and merge. Unfortunately, there are no real automated tests around stats json generation.

assets: true,
chunks: true,
chunkGroups: true,
errorDetails: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to keep these false options provided? Or does all: false set that as a default for anything not explicitly provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at https://github.com/webpack/webpack/blob/afc9b2fcf9bef0831640b3ebb02b73068ba18e17/lib/stats/DefaultStatsPresetPlugin.js#L132 and https://webpack.js.org/configuration/stats/#statsall, it doesn't seem so since all: false will basically default anything not set to false.

i opted for leaving these as-is since i was trying to make a minimal change here but happy to remove the unnecessary false options here

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it'd be clearer to just totally omit anything that isn't true, since the all: false covers all that. But I'll defer to the repo maintainers, I'm just taking a look since this PR will solve my issue too (#709) 😄

source: false,
errorDetails: false,
timings: false,
chunkGroups: true,
Copy link
Contributor Author

@liuyenwei liuyenwei Mar 6, 2021

Choose a reason for hiding this comment

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

Updated to:

@jdb8
Copy link
Contributor

jdb8 commented Mar 15, 2021

Looking good to me, but I'm not a maintainer - would love to see this merged to close #709 :)

@liuyenwei
Copy link
Contributor Author

@theKashey hey just wanted to check in and see if there was anything else I can/should do to help get this merged. Thanks!

@theKashey
Copy link
Collaborator

Just waiting for the Easter break to go through all changes

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.

3 participants