-
Notifications
You must be signed in to change notification settings - Fork 408
ZoneAwareError is 15-20x slower than native, should lazy-evaluate "stack" #975
Comments
@mleibman , so your requirement is
|
I can use the native error as a workaround, though there doesn't seem to be a formal way of getting it ( Ideally, the zone patched one should not incur any additional overhead in the constructor, and do all its work on demand in the |
|
1 & 2 aren't really an option for me. But it seems that we can still have our cake and eat it too. I may be reading the code wrong, but there doesn't seem to be anything in the Also, is there a better way to access the native |
yes, we can keep the to access |
If you capture the The reason I'm asking about the proper way to access the native UPDATE: Sorry, I missed the |
@mleibman , yes, the And about the |
Thanks! |
Getting a stack trace can be an expensive operation, and both Firefox and Chrome/V8 (haven't checked IE/Edge) optimize it by formatting the unstructured stack trace of an error on demand, the first time the
stack
property is accessed (https://github.com/v8/v8/wiki/Stack-Trace-API#customizing-stack-traces).When building instrumentation tooling, I use this to minimize the overhead of capturing the stack trace using
new Error()
and then evaluate itsstack
property if and when needed. Unfortunately,ZoneAwareError
does the trace evaluation and formatting in its constructor, so it ends up a lot slower, both from invoking the native error's formatting, and Zone.js's own overhead. I have also noticed it resulting in increased memory pressure, leading to more frequent GC pauses:(The first half is running
new NativeError()
, the second is runningnew Error()
.)Benchmark demonstrating the issue - https://jsperf.com/zoneawareerror.
Note that this runs the benchmark with an unrealistically shallow call stack. The real life impact in a complex application is likely to be more pronounced.
Is it possible to make it evaluate and rewrite the
stack
on demand?The text was updated successfully, but these errors were encountered: