[anjuta/sdb-core-trans] symbol-db: removed all tablemaps. Added global transaction.



commit c269a99676e0ec8701c8b4939c864997cfc0a9b2
Author: Massimo Corà <mcora src gnome org>
Date:   Sun Jun 20 22:18:54 2010 +0200

    symbol-db: removed all tablemaps. Added global transaction.
    
    Now it's terribly slow. 42 seconds to complete the whole scan of db.

 plugins/symbol-db/benchmark/benchmark.c   |    2 +-
 plugins/symbol-db/plugin.c                |    8 ++---
 plugins/symbol-db/symbol-db-engine-core.c |   41 ++++++++++++++++------------
 plugins/symbol-db/symbol-db-engine-core.h |    5 +---
 plugins/symbol-db/symbol-db-engine-priv.h |    2 +-
 5 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/plugins/symbol-db/benchmark/benchmark.c b/plugins/symbol-db/benchmark/benchmark.c
index 541c6d5..2dfe8ce 100644
--- a/plugins/symbol-db/benchmark/benchmark.c
+++ b/plugins/symbol-db/benchmark/benchmark.c
@@ -104,7 +104,7 @@ int main (int argc, char** argv)
 	
     engine = symbol_db_engine_new_full ("anjuta-tags", "benchmark-db");
   
-	if (symbol_db_engine_open_db (engine, root_dir, root_dir, FALSE) == DB_OPEN_STATUS_FATAL)
+	if (symbol_db_engine_open_db (engine, root_dir, root_dir) == DB_OPEN_STATUS_FATAL)
 	{
 		g_message ("Could not open database: %s", root_dir);
 		return -1;
diff --git a/plugins/symbol-db/plugin.c b/plugins/symbol-db/plugin.c
index 1a4e661..138ed63 100644
--- a/plugins/symbol-db/plugin.c
+++ b/plugins/symbol-db/plugin.c
@@ -1591,8 +1591,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 		anjuta_cache_path = anjuta_util_get_user_cache_file_path (".", NULL);
 		if (symbol_db_engine_open_db (sdb_plugin->sdbe_globals, 
 							  anjuta_cache_path, 
-							  PROJECT_GLOBALS,
-		    				  FALSE) == DB_OPEN_STATUS_FATAL)
+							  PROJECT_GLOBALS) == DB_OPEN_STATUS_FATAL)
 		{
 			g_error ("Opening global project under %s", anjuta_cache_path);
 		}
@@ -1652,7 +1651,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 		/* we'll use the same values for db_directory and project_directory */
 		DEBUG_PRINT ("Opening db %s and project_dir %s", root_dir, root_dir);
 		gint open_status = symbol_db_engine_open_db (sdb_plugin->sdbe_project, root_dir, 
-										  root_dir, FALSE);
+										  root_dir);
 
 		/* is it a fresh-new project? is it an imported project with 
 		 * no 'new' symbol-db database but the 'old' one symbol-browser? 
@@ -1994,8 +1993,7 @@ symbol_db_activate (AnjutaPlugin *plugin)
 	anjuta_cache_path = anjuta_util_get_user_cache_file_path (".", NULL);
 	if (symbol_db_engine_open_db (sdb_plugin->sdbe_globals, 
 							  anjuta_cache_path, 
-							  PROJECT_GLOBALS,
-	    					  TRUE) == DB_OPEN_STATUS_FATAL)
+							  PROJECT_GLOBALS) == DB_OPEN_STATUS_FATAL)
 	{
 		g_error ("Opening global project under %s", anjuta_cache_path);
 	}
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index bad8a93..d377526 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -1695,6 +1695,12 @@ sdb_engine_timeout_trigger_signals (gpointer user_data)
 		
 				case SCAN_END:
 				{
+					/* reset count */
+					priv->symbols_scanned_count = 0;
+
+					gda_connection_commit_transaction (priv->db_connection, "symboltrans",
+		    						NULL);
+					
 					/* perform flush on db of the tablemaps, if this is the 1st scan */
 					if (priv->is_first_population == TRUE)
 					{
@@ -1702,12 +1708,6 @@ sdb_engine_timeout_trigger_signals (gpointer user_data)
 						priv->is_first_population = FALSE;
 					}
 
-					/* were we forced to use tablemaps? Ok, reset the flag to true */
-					if (priv->is_tablemaps_forced == TRUE)
-					{
-						priv->is_first_population = TRUE;
-					}
-					
 					/* get the process id from the queue */
 					gint int_tmp = GPOINTER_TO_INT(g_async_queue_pop (priv->scan_process_id_queue));
 					priv->scanning--;
@@ -2159,7 +2159,8 @@ sdb_engine_init (SymbolDBEngine * object)
 	sdbe->priv->removed_launchers = NULL;
 	sdbe->priv->shutting_down = FALSE;
 	sdbe->priv->is_first_population = FALSE;
-	sdbe->priv->is_tablemaps_forced = FALSE;
+
+	sdbe->priv->symbols_scanned_count = 0;
 
 	/* set the ctags executable path to NULL */
 	sdbe->priv->ctags_path = NULL;
@@ -2954,9 +2955,8 @@ sdb_engine_connect_to_db (SymbolDBEngine * dbe, const gchar *cnc_string)
 	/* establish a connection. If the sqlite file does not exist it will 
 	 * be created 
 	 */
-	priv->db_connection
-		= gda_connection_open_from_string ("SQLite", cnc_string, NULL, 
-		/* FIXME */								   GDA_CONNECTION_OPTIONS_THREAD_SAFE, NULL);	
+	priv->db_connection = gda_connection_open_from_string ("SQLite", cnc_string, NULL, 
+										   GDA_CONNECTION_OPTIONS_THREAD_SAFE, NULL);	
 	
 	if (!GDA_IS_CONNECTION (priv->db_connection))
 	{
@@ -3117,7 +3117,8 @@ symbol_db_engine_close_db (SymbolDBEngine *dbe)
 	priv->thread_pool = NULL;
 	ret = sdb_engine_disconnect_from_db (dbe);
 
-	priv->is_tablemaps_forced = FALSE;
+	/* reset count */
+	priv->symbols_scanned_count = 0;
 	
 	g_free (priv->db_directory);
 	priv->db_directory = NULL;
@@ -3227,7 +3228,7 @@ sdb_engine_check_db_version_and_upgrade (SymbolDBEngine *dbe,
 
 gint
 symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
-						  const gchar * prj_directory, gboolean force_tablemaps)
+						  const gchar * prj_directory)
 {
 	SymbolDBEnginePriv *priv;
 	gboolean needs_tables_creation = FALSE;
@@ -3243,12 +3244,7 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
 
 	priv = dbe->priv;
 
-	priv->is_tablemaps_forced = force_tablemaps;
-	if (priv->is_tablemaps_forced == TRUE)
-	{
-		priv->is_first_population = TRUE;
-	}
-	
+	priv->symbols_scanned_count = 0;
 	
 	/* check whether the db filename already exists. If it's not the case
 	 * create the tables for the database. */
@@ -4988,6 +4984,15 @@ sdb_engine_add_new_symbol (SymbolDBEngine * dbe, const tagEntry * tag_entry,
 
 	g_return_val_if_fail (tag_entry != NULL, -1);
 
+
+	if (priv->symbols_scanned_count++ % 10000 == 0)
+	{
+		gda_connection_commit_transaction (priv->db_connection, "symboltrans",
+		    NULL);
+		gda_connection_begin_transaction (priv->db_connection, "symboltrans",
+	    			GDA_TRANSACTION_ISOLATION_READ_UNCOMMITTED, NULL);
+	}
+	
 	/* parse the entry name */
 	name = tag_entry->name;
 	file_position = tag_entry->address.lineNumber;
diff --git a/plugins/symbol-db/symbol-db-engine-core.h b/plugins/symbol-db/symbol-db-engine-core.h
index 35dd2aa..fe8c50d 100644
--- a/plugins/symbol-db/symbol-db-engine-core.h
+++ b/plugins/symbol-db/symbol-db-engine-core.h
@@ -107,9 +107,6 @@ symbol_db_engine_set_ctags_path (SymbolDBEngine *dbe,
  *        directory of /home/user/project/foo_prj/. On db it'll be represented as
  *        src/file.c. In this way you can move around the project dir without dealing
  *        with relative paths.
- * @param force_tablemaps Defaults to FALSE. Set this to TRUE if you want all
- *        scans to use the tablemaps method. This could be useful for global db
- *        but not for project one.
  */
 #define DB_OPEN_STATUS_FATAL		-1
 #define DB_OPEN_STATUS_NORMAL		0
@@ -117,7 +114,7 @@ symbol_db_engine_set_ctags_path (SymbolDBEngine *dbe,
 #define DB_OPEN_STATUS_UPGRADE		2
 gint
 symbol_db_engine_open_db (SymbolDBEngine *dbe, const gchar* base_db_path,
-						  const gchar * prj_directory, gboolean force_tablemaps);
+						  const gchar * prj_directory);
 
 /** Disconnect db, gda client and db_connection */
 gboolean 
diff --git a/plugins/symbol-db/symbol-db-engine-priv.h b/plugins/symbol-db/symbol-db-engine-priv.h
index 76d914d..7b6c165 100644
--- a/plugins/symbol-db/symbol-db-engine-priv.h
+++ b/plugins/symbol-db/symbol-db-engine-priv.h
@@ -290,7 +290,7 @@ struct _SymbolDBEnginePriv
 	GList *removed_launchers;
 	gboolean shutting_down;
 	gboolean is_first_population;
-	gboolean is_tablemaps_forced;
+	gsize symbols_scanned_count;
 	
 	GMutex* mutex;
 	GAsyncQueue* signals_queue;



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