I'm running Angular 13 and am completely stuck with why the performance is so bad on the server. I'm looking for any help on diagnosing the issue here.
What's really strange to me is that it's clearly not the API calls / resolvers. Adding in some console.time commands, I get this output:
Jul 20 23:12:28: Request Received --> Resolvers Started: 12.489ms
Jul 20 23:12:28: Resolver 1 Complete: 11.716ms
Jul 20 23:12:28: Resolver 2 Complete: 16.857ms
Jul 20 23:12:28: Resolver 3 Complete: 23.766ms
Jul 20 23:12:28: Request Received --> Page Component Constructed: 47.235ms
Jul 20 23:12:28: All Resolvers Complete: 41.516ms
Jul 20 23:12:28: Resolvers Complete --> Page AfterViewInit: 33.892ms
Jul 20 23:12:28: Request Received --> Page AfterViewInit: 89.313ms
Jul 20 23:12:28: Request Received --> First Page Application Stable: 20.806ms
Jul 20 23:12:28: First Page Application Stable --> Second Page Application Stable: 92.933ms
Jul 20 23:12:29: Requested Received --> Line before res.send HTML: 609.946ms
I am completely stuck... It's like there's a phantom 500ms just sitting somewhere in there.
At this point, I've ruled out everything I can think of. There are no setInterval or setTimeout in the code. There's no mouse position or anything.
So I guess what I'm asking for is... is there any way to profile Angular Universal?
Edit:
I've started digging more and more into this. One function I've found that's particularly problematic:
function walkStyleRules(node, iterator) {
const startWalk = Date.now();
node.nodes = node.nodes.filter(rule2 => (hasNestedRules(rule2) && walkStyleRules(rule2, iterator), rule2._other = void 0, rule2.filterSelectors = filterSelectors, !1 !== iterator(rule2)));
const finishTime = Date.now() - startWalk;
if (finishTime > 100) {
console.log('Boom');
}
}
This function seems to be responsible for at least 100ms of the 500ms delay, and doesn't seem to have any obvious purpose (commenting it out and the application still runs just fine).
Certainly not a smoking gun... but still, nice to have made some progress, I guess?