Repository navigation
perf(aio): improve unit test rebuild time - #16250
Conversation
There was a problem hiding this comment.
True but harmless and has the virtue of making it easy to inspect if you have all of the @angular libraries you want when you inspect/extend this list.
There was a problem hiding this comment.
Yeah I'm on the fence regarding this one. I defer to you.
There was a problem hiding this comment.
I don't get it 😕 How does it help to have @angular/platform-browser-dynamic listed twice?
There was a problem hiding this comment.
Just to be clear, I am referring to the fact that there is the exact same import (import '@angular/platform-browser-dynamic';) a few lines below.
There was a problem hiding this comment.
Oh that's a mistake!
There was a problem hiding this comment.
Do we need to import stuff that we don't use? Does it noticeably affect re-build time?
There was a problem hiding this comment.
I'd rather have them all if it doesn't harm build times, just so I don't forget to add it later. Filipe's (internal) numbers show that the initial build time (the only build time that could be affected) is unchanged from the pre-PR figure.
There was a problem hiding this comment.
We don't need to, no. Will try to trim it down.
There was a problem hiding this comment.
OOC, why does this help with rebuild times?
There was a problem hiding this comment.
@gkalpak In a side conversation with the PR author he said
it bundles each spec separately so it should provide better performance by only rebuilding the specs that really need it.
And so it does.
The trick of gathering the spec files in a separate file (test-specs.ts) and then importing that here in test.ts seems weird but is essential magic.
There was a problem hiding this comment.
So what happens in webpack is that rebuilding chunks is fast in and of itself. But if anything changes on a given chunk, sourcemaps are rebuilt and that takes a long time.
This is why often builds stay on 92% optimizing assets and why turning off sourcemaps makes it faster.
What this tweak does is force webpack to make a separate, lazy chunk for all the spec files and dependencies. But we also list dependencies manually, so they don't get duplicated. This way, when sourcemaps are recalculated, it's super fast because it's not doing the vendor libs.
We do this another way in normal builds, but karma webpack does not support the other approach (using CommonsChunkPlugin, codymikol/karma-webpack#22).
There was a problem hiding this comment.
But sourcemaps are already disabled in yarn test, so this shouldn't be the reason for slowness. Does this change mean that we could re-enable sourcemaps in yarn test with minimal overhead?
There was a problem hiding this comment.
I hadn't noticed they were turned off there. You're right, they can now be turned on with little to no overhead.
There was a problem hiding this comment.
Amended the PR to also remove the disabled sourcemaps.
|
The angular.io preview for 8dd4ff619b71de39fa42f372c8ec1cd6b2ee54cb is available here. |
wardbell
left a comment
There was a problem hiding this comment.
EXCELLENT! Palpably improves dev/test cycle time.
I know you used an internal tool to measure those build times. Wish we could see them too.
Reader's note: this PR improves build time. It does not affect the time it takes for the tests themselves to run.
Approved with enthusiasm.
p.s. The currently failing e2e test is unrelated.
55af12d to
6407ef6
Compare
|
The angular.io preview for 55af12d8ff2c508a41623d5504f602d63e27ca6c is available here. |
|
The angular.io preview for 6407ef6b72db6d04988c417ad60d31ec8cb2c0e2 is available here. |
|
Also just tested this against an Angular CLI project with around ~400 tests and it's really helped the rebuilds. They're not getting stuck on 92% anymore for a couple of seconds for me |
6407ef6 to
6e5d7d1
Compare
|
just checking that the e2e test failure was a flake before landing. |
|
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. |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
Rebuild times for AIO unit test are somewhat slow currently: 15.809s (initial), 10.015s, 9.764s, 10.728s, 11.957s.
What is the new behavior?
This PR improves rebuild times: 16.551s (initial), 0.972s, 1.505s, 0.992s, 0.826s.
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
/cc @wardbell