-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Modifying unpublished properties on a polymer element causes a lot of observe-js work #844
Comments
Comment by jmesserly Excellent reproduction! So I think this is caused by an interaction between This is going to be somewhat tricky, but I think we can come up with a solution somewhere across the observe-js/TemplateBinding/PolymerExpression layers. In principle, we should (somehow) be able to divide observed state into "inside the repeat" and "outside the repeat" and ensure we only create a single observer for each bit of "outside the repeat" state. It would be harder to replicate this issue with raw TemplateBinding as the "default binding syntax" doesn't look into parent scopes. But one way to do it would be a shared prototype among data items you're repeating over. Then mutate something on that shared prototype. Not sure how common that would be, but it seems possibly less pressing than the current issue. |
Comment by jmesserly So one quick idea: there's an optimization to skip most of the work if the property doesn't match the root object: googlearchive/observe-js@b229ed5 ... however it doesn't consider the prototype chain. This wouldn't really fix the problem (you'd still get O(N) pings for a big repeat), but it would bail out faster so it might help in practice. |
Comment by jmesserly this CL seems to fix the problem for me: googlearchive/observe-js#74 |
Comment by jmesserly after that change, we only call |
Comment by jmesserly btw, that fix wouldn't help cases like using a filter or a property from list-test in each item. For that we need something smarter. But maybe it helps in some common cases. |
Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect. |
Issue by kevinpschaaf
Thursday Sep 25, 2014 at 02:31 GMT
Originally opened as https://github.com/Polymer/polymer-dev/issues/101
Unexpected cost: Modifying any property on a polymer element (particularly an unobserved property) causes observe-js to do a ton of unexpected/extra work.
This was stumbled upon in the sample in the following gist, which was attempting to measure how often the browser sends scroll events while scrolling.
observe-test-a.html
appends text tothis.deltas
(instance property oflist-test
element) every scroll event, recording the time between scroll frames. Notethis.deltas
is not used by any bindings or otherwise explicitly published/observed. Inobserve-test-b.html
,deltas
is moved to a variable not on the element, and the observe-js work per event goes away, reducing the time between scroll events substantially (click the menu icon to see the deltas text in an overlay).https://gist.github.com/kevinpschaaf/b12d38796be25a0ce5fe
The text was updated successfully, but these errors were encountered: