ember.js: Ember/V8: Slow EmberError constructor
I heard through the grapevine that error handling is very slow when using current V8 versions (e.g. 6.0).
Looking at the EmberError constructor [0], the main offender is probably the call to Error.captureStackTrace. captureStackTrace used to format the stack trace lazily on access to the stack property (like builtin error objects), but since about a year it formats traces eagerly. That could be fairly expensive, and would explain a sudden slowdown in error handling code. We’re looking into re-enabling lazy formatting in Error.captureStackTrace [1] soon.
I also noticed that each call to the EmberError constructor collects the stack trace three times:
- In the call to
super() - In the explicit
Error.call(this, message) - In
Error.captureStackTrace.
Maybe it’d be possible to avoid some of this useless work? In current V8 versions, it should be enough to just call super(message) - this will also filter to relevant frames (as Error.captureStackTrace does).
[0] https://github.com/emberjs/ember.js/blob/094740737771895e154e8ed2c35ed09fa63b0baa/packages/ember-debug/lib/error.js#L32 [1] https://crbug.com/v8/5962
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 15 (12 by maintainers)
Commits related to this issue
- [BUGFIX beta] remove Error.captureStackTrace We only do this for stack cosmetic reasons, it really just removes 1 or so frames, but apparently more recently at a hefty cost: context: https://git... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX beta] remove Error.captureStackTrace We only do this for stack cosmetic reasons, it really just removes 1 or so frames, but apparently more recently at a hefty cost: context: https://git... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX beta] remove Error.captureStackTrace We only do this for stack cosmetic reasons, it really just removes 1 or so frames, but apparently more recently at a hefty cost: context: https://git... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX release] Fix Ember.Error inheritance As pointed out by @schuay https://github.com/emberjs/ember.js/issues/15516 our error constructor essentially calls super twice. The reasons seems to have ... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX release] Fix Ember.Error inheritance As pointed out by @schuay https://github.com/emberjs/ember.js/issues/15516 our error constructor essentially calls super twice. The reasons seems to have ... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX release] Fix Ember.Error inheritance As pointed out by @schuay https://github.com/emberjs/ember.js/issues/15516 our error constructor essentially calls super twice. The reasons seems to have ... — committed to emberjs/ember.js by stefanpenner 7 years ago
- [BUGFIX release] remove Error.captureStackTrace We only do this for stack cosmetic reasons, it really just removes 1 or so frames, but apparently more recently at a hefty cost: context: https://gith... — committed to emberjs/ember.js by stefanpenner 7 years ago
By the way,
Error.captureStackTracenow formats lazily again: https://chromium-review.googlesource.com/c/574530/