|
|
DescriptionImageResource: remove unnecessary vector copying during iteration.
Iterations that don't update the underlying collection, can be done
in-place.
R=
BUG=
Committed: https://crrev.com/af6993cee55aaf307b3f73e4e0ca5f05aa0413f4
Cr-Commit-Position: refs/heads/master@{#437482}
Patch Set 1 #Patch Set 2 : remove redundant hash table lookups #Patch Set 3 : add comments #
Total comments: 2
Patch Set 4 : add comment #
Messages
Total messages: 48 (21 generated)
The CQ bit was checked by sigbjornf@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by sigbjornf@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
sigbjornf@opera.com changed reviewers: + hiroshige@chromium.org, tkent@chromium.org
please take a look. I've been trying to understand these asVector() uses for a while, but have failed -- no particular reason to have these, right?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
tkent@chromium.org changed reviewers: + yhirano@chromium.org
+yhirano On 2016/12/07 at 09:11:42, sigbjornf wrote: > I've been trying to understand these asVector() uses for a while, but have failed -- no particular reason to have these, right? It looks safe to remove asVector() with the current ImageResourceObserver implementations. However, an ImageResourceObserver implementation might break the assumption in the future. The defensive copy isn't bad. I'd like to entrust this to an owner of core/fetch.
On 2016/12/07 23:38:43, tkent wrote: > +yhirano > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > I've been trying to understand these asVector() uses for a while, but have > failed -- no particular reason to have these, right? > > It looks safe to remove asVector() with the current ImageResourceObserver > implementations. However, an ImageResourceObserver implementation might break > the assumption in the future. The defensive copy isn't bad. I'd like to > entrust this to an owner of core/fetch. We copy a collection before iterating-and-calling a method on the collection because the method may mutate the collection (especially via addClient / removeClient / addObserver / removeObserver).
On 2016/12/08 01:59:49, yhirano wrote: > On 2016/12/07 23:38:43, tkent wrote: > > +yhirano > > > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > > I've been trying to understand these asVector() uses for a while, but have > > failed -- no particular reason to have these, right? > > > > It looks safe to remove asVector() with the current ImageResourceObserver > > implementations. However, an ImageResourceObserver implementation might break > > the assumption in the future. The defensive copy isn't bad. I'd like to > > entrust this to an owner of core/fetch. > > We copy a collection before iterating-and-calling a method on the collection > because the method may mutate the collection (especially via addClient / > removeClient / addObserver / removeObserver). Sure, and checkModifications() on HashTable iterators catch when that doesn't hold. Which of the predicates in these loops perform side-effects?
On 2016/12/08 06:30:50, sof wrote: > On 2016/12/08 01:59:49, yhirano wrote: > > On 2016/12/07 23:38:43, tkent wrote: > > > +yhirano > > > > > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > > > I've been trying to understand these asVector() uses for a while, but have > > > failed -- no particular reason to have these, right? > > > > > > It looks safe to remove asVector() with the current ImageResourceObserver > > > implementations. However, an ImageResourceObserver implementation might > break > > > the assumption in the future. The defensive copy isn't bad. I'd like to > > > entrust this to an owner of core/fetch. > > > > We copy a collection before iterating-and-calling a method on the collection > > because the method may mutate the collection (especially via addClient / > > removeClient / addObserver / removeObserver). > > Sure, and checkModifications() on HashTable iterators catch when that doesn't > hold. Which of the predicates in these loops perform side-effects? I didn't know checkModifications(), thanks. Currently I don't understand all ImageResourceObserver subclasses implementations, but it might make sense to forbid addObserver / removeObserver in some functions. If we do so, such restrictions must be explicitly stated in ImageResourceObserver.h.
On 2016/12/08 06:50:05, yhirano wrote: > On 2016/12/08 06:30:50, sof wrote: > > On 2016/12/08 01:59:49, yhirano wrote: > > > On 2016/12/07 23:38:43, tkent wrote: > > > > +yhirano > > > > > > > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > > > > I've been trying to understand these asVector() uses for a while, but > have > > > > failed -- no particular reason to have these, right? > > > > > > > > It looks safe to remove asVector() with the current ImageResourceObserver > > > > implementations. However, an ImageResourceObserver implementation might > > break > > > > the assumption in the future. The defensive copy isn't bad. I'd like to > > > > entrust this to an owner of core/fetch. > > > > > > We copy a collection before iterating-and-calling a method on the collection > > > because the method may mutate the collection (especially via addClient / > > > removeClient / addObserver / removeObserver). > > > > Sure, and checkModifications() on HashTable iterators catch when that doesn't > > hold. Which of the predicates in these loops perform side-effects? > > I didn't know checkModifications(), thanks. Currently I don't understand all > ImageResourceObserver subclasses implementations, but it might make sense to > forbid addObserver / removeObserver in some functions. If we do so, such > restrictions must be explicitly stated in ImageResourceObserver.h. While such a clarification is separately worthwhile, the copying that this CL removes, is redundant and overly defensive.
On 2016/12/08 07:09:59, sof wrote: > On 2016/12/08 06:50:05, yhirano wrote: > > On 2016/12/08 06:30:50, sof wrote: > > > On 2016/12/08 01:59:49, yhirano wrote: > > > > On 2016/12/07 23:38:43, tkent wrote: > > > > > +yhirano > > > > > > > > > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > > > > > I've been trying to understand these asVector() uses for a while, but > > have > > > > > failed -- no particular reason to have these, right? > > > > > > > > > > It looks safe to remove asVector() with the current > ImageResourceObserver > > > > > implementations. However, an ImageResourceObserver implementation might > > > break > > > > > the assumption in the future. The defensive copy isn't bad. I'd like > to > > > > > entrust this to an owner of core/fetch. > > > > > > > > We copy a collection before iterating-and-calling a method on the > collection > > > > because the method may mutate the collection (especially via addClient / > > > > removeClient / addObserver / removeObserver). > > > > > > Sure, and checkModifications() on HashTable iterators catch when that > doesn't > > > hold. Which of the predicates in these loops perform side-effects? > > > > I didn't know checkModifications(), thanks. Currently I don't understand all > > ImageResourceObserver subclasses implementations, but it might make sense to > > forbid addObserver / removeObserver in some functions. If we do so, such > > restrictions must be explicitly stated in ImageResourceObserver.h. > > While such a clarification is separately worthwhile, the copying that this CL > removes, is redundant and overly defensive. What this CL is doing is changing contracts between ImageResource and ImageResourceObserver. That must be explicitly stated in the public interface, not only in the implementation.
On 2016/12/08 07:14:34, yhirano wrote: > On 2016/12/08 07:09:59, sof wrote: > > On 2016/12/08 06:50:05, yhirano wrote: > > > On 2016/12/08 06:30:50, sof wrote: > > > > On 2016/12/08 01:59:49, yhirano wrote: > > > > > On 2016/12/07 23:38:43, tkent wrote: > > > > > > +yhirano > > > > > > > > > > > > On 2016/12/07 at 09:11:42, sigbjornf wrote: > > > > > > > I've been trying to understand these asVector() uses for a while, > but > > > have > > > > > > failed -- no particular reason to have these, right? > > > > > > > > > > > > It looks safe to remove asVector() with the current > > ImageResourceObserver > > > > > > implementations. However, an ImageResourceObserver implementation > might > > > > break > > > > > > the assumption in the future. The defensive copy isn't bad. I'd like > > to > > > > > > entrust this to an owner of core/fetch. > > > > > > > > > > We copy a collection before iterating-and-calling a method on the > > collection > > > > > because the method may mutate the collection (especially via addClient / > > > > > removeClient / addObserver / removeObserver). > > > > > > > > Sure, and checkModifications() on HashTable iterators catch when that > > doesn't > > > > hold. Which of the predicates in these loops perform side-effects? > > > > > > I didn't know checkModifications(), thanks. Currently I don't understand all > > > ImageResourceObserver subclasses implementations, but it might make sense to > > > forbid addObserver / removeObserver in some functions. If we do so, such > > > restrictions must be explicitly stated in ImageResourceObserver.h. > > > > While such a clarification is separately worthwhile, the copying that this CL > > removes, is redundant and overly defensive. > > What this CL is doing is changing contracts between ImageResource and > ImageResourceObserver. That must be explicitly stated in the public interface, > not only in the implementation. Done.
https://codereview.chromium.org/2555103004/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/fetch/ImageResourceObserver.h (right): https://codereview.chromium.org/2555103004/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/fetch/ImageResourceObserver.h:63: virtual ResourcePriority computeResourcePriority() const { This function has the same restriction.
https://codereview.chromium.org/2555103004/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/fetch/ImageResourceObserver.h (right): https://codereview.chromium.org/2555103004/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/fetch/ImageResourceObserver.h:63: virtual ResourcePriority computeResourcePriority() const { On 2016/12/08 07:29:21, yhirano wrote: > This function has the same restriction. Done.
lgtm
The CQ bit was checked by sigbjornf@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by sigbjornf@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by sigbjornf@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm. I think we should add assertions that these callbacks actually does not add/remove observers, but I'd like to do it later (after I modifies ImageResource largely probably next week: https://codereview.chromium.org/2469873002/) One trybot is consistently failing, but the tests are already failing/flaky without this CL?
On 2016/12/08 10:46:01, hiroshige wrote: > lgtm. I think we should add assertions that these callbacks actually does not > add/remove observers, but I'd like to do it later (after I modifies > ImageResource largely probably next week: > https://codereview.chromium.org/2469873002/) > ok, it wouldn't hurt, but the likelihood it happening is low for these methods. Having HashTable enforce it on updates during iteration has proven to have too large an overhead. > One trybot is consistently failing, but the tests are already failing/flaky > without this CL? It's flaky for all atm.
On 2016/12/08 10:52:51, sof wrote: > On 2016/12/08 10:46:01, hiroshige wrote: > > lgtm. I think we should add assertions that these callbacks actually does not > > add/remove observers, but I'd like to do it later (after I modifies > > ImageResource largely probably next week: > > https://codereview.chromium.org/2469873002/) > > > > ok, it wouldn't hurt, but the likelihood it happening is low for these methods. > Having HashTable enforce it on updates during iteration has proven to have too > large an overhead. > > > One trybot is consistently failing, but the tests are already failing/flaky > > without this CL? > > It's flaky for all atm. It'd be useful to at least document which imageChanged() observer implementations depend on (un)registering observers.
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by hiroshige@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by sigbjornf@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by sigbjornf@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 60001, "attempt_start_ts": 1481264100264290, "parent_rev": "fcc8ae27cce0a55d64344e65c2d396d8c34027bb", "commit_rev": "a8743ac9d6898fc7707efa839bd99587af96300c"}
Message was sent while issue was closed.
Committed patchset #4 (id:60001)
Message was sent while issue was closed.
Description was changed from ========== ImageResource: remove unnecessary vector copying during iteration. Iterations that don't update the underlying collection, can be done in-place. R= BUG= ========== to ========== ImageResource: remove unnecessary vector copying during iteration. Iterations that don't update the underlying collection, can be done in-place. R= BUG= Committed: https://crrev.com/af6993cee55aaf307b3f73e4e0ca5f05aa0413f4 Cr-Commit-Position: refs/heads/master@{#437482} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/af6993cee55aaf307b3f73e4e0ca5f05aa0413f4 Cr-Commit-Position: refs/heads/master@{#437482} |