[geary/wip/713432-startup: 45/45] More tweaks to squeeze a few more tenths-of-a-second from startup



commit 59420a6232a31bd804f0fc0f8105a5e5118ba38b
Author: Jim Nelson <jim yorba org>
Date:   Wed Jan 15 15:19:56 2014 -0800

    More tweaks to squeeze a few more tenths-of-a-second from startup
    
    In particular, this patch reports local folders as being available
    as soon as they've been enumerated.  This gets them on the UI faster.
    Then the server is enumerated and folder properaties are updated.

 .../imap-engine/imap-engine-generic-account.vala   |   56 ++++---------------
 .../transport/imap-client-session-manager.vala     |    2 +-
 2 files changed, 13 insertions(+), 45 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 24cdeb0..4322ed7 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -7,38 +7,6 @@
 private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
     private const int REFRESH_FOLDER_LIST_SEC = 4 * 60;
     
-    // A background batch operation for enumerating folders in the local store (database)
-    private class EnumerateLocalOperation : Nonblocking.BatchOperation {
-        public weak GenericAccount owner;
-        public Gee.HashMap<FolderPath, ImapDB.Folder>? local_folders = null;
-        
-        public EnumerateLocalOperation(GenericAccount owner) {
-            this.owner = owner;
-        }
-        
-        public override async Object? execute_async(Cancellable? cancellable) throws Error {
-            local_folders = yield owner.enumerate_local_folders_async(null, cancellable);
-            
-            return null;
-        }
-    }
-    
-    // A background batch operation for enumerating folders in the remote store (server)
-    private class EnumerateRemoteOperation : Nonblocking.BatchOperation {
-        public weak GenericAccount owner;
-        public Gee.HashMap<FolderPath, Imap.Folder>? remote_folders = null;
-        
-        public EnumerateRemoteOperation(GenericAccount owner) {
-            this.owner = owner;
-        }
-        
-        public override async Object? execute_async(Cancellable? cancellable) throws Error {
-            remote_folders = yield owner.enumerate_remote_folders_async(null, cancellable);
-            
-            return null;
-        }
-    }
-    
     private static Geary.FolderPath? outbox_path = null;
     private static Geary.FolderPath? search_path = null;
     
@@ -336,27 +304,27 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
     private async void enumerate_folders_async(Cancellable? cancellable) throws Error {
         check_open();
         
-        EnumerateLocalOperation local_op = new EnumerateLocalOperation(this);
-        EnumerateRemoteOperation remote_op = new EnumerateRemoteOperation(this);
-        
-        Nonblocking.Batch batch = new Nonblocking.Batch();
-        batch.add(local_op);
-        batch.add(remote_op);
-        
-        yield batch.execute_all_async(cancellable);
-        batch.throw_first_exception();
+        // enumerate local folders first
+        Gee.HashMap<FolderPath, ImapDB.Folder> local_folders = yield enumerate_local_folders_async(
+            null, cancellable);
         
         // convert to a list of Geary.Folder ... build_folder() also reports new folders, so this
-        // gets the word out quickly
+        // gets the word out quickly (local_only folders have already been reported)
         Gee.Collection<Geary.Folder> existing_list = new Gee.ArrayList<Geary.Folder>();
-        existing_list.add_all(build_folders(local_op.local_folders.values));
+        existing_list.add_all(build_folders(local_folders.values));
         existing_list.add_all(local_only.values);
         
+        // build a map of all existing folders
         Gee.HashMap<FolderPath, Geary.Folder> existing_folders
             = Geary.traverse<Geary.Folder>(existing_list).to_hash_map<FolderPath>(f => f.path);
         
+        // now that all local have been enumerated and reported (this is important to assist
+        // startup of the UI), enumerate the remote folders
+        Gee.HashMap<FolderPath, Imap.Folder>? remote_folders = yield enumerate_remote_folders_async(
+            null, cancellable);
+        
         // pair the local and remote folders and make sure everything is up-to-date
-        yield update_folders_async(existing_folders, remote_op.remote_folders, cancellable);
+        yield update_folders_async(existing_folders, remote_folders, cancellable);
     }
     
     // Called by EnumerateLocalOperation
diff --git a/src/engine/imap/transport/imap-client-session-manager.vala 
b/src/engine/imap/transport/imap-client-session-manager.vala
index 4acc6b7..abfd436 100644
--- a/src/engine/imap/transport/imap-client-session-manager.vala
+++ b/src/engine/imap/transport/imap-client-session-manager.vala
@@ -5,7 +5,7 @@
  */
 
 public class Geary.Imap.ClientSessionManager : BaseObject {
-    public const int DEFAULT_MIN_POOL_SIZE = 2;
+    public const int DEFAULT_MIN_POOL_SIZE = 1;
     private const int AUTHORIZED_SESSION_ERROR_RETRY_TIMEOUT_MSEC = 1000;
     
     public bool is_open { get; private set; default = false; }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]