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:

  1. In the call to super()
  2. In the explicit Error.call(this, message)
  3. 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

cc @hashseed, @bmeurer, @stefanpenner

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

By the way, Error.captureStackTrace now formats lazily again: https://chromium-review.googlesource.com/c/574530/