MozReview: load diffs in parallel instead of via the funcQueue (
bug 1251286); r?smacleod
In order to improve page load time performance, allow the browser to schedule
requests for file content instead of serialising requests via the funcQueue.
This change means that we no longer guarantee that file's content will appear
in the same order they are listed in the patch (the ordering of the files
themselves will not change however). In practice this makes very little
difference to the user experience, and the overall performance gains are worth
this cost.
MozReview-Commit-ID: 31IDKOrmoc8
--- a/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
@@ -280,22 +280,20 @@ RB.DiffViewerPageView = RB.ReviewablePag
this.queueLoadDiff(filediff.id,
filediff.revision,
interfilediff ? interfilediff.id : null,
interdiffRevision,
file.get('index'),
file.get('commentCounts'));
}, this);
-
- $.funcQueue('diff_files').start();
},
/*
- * Queues loading of a diff.
+ * Requests loading of a diff.
*
* When the diff is loaded, it will be placed into the appropriate location
* in the diff viewer. The anchors on the page will be rebuilt. This will
* then trigger the loading of the next file.
*/
queueLoadDiff: function(fileDiffID, fileDiffRevision,
interFileDiffID, interdiffRevision,
fileIndex, serializedCommentBlocks) {
@@ -304,56 +302,52 @@ RB.DiffViewerPageView = RB.ReviewablePag
fileIndex: fileIndex,
fileDiffID: fileDiffID,
interFileDiffID: interFileDiffID,
revision: fileDiffRevision,
interdiffRevision: interdiffRevision,
serializedCommentBlocks: serializedCommentBlocks
});
- $.funcQueue('diff_files').add(function() {
- if ($('#file' + fileDiffID).length === 1) {
- /*
- * We already have this one. This is probably a pre-loaded file.
- */
- this._renderFileDiff(diffReviewable);
- } else {
- diffReviewable.getRenderedDiff({
- complete: function(xhr) {
- $('#file_container_' + fileDiffID)
- .replaceWith(xhr.responseText);
- this._renderFileDiff(diffReviewable);
- }
- }, this);
- }
- }, this);
+ // MozReview: upstream processes these requests via the funcQueue,
+ // which prevents requests from being processed in parallel.
+ if ($('#file' + fileDiffID).length === 1) {
+ /*
+ * We already have this one. This is probably a pre-loaded file.
+ */
+ this._renderFileDiff(diffReviewable);
+ } else {
+ diffReviewable.getRenderedDiff({
+ complete: function(xhr) {
+ $('#file_container_' + fileDiffID)
+ .replaceWith(xhr.responseText);
+ this._renderFileDiff(diffReviewable);
+ }
+ }, this);
+ }
},
/*
* Sets up a diff as DiffReviewableView and renders it.
*
* This will set up a DiffReviewableView for the given diffReviewable.
* The anchors from this diff render will be stored for navigation.
- *
- * Once rendered and set up, the next diff in the load queue will be
- * pulled from the server.
*/
_renderFileDiff: function(diffReviewable) {
var elementName = 'file' + diffReviewable.get('fileDiffID'),
$el = $('#' + elementName),
diffReviewableView,
$anchor,
urlSplit;
if ($el.length === 0) {
/*
* The user changed revsions before the file finished loading, and
* the target element no longer exists. Just return.
*/
- $.funcQueue('diff_files').next();
return;
}
diffReviewableView = new RB.DiffReviewableView({
el: $el,
model: diffReviewable
});
@@ -407,18 +401,16 @@ RB.DiffViewerPageView = RB.ReviewablePag
.append($anchor);
}
if ($anchor.length !== 0) {
this.selectAnchor($anchor);
this._startAtAnchorName = null;
}
}
-
- $.funcQueue('diff_files').next();
},
/*
* Selects the anchor at a specified location.
*
* By default, this will scroll the page to position the anchor near
* the top of the view.
*/