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

Don't abuse timers #1108

Merged
merged 1 commit into from
Dec 18, 2019
Merged

Don't abuse timers #1108

merged 1 commit into from
Dec 18, 2019

Conversation

chancancode
Copy link
Member

@chancancode chancancode commented Dec 18, 2019

Previously, the object inspector would schedule an infinite timer that fires every 300ms to update the current object (it actually fires even where there isn't a current object to update). This is extremely inefficient, and it causes a lot of extra work in big apps, since the timer starts a runloop which results in a full top-down revalidation. The more appropriate thing to do is tap into the runloop callbacks, since as far as Ember is concerned, if there are no runloops, there are no observable changes.

Split from #1088. I'll rebase that PR once this lands.

@RobbieTheWagner
Copy link
Member

@chancancode to clarify, there was not a 300ms timer that fired infinitely. Updates were fired when the render event was fired and there was a 300ms debounce.

@chancancode
Copy link
Member Author

@rwwagner90 This is unrelated to how we update the render tree. This is just how we update the currently inspected object. When you call updateCurrentObject (which we always do in init as of now), at the end of the method, it will always unconditionally (even when there isn’t a current object) schedule a setTimeout that calls itself again, run-wrapped, which will then schedule another timer, etc. Worse, i think it’s actually possible to call this method multiple times and end up with a set of 300ms infinitely repeating timers.

@chancancode
Copy link
Member Author

chancancode commented Dec 18, 2019

This conflicts with #1106 (logically, at least), so whichever is merged first, the other one will require a manual rebase. This should be merged before #1106.

@chancancode chancancode added octane and removed octane labels Dec 18, 2019
@chancancode chancancode added this to the 3.13.0 milestone Dec 18, 2019
@wycats
Copy link
Member

wycats commented Dec 18, 2019

Awesome! Really good work.

@wycats wycats self-requested a review December 18, 2019 20:14
Previously, the object inspector would schedule an infinite timer
that fires every 300ms to update the current object (it actually
fires even where there isn't a current object to update). This is
extremely inefficient, and it causes a lot of extra work in big
apps, since the timer starts a runloop which results in a full
top-down revalidation. The more appropriate thing to do is tap
into the runloop callbacks, since as far as Ember is concerned,
if there are no runloops, there are no observable changes.
import { typeOf } from './utils/type-check';

const Ember = window.Ember;
const {
Object: EmberObject, inspect: emberInspect, meta: emberMeta,
computed, get, set, guidFor, isNone,
cacheFor, VERSION
cacheFor, VERSION, run,
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for not nesting this!

@chancancode chancancode merged commit 74a6705 into master Dec 18, 2019
@delete-merged-branch delete-merged-branch bot deleted the no-timers branch December 18, 2019 20:41
nummi pushed a commit to nummi/ember-inspector that referenced this pull request Apr 1, 2020
Previously, the object inspector would schedule an infinite timer
that fires every 300ms to update the current object (it actually
fires even where there isn't a current object to update). This is
extremely inefficient, and it causes a lot of extra work in big
apps, since the timer starts a runloop which results in a full
top-down revalidation. The more appropriate thing to do is tap
into the runloop callbacks, since as far as Ember is concerned,
if there are no runloops, there are no observable changes.
nummi pushed a commit to nummi/ember-inspector that referenced this pull request Apr 5, 2020
Previously, the object inspector would schedule an infinite timer
that fires every 300ms to update the current object (it actually
fires even where there isn't a current object to update). This is
extremely inefficient, and it causes a lot of extra work in big
apps, since the timer starts a runloop which results in a full
top-down revalidation. The more appropriate thing to do is tap
into the runloop callbacks, since as far as Ember is concerned,
if there are no runloops, there are no observable changes.
patricklx pushed a commit to patricklx/ember-inspector that referenced this pull request Sep 19, 2022
Previously, the object inspector would schedule an infinite timer
that fires every 300ms to update the current object (it actually
fires even where there isn't a current object to update). This is
extremely inefficient, and it causes a lot of extra work in big
apps, since the timer starts a runloop which results in a full
top-down revalidation. The more appropriate thing to do is tap
into the runloop callbacks, since as far as Ember is concerned,
if there are no runloops, there are no observable changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants