On Sep 29, 2011, at 5:49 AM, Jeff Slutter wrote:

> Initial 'add' of all the files took roughly 10 minutes. For comparison,
> Mercurial took less than a minute.

Let's start with this and work on low-hanging fruits.
I have created ~70000 tiny files (no directories). Adding all files takes 16 
sec (not 10 minutes for me probably because there are no directories). 
Profiling in Instruments shows that db_get_boolean() takes 36.7% of execution 
time:

http://i.imgur.com/6iCDp.png 

I hunted it down to fossil_reserved_name() function. It's called for every 
added file, and it fetches "manifest" setting from db.
Let's cache this setting in a static variable instead of fetching it from db 
every time:

Index: src/add.c
===================================================================
--- src/add.c
+++ src/add.c
@@ -58,13 +58,20 @@
   static const char *azManifest[] = {
      "manifest",
      "manifest.uuid",
   };
 
+  /* Cached setting "manifest" */
+  static int cachedManifest = -1;
+
+  if( cachedManifest == -1 ){
+    cachedManifest = db_get_boolean("manifest",0);
+  }
+
   if( N>=0 && N<count(azName) ) return azName[N];
   if( N>=count(azName) && N<count(azName)+count(azManifest)
-      && db_get_boolean("manifest",0) ){
+      && cachedManifest ){
     return azManifest[N-count(azName)];
   }
   return 0;
 }
 

Ta-dam! The call to db_get_boolean() no longer appears in Instruments, and 
we're down to 10 sec from 16 sec.

--
Dmitry Chestnykh

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to