-
Notifications
You must be signed in to change notification settings - Fork 25.9k
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
AoT uses a lot more resources in browser than JiT #12253
Comments
You can reduce the size of the bundle:
How large is your app? What 3rd party libs do u use? Can u post a link to a github repo? |
@DzmitryShylovich Thanks. I don't think I could make the app public. If you tell me how you would measure app size I'd be happy to provide a metric.
|
Have a look at https://github.com/qdouble/angular-webpack2-starter Discussion: qdouble/angular-webpack-starter#111 |
side note : with AoT you don't need reflect-metadata nor core-js implementation of it |
@ericmartinezr interesting; why is that? |
The AOT bundle contains all the code generated by the JIT. So I would expect that the AOT build is larger than the JIT, if the Application is large enough. But without your application, it's hard to tell if I would expect 500KB in your case. |
Using Windows CPU profiler is a pretty poor metric for anything related to JS, as you're measuring what the browser itself is doing, not what code running within it is doing. I'd suggest doing some tracing with Chrome's developer tools - https://developers.google.com/web/tools/chrome-devtools/rendering-tools/js-execution - this would give us all a much better picture of what's actually occurring in your application. You can export and share the trace from devtools, and link it here. |
Did you take a peek into the bundle to make sure it only contains expected modules? There is a section in the AoT article about this. |
@thelgevold the AoT and JiT packages are the exact same app, just built differently. @robwormald Thanks for the tip. Hopefully the info below will help guide the discussion. I've been running more tests. The issue (AoT app requiring much more CPU work than JiT) occurs both on How I collected the data:
The screenshots below are from Firefox, while the browser is sitting idle.
I'm attaching a zip file with four files:
To inspect the data, you can import these files into dev tools from the Interestingly, as soon as I minimize the browser window, CPU usage goes back down to JiT-compiled levels. Once I return focus to the window, usage goes up again. |
This has to do with |
Closing: See this issue |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
When I use the Ahead-of-Time compiler --
ngc
-- along withrollup.js
to build my app, it consumes a lot more CPU cycles in the browser than Just-in-Time. The resulting bundle is also significantly larger.Expected behavior
AoT with tree-shaking to result in a smaller, less resource-hungry application. I was so shocked by my observation that I've re-run the tests below over a dozen times now.
Minimal reproduction of the problem with instructions
Firefox 49 32bit
onWindows 7 x64
),The AoT build is more resource hungry. In addition, its JS bundle (which has been minified and tree-shaken with
rollup
) is about 500KB larger than its JiT compiled counterpart.AoT compiled bundle +
vendor.js
(made up ofcore-js
,reflect-metadata
andzone.js
):AoT CPU and IO operations starting 5 seconds before I load the app, extending for 1 minute:
The app was optimized following the directions from the docs. I've also tried bundling the AoT build with
SystemJS-builder
, and avoidRollup.js
altogether, but the performance differential remained.Now checkout the same exact app using in-browser, Just-in-Time compilation. The templates and styles have been inlined and all the JS bundled into one minified file using
SystemJS-builder
'sbuildStatic
JiT compiled bundle is about 500KB lighter than the AoT tree-shaken minified bundle, even though the former includes
core-js
,reflect-metadata
andzone.js
!JiT CPU and IO operations starting 5 seconds before I load the app, extending for 1 minute:
Can anyone replicate this? If not, how can I find out why it's happening to my app?
What is the motivation / use case for changing the behavior?
I'd like to use AoT builds, and although they load faster, their latent power consumption makes them a non-starter.
Please tell us about your environment:
Firefox 49 32bit
,Angular 2.0.1
,ng2 compiler-cli 0.6.3
,node 4.5.0
,Windows 7 x64
The text was updated successfully, but these errors were encountered: