Open JiaLiPassion opened 6 years ago
How big is the performance improvement impact here? If it is not substantial, I would vote against this change. Alternatively, could this be configurable?
The reason I ask is that this change would break a lot of our code without a way to fix it other than maintaining a local modified version of Zone.js.
We (GCP Console, i.e. https://console.cloud.google.com) use Zone.js for latency instrumentation and rely on monkey-patching Zone.prototype.[runTask|scheduleTask|cancelTask] to track all executed tasks regardless of which zone they run in. If I understand this change correctly, this PR would prevent us from being able to track tasks executed in the root zone.
This is a new way to improve
root zone
performance and reducemonkey-patch
impact inspired by @mhevery.Zone.current
isrootZone(Zone.root)
, we will usenative delegate (with a very small wrap)
instead ofmonkey patched version
.For example: After loading
zone.js
, we call someasync operations
. For example, in web page, we haveAngular Elements
andJquery
, the following code will be thejquery part
.Zone.root.run
in other zone to use thenative delegate
version.Now the
monkey-patch
method will look like this. For example, forsetTimeout
.@mhevery, @robwormald, please review, thank you!