Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable costly eventManager support when unused. #14756

Merged
merged 1 commit into from
Dec 25, 2016

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Dec 25, 2016

For every event that we observe (which is basically all bubbling events in the DOM) we would iterate the entire parentView structure of the target elements view looking for an eventManager (and then we would dispatch the event to the eventManager instead of the view itself).

This support has existed for a very long time, and is generally unused in most applications. Unfortunately, the iteration upwards through the view heirarchy is much more costly than we would like. This is currently being done for events like mouseenter and mousemove and that very very very few applications (if any) actually take advantage of this support.

This changes the EventDispatcher to (by default) disable support for eventManager's (and avoids the costly parentView iteration) until we actually instantiate a component that has an eventManager property.

In the future, we should deprecate specifying an eventManager, but this makes the feature much more "pay as you go".

Related to #14754

For every event that we observe (which is basically all bubbling events
in the DOM) we would iterate the entire `parentView` structure of the
target elements view looking for an `eventManager` (and then we would
dispatch the event to the `eventManager` instead of the view itself).

This support has existed for a *very* long time, and is generally
unused in most applications. Unfortunately, the iteration upwards through
the view heirarchy is much more costly than we would like. This is
currently being done for events like `mouseenter` and  `mousemove` and
that very very very few applications (if any) actually take advantage of
this support.

This changes the `EventDispatcher` to (by default) disable support for
`eventManager`'s (and avoids the costly `parentView` iteration) until
we actually instantiate a component that has an `eventManager` property.

In the future, we should deprecate specifying an `eventManager`, but this
makes the feature much more "pay as you go".
@rwjblue
Copy link
Member Author

rwjblue commented Dec 25, 2016

@GavinJoyce - Would you like to work on the deprecation RFC (we can use the same conditional to add the deprecation)?

@GavinJoyce
Copy link
Member

Nice one!

Would you like to work on the deprecation RFC (we can use the same conditional to add the deprecation)

Sure, I'll work on the RFC and deprecation

@rwjblue
Copy link
Member Author

rwjblue commented Dec 25, 2016

FYI - We have a couple of tests that confirm .eventManager support (here and here), so in general the original feature still works (without app changes required).

@rwjblue rwjblue merged commit 9b11b21 into emberjs:master Dec 25, 2016
@rwjblue rwjblue deleted the disable-event-manager-by-default branch December 25, 2016 16:07
@jonnii
Copy link

jonnii commented Dec 25, 2016

@rwjblue I'd have thought this would be a huge performance win, do you have any idea how big?

@rwjblue
Copy link
Member Author

rwjblue commented Dec 25, 2016

@jonnii - I agree it should have a nice perf win, but haven't really done any testing. Most of the benchmarks I've been running locally are specifically testing initial render or rerender performance, and those types of tests generally wouldn't benefit from this (AFAICT). I think the types of things that would benefit would be rerenders where many events are firing. I'd definitely be interested in some numbers if you happened to have a perf testing harness setup in this way...

Copy link
Contributor

@ef4 ef4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me.

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

Successfully merging this pull request may close these issues.

4 participants