Skip to content

Commit

Permalink
Bug 862870. Implement splice batching with forced flushes if batching…
Browse files Browse the repository at this point in the history
… too much. r=asuth
  • Loading branch information
Mason Chang authored and asutherland committed Jan 14, 2014
1 parent 660ecbd commit 59efcdc
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 218 deletions.
2 changes: 1 addition & 1 deletion data/lib/mailapi/activesync/folder.js
Expand Up @@ -1384,7 +1384,7 @@ ActiveSyncFolderSyncer.prototype = {

initialSync: function(slice, initialDays, syncCallback,
doneCallback, progressCallback) {
syncCallback('sync', false, true);
syncCallback('sync', true /* Ignore Headers */);
this.folderConn.sync(
$date.NOW(),
this.onSyncCompleted.bind(this, doneCallback, true),
Expand Down
13 changes: 2 additions & 11 deletions data/lib/mailapi/imap/folder.js
Expand Up @@ -548,7 +548,6 @@ console.log('BISECT CASE', serverUIDs.length, 'curDaysDelta', curDaysDelta);
// build the list of requests based on downloading required.
var requests = [];
bodyInfo.bodyReps.forEach(function(rep, idx) {

// attempt to be idempotent by only requesting the bytes we need if we
// actually need them...
if (rep.isDownloaded)
Expand Down Expand Up @@ -961,7 +960,7 @@ ImapFolderSyncer.prototype = {
*/
initialSync: function(slice, initialDays, syncCallback,
doneCallback, progressCallback) {
syncCallback('sync', false);
syncCallback('sync', false /* Ignore Headers */);
// We want to enter the folder and get the box info so we can know if we
// should trigger our SYNC_WHOLE_FOLDER_AT_N_MESSAGES logic.
// _timelySyncSearch is what will get called next either way, and it will
Expand Down Expand Up @@ -1090,11 +1089,7 @@ ImapFolderSyncer.prototype = {
// intended to be a new thing for each request. So we don't want extra
// desire building up, so we set it to what we have every time.
//
// We don't want to affect this value in accumulating mode, however, since
// it could result in sending more headers than actually requested over the
// wire.
if (!this._syncSlice._accumulating)
this._syncSlice.desiredHeaders = this._syncSlice.headers.length;
this._syncSlice.desiredHeaders = this._syncSlice.headers.length;

if (this._curSyncDoneCallback)
this._curSyncDoneCallback(err);
Expand Down Expand Up @@ -1288,10 +1283,6 @@ console.log("folder message count", folderMessageCount,
this._doneSync();
return;
}
else if (this._syncSlice._accumulating) {
// flush the accumulated results thus far
this._syncSlice.setStatus('synchronizing', true, true, true);
}

// - Increase our search window size if we aren't finding anything
// Our goal is that if we are going backwards in time and aren't finding
Expand Down
1 change: 0 additions & 1 deletion data/lib/mailapi/imap/imapchew.js
Expand Up @@ -382,7 +382,6 @@ exports.chewHeaderAndBodyStructure =
*
*/
exports.updateMessageWithFetch = function(header, body, req, res, _LOG) {

var bodyRep = body.bodyReps[req.bodyRepIndex];

// check if the request was unbounded or we got back less bytes then we
Expand Down
15 changes: 12 additions & 3 deletions data/lib/mailapi/imap/protocol/sync.js
Expand Up @@ -142,9 +142,18 @@ Sync.prototype = {
if (!self.oncomplete)
return;

self.oncomplete(
self.newUIDs.length,
self.knownUIDs.length
// Need a timeout here
// because we batch slices in SliceBridgeProxy
// And only want to call oncomplete after
// All those slices have been sent to keep the order
// the same
setZeroTimeout(
function() {
self.oncomplete(
self.newUIDs.length,
self.knownUIDs.length
);
}
);
});
}
Expand Down

0 comments on commit 59efcdc

Please sign in to comment.