Bug 505035 - Improve comment to explain why there is a delay and choice of delay. a=comment-only-blocker-followup
authorAndrew Sutherland <asutherland@asutherland.org>
Sat, 24 Apr 2010 01:21:13 -0700
changeset 5533 d98d6a3f9b096858f2d2b450199dbbc37eb531bd
parent 5532 a0d58747ab2ed2b88b34a04f4ca6f80b51eef055
child 5534 39695cfa8c14ad9beadcfcbd3b9f694446b1905a
push idunknown
push userunknown
push dateunknown
reviewerscomment-only-blocker-followup
bugs505035
Bug 505035 - Improve comment to explain why there is a delay and choice of delay. a=comment-only-blocker-followup
mail/base/modules/MailUtils.js
--- a/mail/base/modules/MailUtils.js
+++ b/mail/base/modules/MailUtils.js
@@ -324,18 +324,36 @@ var MailUtils =
       windowWatcher.openWindow(null,
           "chrome://messenger/content/", "",
           "all,chrome,dialog=no,status,toolbar", args);
     }
   },
 
   /**
    * The number of milliseconds to wait between loading of folders in
-   * |setStringPropertyOnFolderAndDescendents|.  This is exposed primarily
-   * to allow unit tests to set this to 0 to minimize throttling.
+   * |setStringPropertyOnFolderAndDescendents|.  We wait at all because
+   * opening msf databases is a potentially expensive synchronous operation that
+   * can approach the order of a second in pathological cases like gmail's
+   * all mail folder.
+   *
+   * If we did not use a timer or otherwise spin the event loop we would
+   * completely lock up the UI.  In theory we would still maintain some degree
+   * of UI responsiveness if we just used postMessage to break up our work so
+   * that the event loop still got a chance to run between our folder openings.
+   * The use of any delay between processing folders is to try and avoid causing
+   * system-wide interactivity problems from dominating the system's available
+   * disk seeks to such an extent that other applications start experiencing
+   * non-trivial I/O waits.
+   *
+   * The specific choice of delay remains an arbitrary one to maintain app
+   * and system responsiveness per the above while also processing as many
+   * folders as quickly as possible.
+   *
+   * This is exposed primarily to allow unit tests to set this to 0 to minimize
+   * throttling.
    */
   INTER_FOLDER_PROCESSING_DELAY_MS: 10,
 
   /**
    * Set a string property on a folder and all of its descendents, taking care
    * to avoid locking up the main thread and to avoid leaving folder databases
    * open.  To avoid locking up the main thread we operate in an asynchronous
    * fashion; we invoke a callback when we have completed our work.