-
Notifications
You must be signed in to change notification settings - Fork 168
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
Development Mode Performance Regression 14.x vs 19 #10281
Comments
@pleku well-meaning ping because I think this is a huge regression (300%) and results in a really bad DX |
@knoobie this has been discussed internally but there is no conclusion yet. We're tracking the cold/warm build times internally too but this was noticed there only when the final release was done (as apparently it cannot be done reliably with prereleases). One performance test we have for webpack build is still having the same threshold of 11s (or so) since 3.0. It was sort of ruled out already that the change should not be caused, at least entirely, by switching to use I think it is up for @vlukashov and @mstahv to agree who starts to take a look at this and when. I don't know if this can be "fixed" or if we need to rework the whole build like we've tried to do with investigating webpack 5 module federation (didn't work for web component / polymer reasons) or Snowpack. Personally I would like to get rid off compiling things that are not changed as those are slowing down every single build we have but that might be pointless if there is a better alternative. Personally I also feel we would benefit from having dedicated team for the frontend build, but that is still just a personal opinion for now. It has been already known that since 3.0+ the fusion introduced changes (like TS compilation that occurs with Flow Lit templates too) makes things slower vaadin/hilla#331 and the issue has some pointers what to look at, but the impact there was from 5s -> 10s. |
@pleku thanks for your valuable feedback and insights! I try to make some more tests the next days with other versions / less features and see if I can narrow down the issue a bit.
That would probably help a lot with recurring builds! Sadly webpack is a total Blackbox for me so I can't really help on this part.. |
I tested this using the production build as follows for run in `seq 1 3`; do rm -rf v14 && npx @vaadin/cli init v14 && cd v14 && mvn install -Pproduction > ../v14-run-$run && cd .. ; done
for run in `seq 1 3`; do rm -rf v19 && npx @vaadin/cli init --latest v19 && cd v19 && mvn install -Pproduction > ../v19-run-$run && cd .. ; done The result is $ grep "Total time" v14-run-*
v14-run-1:[INFO] Total time: 01:05 min
v14-run-2:[INFO] Total time: 01:10 min
v14-run-3:[INFO] Total time: 01:05 min $ grep "Total time" v19-run-*
v19-run-1:[INFO] Total time: 01:01 min
v19-run-2:[INFO] Total time: 59.422 s
v19-run-3:[INFO] Total time: 57.877 s So is this related to my machine vs your machine or production vs development mode? |
@Artur- I haven't checked the production build time because it runs on our CI server. I tested the development mode because that's what a developer is running locally most of the time. |
Both matter, but the development mode build time is much more important. |
@Artur- I run the production build with the following result: v14: 16 seconds Environment: Lenovo T470s with Ubuntu LTS (3 year old business laptop) |
Tried the same on a Windows desktop Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 3401 Mhz, 4 Core(s), 8 Logical Processor(s) When run on an old HDD
when run on an SSD
|
@Artur- did you run production mode or development mode? |
This was the same If I run only webpack in the generated projects, then I see a difference (this time on a Mac):
|
Created two screen casts of my runs - both builds happened with no V14: v19: |
I was able to reproduce and can confirm the issue. The frontend build time in v19 has increased 3.5x - 4x compared to that in v14.5.
Projects: v14.zip, v16.zip, v17.zip, v18.zip, v19.zip. Why it was not detected by an automatic regression test nor noticed by one of Vaadin developers is another question, but let's focus at fixing the build time regression here. I could speculate, without having done a proper research, that the time increase could be due to (i) adding TypeScript compilation in V15 and (ii) adding Service Worker generation in V19. These are assumptions which need validation. In Flow apps both TypeScript and Service Worker support bring little value, and the build time increase would be hard to justify if it is indeed due to adding these 2 features. |
Did some preliminary experiments, found that the client-side bootstrapping and service worker has a significant impact on the performance, the impact of theme is not that significant. On my Mac Laptop:
|
Next step is make a 2 day time-boxed research to identify the root causes and possible solutions. |
I researched for the performance improvement ideas using the https://github.com/stephencookdev/speed-measure-webpack-plugin when running The starting numbers
ImprovementsRecommend: using
|
Some findings from my testing after the
After adding |
The webpack dev build performance was improved by these two PRs:
|
@Haprog Do did you run the tests like @vlukashov did above? Would be nice to see what level of improvements we got and how the situation is now compared to V14. |
@mstahv I ran tests similar to @platosha above basically running a development mode build of webpack only (trying to simulate what webpack does when you run the app with Here's a spreadsheet (with some interesting bits highlighted) where I recorded some of the numbers when I was testing these changes on my work laptop running on Linux. For V14 tests I had to do some minor manual fix in webpack config to prevent it from doing transpilation that doesn't normally happen in development mode (since giving dev mode flag to webpack wasn't enough for that). When manually running All tests ran several times and ignored 1 or 2 first runs which where slower (so assuming populated node_modules etc). |
Webpack dev mode build on master still takes around 74% more time (on my laptop) compared to what it takes on V14.6 (it was 277% more before the fixes). Webpack part of the build probably can't be optimized much more (without removing features) unless we move away from webpack and implement the same features using some other frontend tooling (e.g. esbuild) if possible (and probably requiring a large effort).
I'm not sure if somebody has tried to look into what other parts in the maven build have become slower. I've been mainly looking at the frontend build. EDIT: I just realized that the "Started webpack-dev-server. Time: {}ms" actually only measures time from the start of webpack-dev-server (which makes sense) so the difference here is probably just due to method of benchmarking/timing because running webpack dev build is not exactly the same as running |
Also did some comparison using
comparing between V14.6 and V19 this time seems to be only about 0.1s slower on V19 so it indeed seems that the dev server (probably just |
@knoobie there was another fix for this performance ticket which I updated the description of the ticket. That one actually has a more significant impact on the frontend build time. |
@haijian-vaadin Thanks! Haven't noticed the other PR. Looks like my laptop got a little bit faster (20 vs 13 sec) with nothing else open, but still way behind v14 for me. Same applications as last time, just changed the pom version to 14.5.3 and 19.0.6: V14.4.9 V14.5.3 v19.0.3 v19.0.6 |
@knoobie thanks for sharing, good to see that it helps with the performance, we may need to do another round of performance tuning since the difference is still significant compare with v14. |
Update:
Further investigation #10281 (comment)
Original Ticket:
Description of the bug / feature
Starting an application (v19) with
mvn
downloaded from start.vaadin.com takes a lot more time than the same application with v14. On my machine 3x slower..Minimal reproducible example
V14 Example
mvn
Example attached: my-app(1).zip
V19 Example
mvn
Example attached: my-app(2).zip
Expected behavior
Both application have the same starting time.
Actual behavior
v14 - 7 sec webpack execution
v19 - 21 sec webpack execution (and a lot of unrelated logging)
Versions:
The text was updated successfully, but these errors were encountered: