evolution-data-server r9059 - branches/camel-db-summary/camel



Author: sragavan
Date: Fri Jun 27 08:56:07 2008
New Revision: 9059
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9059&view=rev

Log:
More goodness.


Modified:
   branches/camel-db-summary/camel/camel-db.c
   branches/camel-db-summary/camel/camel-folder-summary.c
   branches/camel-db-summary/camel/camel-folder-summary.h
   branches/camel-db-summary/camel/camel-folder-thread.c
   branches/camel-db-summary/camel/camel-folder.c

Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c	(original)
+++ branches/camel-db-summary/camel/camel-db.c	Fri Jun 27 08:56:07 2008
@@ -69,7 +69,7 @@
 
 	#warning "make these under g_getenv"
 	
-	//camel_db_command (cdb, "PRAGMA cache_size=100", NULL);
+	camel_db_command (cdb, "PRAGMA cache_size=100", NULL);
 	
 	sqlite3_busy_timeout (cdb->db, CAMEL_DB_SLEEP_INTERVAL);
 

Modified: branches/camel-db-summary/camel/camel-folder-summary.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.c	(original)
+++ branches/camel-db-summary/camel/camel-folder-summary.c	Fri Jun 27 08:56:07 2008
@@ -60,10 +60,11 @@
 #include "camel-stream-null.h"
 #include "camel-string-utils.h"
 #include "camel-store.h"
+#include "camel-vee-folder.h"
 
 /* To switch between e-memchunk and g-alloc */
 #define ALWAYS_ALLOC
-
+#define SUMMARY_CACHE_DROP 120
 static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER;
 
 /* this lock is ONLY for the standalone messageinfo stuff */
@@ -178,6 +179,7 @@
 	   exceeding 20, has to override this value 
 	*/
 	s->meta_summary->uid_len = 20;
+	s->cache_load_time = 0;
 }
 
 static void free_o_name(void *key, void *value, void *data)
@@ -697,7 +699,10 @@
 remove_cache (CamelFolderSummary *s)
 {
 	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
-
+	/* Attempt to release 2MB*/
+	sqlite3_release_memory(2*1024*1024);
+	if (time(NULL) - s->cache_load_time < SUMMARY_CACHE_DROP)
+		return TRUE;
 	printf("removing cache for  %s %d\n", s->folder->full_name, g_hash_table_size (s->loaded_infos));
 	#warning "hack. fix it"
 	CAMEL_SUMMARY_LOCK (s, summary_lock);
@@ -708,20 +713,33 @@
 }
 
 int
+camel_folder_summary_cache_size (CamelFolderSummary *s)
+{
+	#warning "this is a timely hack. fix it well"
+	if (!CAMEL_IS_VEE_FOLDER(s->folder))
+		return g_hash_table_size (s->loaded_infos);
+	else
+		return s->uids->len;
+		    
+}
+
+int
 camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex)
 {
 	CamelDB *cdb;
 	char *folder_name;
 	int ret = 0;
 
+	#warning "baseclass this, and vfolders we may have to load better."
 	d(printf ("\ncamel_folder_summary_reload_from_db called \n"));
 
 	folder_name = s->folder->full_name;
 	cdb = s->folder->cdb;
 
 	/* FIXME FOR SANKAR: No need to pass the address of summary here. */
-	ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer**) &s, camel_read_mir_callback, ex);
+	ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer**) &s, camel_read_mir_callback, NULL);
 
+	s->cache_load_time = time (NULL);
 	return ret;
 }
 
@@ -746,9 +764,9 @@
 
 	/* FIXME FOR SANKAR: No need to pass the address of summary here. */
 	ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer**) &s, camel_read_mir_callback, ex);
-
+	s->cache_load_time = time (NULL);
 	#warning "LRU please and not timeouts"
-	g_timeout_add_seconds (5, remove_cache, s);
+	g_timeout_add_seconds (SUMMARY_CACHE_DROP, remove_cache, s);
 	return ret;
 }
 

Modified: branches/camel-db-summary/camel/camel-folder-summary.h
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.h	(original)
+++ branches/camel-db-summary/camel/camel-folder-summary.h	Fri Jun 27 08:56:07 2008
@@ -243,6 +243,7 @@
 
 	struct _CamelFolder *folder; /* parent folder, for events */
 	struct _CamelFolderMetaSummary *meta_summary; /* Meta summary */
+	time_t cache_load_time;
 };
 
 struct _CamelFolderSummaryClass {

Modified: branches/camel-db-summary/camel/camel-folder-thread.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-thread.c	(original)
+++ branches/camel-db-summary/camel/camel-folder-thread.c	Fri Jun 27 08:56:07 2008
@@ -620,6 +620,8 @@
 
 	fsummary = camel_folder_get_summary(folder);
 	thread->summary = summary = g_ptr_array_new();
+	if (fsummary->len > camel_folder_summary_cache_size (folder->summary))
+		camel_folder_summary_reload_from_db (folder->summary);
 
 	for (i = 0 ; i < fsummary->len ; i++) {
 		CamelMessageInfo *info ;

Modified: branches/camel-db-summary/camel/camel-folder.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder.c	(original)
+++ branches/camel-db-summary/camel/camel-folder.c	Fri Jun 27 08:56:07 2008
@@ -374,10 +374,13 @@
 		case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
 		case CAMEL_FOLDER_ARG_VISIBLE:
 			/* This is so we can get the values atomically, and also so we can calculate them only once */
+
+			#warning "Add a better base class function to get counts specific to normal/vee folder."
 			if (unread == -1) {
 				int j;
 				CamelMessageInfo *info;
 
+				if (!CAMEL_IS_VEE_FOLDER (folder)) {
 				/* TODO: Locking? */
 				#warning "unread should be unread and not del/junk and take care of dirty infos also"
 				camel_db_count_visible_unread_message_info (folder->cdb, folder->full_name, &unread, ex);
@@ -385,7 +388,7 @@
 				camel_db_count_deleted_message_info (folder->cdb, folder->full_name, &deleted, ex);
 				camel_db_count_junk_not_deleted_message_info (folder->cdb, folder->full_name, &junked_not_deleted, ex);
 				camel_db_count_visible_message_info (folder->cdb, folder->full_name, &visible, ex);
-#if 0				
+				} else {
 				count = camel_folder_summary_count (folder->summary);
 				for (j = 0; j < count; j++) {
 					if ((info = camel_folder_summary_index (folder->summary, j))) {
@@ -405,7 +408,7 @@
 						camel_message_info_free(info);
 					}
 				}
-#endif
+				}
 				#warning "I added it for vfolders summary storage, does it harm ?"
 				folder->summary->junk_count = junked;
 				folder->summary->deleted_count = deleted;



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