Here's a patch to improve the speed of many database-intensive monotone 
commands.

It can shave 70% of the time off of a (cold) checkout, for example.

Enjoy.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
# 
# old_revision [f28f306ccd3ff2c57df9d0005876a00370af2739]
# 
# patch "database.cc"
#  from [430079748f8733f34aa2f781847a905d85983436]
#    to [e97887b34a24b8616270150b8bcdc4b120d84be9]
# 
============================================================
--- database.cc	430079748f8733f34aa2f781847a905d85983436
+++ database.cc	e97887b34a24b8616270150b8bcdc4b120d84be9
@@ -2834,6 +2834,20 @@
   return !filename.empty();
 }
 
+// load database file into the operating system's disk cache to
+// improve SQLite speed.
+// NOTE: the file is NOT loaded into program memory.
+// file may take a few seconds to load the first time, but only a
+// fraction of a second to load subsequent times if already in cache.
+static void
+load_file_into_OS_cache(const string& filename)
+{
+  ifstream ifs(filename.c_str(), ios_base::in | ios_base::binary);
+  char buffer[4096];
+  while (ifs) {
+    ifs.read(buffer, sizeof(buffer));
+  }
+}
 
 void
 database::open()
@@ -2842,6 +2856,8 @@
 
   I(!__sql);
 
+  load_file_into_OS_cache(filename.as_external().c_str());
+
   error = sqlite3_open(filename.as_external().c_str(), &__sql);
 
   if (__sql)
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to