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

Production build is really slow. #51

Closed
zicsus opened this issue Apr 15, 2021 · 19 comments · Fixed by #55
Closed

Production build is really slow. #51

zicsus opened this issue Apr 15, 2021 · 19 comments · Fixed by #55
Milestone

Comments

@zicsus
Copy link
Collaborator

zicsus commented Apr 15, 2021

Describe the bug
Production build of scripts is really slow without any significant reason.

To Reproduce
npm run build

Expected behavior
I think than production build should go faster than current speed. There is not generation of source map or anything just same compilation as development with some minification. is the minifaction the issue?
When I just used webpack for compiling, the speeds were significantly faster than current time even when source maps where generated with minifcation.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 16, 2021

@nkrusch any ideas?

@nkrusch
Copy link
Contributor

nkrusch commented Apr 16, 2021

@zicsus are you using the latest alpha?

If you downgrade does it continue or no?

Also try 1.0.3-alpha.1 let me know if you are seeing same behavior.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 16, 2021

@nkrusch I'm not sure if this problem is recent or old because I noticed when I started compiling large projects. I will take look at latest alpha and let you know.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 16, 2021

I have two thoughts which I have been thinking about to address this type of issues:

  1. Create integration (or system?) tests to test against different configurations to make it easier to identify issues. I mean having various sample project w/ configs and using it to drive the CLI and then check that output is what was expected.

  2. secondly benchmark those tests and develop some data around how long it takes to run different configurations and detect degradation, if it happens.

I'm thinking running on tags using CI.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 16, 2021

It persists in latest alpha 1.0.3-alpha.1. I'm also getting warning like this-
Capture

The weird part is that development build does not have this warning. Something related to production is causing this.
We also need to take a look at development builds because they are slower than normal webpack setups.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 16, 2021

Try viewing what is being included in capture.js 6e4035c6674b924a9ff0.js after it builds vs. what should be in included per configs. It seems like it is slow and showing this warning because the generated file is so large.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 16, 2021

@nkrusch capture.js includes some third party (3 packages to be precise) includes but nothing out of ordinary. Even if I remove capture.js, it is still slow build time.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 16, 2021

next options:

  • is it specifically building javascript that is slow, or some other build step(s)? It runs steps sequentially and you can observe the delays of each step in the output. Also compare between dev build to compare differences in timing to say which step(s) in the build are slow.

  • backtrack the CLI version to see at which point it becomes slow to identify when the change occurred

  • (there are many dependencies) if you identify the lag is with building scripts specifically, I would also check if using different versions of webpack-stream makes any difference.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 17, 2021

I don't know if you have had a chance to test this further? I am now wondering how much this impacts the build time especially since it sounds like the issues is with prod and not dev:

const webpackOptions = { mode: isProd ? "production" : "development" };

It is the only difference between the two.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 17, 2021

I haven't tested it yet. Webpack might be doing some extra optimations in production mode but its there suggested way. I wonder why it's making so much difference.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 26, 2021

According to this page- https://webpack.js.org/configuration/mode/ changing mode to production brings some additional optimizations.
Files are breaking when doing a production build. I'll remove mode for now.
I also found another solution where we need to just increase the asset size but I'm not sure how practical that would be without custom webpack configs.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 26, 2021

I was assuming that. If you try building locally, either specifying no mode or dev mode, does that makes any difference in the build time? Trying to figure out the cause of the latency. If it makes no difference then the cause is somewhere else.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 26, 2021

Just tested it and setting mode to development (permanently) and making devtool: none gives really fast build times in production. I will keep devtool: cheap-source-map for development.
Creating a PR in some time.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 26, 2021

Here you go- #54

Can you make a release for this?

@nkrusch
Copy link
Contributor

nkrusch commented Apr 27, 2021

First, great that this explains the cause!

webpack dev mode does not minifying the source. I believe it concatenates the files. It would explains why 3rd party files build fast.

The flip-side is it does not minify js files in cases where that *is* the desired behavior.

How about best of both worlds and make the mode configurable?

I'm thinking:

  {
    "name": "content_script",
    "src": "./src/*.js",
    "mode": "development"
  }

when the use case is to always use specific mode. If not specified, default to --env flag.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 27, 2021

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 27, 2021

You're good to go. Ignore my comment on the PR. After thinking for a while I think that it can be really useful.

@nkrusch
Copy link
Contributor

nkrusch commented Apr 27, 2021

Let me know if the latest alpha resolves this issue? If yes, I will roll out a patch and we can close this.

@zicsus
Copy link
Collaborator Author

zicsus commented Apr 27, 2021

Yup! you can proceed.

@nkrusch nkrusch added this to the 1.0.3 milestone Apr 27, 2021
@nkrusch nkrusch linked a pull request Apr 27, 2021 that will close this issue
@nkrusch nkrusch closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants