Closed Bug 877149 Opened 11 years ago Closed 11 years ago

Avoid redundant arrangeItems calls on richgrids

Categories

(Firefox for Metro Graveyard :: Firefox Start, defect)

x86_64
Windows 8
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 24

People

(Reporter: sfoster, Assigned: sfoster)

References

Details

Attachments

(1 file)

The richgrid binding's mutator methods recently got a 'skipArrange' param, which is not used or not used effectively in some of the views with grids. This results in repeated arrangeItems calls. As each call can involve quite a bit of DOM interaction, fixing this should buy some tangible performance gains. For example, I recently logged the following during startup:

richgrid#start-bookmarks-grid: 9 calls
richgrid#start-history-grid: 17 calls
richgrid#start-topsites-grid: 2 calls
richgrid#snapped-topsites-grid: 1 call
richgrid#start-bookmarks-grid: 1 call
richgrid#results-richgrid: 2 calls
richgrid#start-remotetabs-grid: 1 call
richgrid#snapped-topsites-grid: 2 calls
richgrid#searches-richgrid: 24 calls
Make use of the skipArrange params to significantly reduce the number of times we rebuild the richgrid / items - at startup and during use. New numbers from startup with this patch: 

richgrid#start-bookmarks-grid: calls: 2
richgrid#start-history-grid: calls: 2
richgrid#start-topsites-grid: calls: 2
richgrid#snapped-topsites-grid: calls: 3
richgrid#results-richgrid: calls: 2
richgrid#start-remotetabs-grid: calls: 11
richgrid#searches-richgrid: calls: 3
Attachment #755421 - Flags: review?(mbrubeck)
Ack, that's richgrid#start-remotetabs-grid: calls: 1 not 11
Comment on attachment 755421 [details] [diff] [review]
Reduce the number of calls to richgrid arrangeItems

Review of attachment 755421 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/metro/base/content/history.js
@@ +30,5 @@
>    },
>  
>    populateGrid: function populateGrid(aRefresh) {
> +    let inBatch = this._inBatch;
> +    this._inBatch = true; // always batch up grid updates to avoid redundant arrangeItems calls

Another way to do this is initialize _inBatch to 0, then use _inBatch++ to set it and _inBatch-- to unset.  This is a bit more robust for things like nested calls.  We don't seem to require nesting here, but feel free to switch to this style if you like.
Attachment #755421 - Flags: review?(mbrubeck) → review+
I updated the patch to use the inBatch++ / -- style for the nesting case in history.js. Landed on inbound: https://hg.mozilla.org/integration/mozilla-inbound/rev/d448b2c7e12b
https://hg.mozilla.org/mozilla-central/rev/d448b2c7e12b
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: