Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

WTF_ISSUE_555 loop garbage collection / unfunctional #1244

Closed
sod opened this issue Jun 21, 2019 · 6 comments
Closed

WTF_ISSUE_555 loop garbage collection / unfunctional #1244

sod opened this issue Jun 21, 2019 · 6 comments

Comments

@sod
Copy link

sod commented Jun 21, 2019

Profiling our page and improving perf I stumbled over zone.js that creates a hefty amount of GC pressure and CPU time.

In particular this method eventTargetLegacyPatch:
image

That red bar inside that function is 50% of the load time of zone.js.

Looking in a debugger ... what is that even supposed to do? :D

image

So it takes the length of the string WTF_ISSUE_555, that is a loop of 425 iterations (because the string is 425 characters long) but then uses the index on the array WTF_ISSUE_555_ARRAY that only has 64 elements. And it has an inner loop with 218 elements, so that doubleloop creates 92625 strings and writes/overwrites them into the target object. And that then hold items like abort: "undefined.addEventListener:abort.

This can't be right, is it? :)

Seems like that loop was introduced in b3a76d3

zone.js version 0.9.1, inside zone.js/dist/zone.js line 2766 to 2773

@JiaLiPassion
Copy link
Collaborator

@sod, thanks for posting the issue, this has been fixed by #1102, but never get chance to be merged, I will ask the author to rebase or I can fix this again.

@sod
Copy link
Author

sod commented Jun 21, 2019

well, that typo creates twice the amount of memory garbage (12 MB) then an entire vue.js app I wrote.

@JiaLiPassion
Copy link
Collaborator

We will fix this one ASAP, thanks for the waiting.

@JiaLiPassion
Copy link
Collaborator

And if you are targeting only the evergreen browsers, you can use zone-evergreen.js.

@sod
Copy link
Author

sod commented Jun 28, 2019

The documentation is false regarding loading zone-evergreen and zone-legacy seperatly on https://github.com/angular/zone.js/blob/master/README.md. The documentation states

zone-legacy.js [...] This bundle must be loaded after zone-evergreen.js, zone.js=zone-evergreen.js + zone-legacy.js

It's exactly the other way around. zone-legacy writes a function into _global['__zone_symbol__legacyPatch'] that zone-everygreen calls. That is very nice, because one can just shove it into the legacy polyfill bundle ... just saying :D

@JiaLiPassion
Copy link
Collaborator

This should be fixed by angular/angular#31208

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants