[tracker/wal: 17/24] tracker-store: Allow disabling CPU affinity with env var



commit 981508330e1a9d36ed48a6dccaf0a0e6555088f6
Author: Martyn Russell <martyn lanedo com>
Date:   Thu Jul 22 13:28:41 2010 +0100

    tracker-store: Allow disabling CPU affinity with env var
    
    Variable name is: TRACKER_STORE_DISABLE_CPU_AFFINITY

 docs/manpages/tracker-store.1     |    9 ++++++++
 src/tracker-store/tracker-store.c |   42 ++++++++++++++++++++----------------
 2 files changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/docs/manpages/tracker-store.1 b/docs/manpages/tracker-store.1
index 8747bff..84eaf2e 100644
--- a/docs/manpages/tracker-store.1
+++ b/docs/manpages/tracker-store.1
@@ -81,6 +81,15 @@ happens. The actual moment of interruption depends also on the frequency of
 checks. The value 0 indicates no interruption.
 This environment variable is used mainly for testing purposes.
 
+.TP
+.B TRACKER_STORE_DISABLE_CPU_AFFINITY
+Tracker currently uses CPU affinity to improve query times by making
+sure that certain operations are done on the same CPU. This is only
+useful on multi processor systems of course and on some architectures
+has given a yeild of up to 50% performance improvement. The main
+reason for wanting to disable this is if there is an adverse effect.
+This has been seen by using Valgrind with tracker-store for example.
+
 .SH FILES
 .I $HOME/.config/tracker/tracker-store.cfg
 .I $HOME/.config/tracker/tracker-fts.cfg
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 82154fe..e9b5180 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -342,16 +342,18 @@ pool_dispatch_cb (gpointer data,
 	TrackerStoreTask *task;
 
 #ifdef __USE_GNU
-	/* special task, only ever sent to main pool */
-	if (GPOINTER_TO_INT (data) == 1) {
-		cpu_set_t cpuset;
-		CPU_ZERO (&cpuset);
-		CPU_SET (main_cpu, &cpuset);
-
-		/* avoid cpu hopping which can lead to significantly worse performance */
-		pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
-		return;
-	}
+        /* special task, only ever sent to main pool */
+        if (GPOINTER_TO_INT (data) == 1) {
+                if (g_getenv ("TRACKER_STORE_DISABLE_CPU_AFFINITY") == NULL) {
+                        cpu_set_t cpuset;
+                        CPU_ZERO (&cpuset);
+                        CPU_SET (main_cpu, &cpuset);
+
+                        /* avoid cpu hopping which can lead to significantly worse performance */
+                        pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+                        return;
+                }
+        }
 #endif /* __USE_GNU */
 
 	private = user_data;
@@ -423,15 +425,17 @@ tracker_store_init (void)
 	g_thread_pool_set_max_unused_threads (2);
 
 #ifdef __USE_GNU
-	main_cpu = sched_getcpu ();
-	CPU_ZERO (&cpuset);
-	CPU_SET (main_cpu, &cpuset);
-
-	/* avoid cpu hopping which can lead to significantly worse performance */
-	pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
-	/* lock main update/query thread to same cpu to improve overall performance
-	   main loop thread is essentially idle during query execution */
-	g_thread_pool_push (private->update_pool, GINT_TO_POINTER (1), NULL);
+        if (g_getenv ("TRACKER_STORE_DISABLE_CPU_AFFINITY") == NULL) {
+                main_cpu = sched_getcpu ();
+                CPU_ZERO (&cpuset);
+                CPU_SET (main_cpu, &cpuset);
+
+                /* avoid cpu hopping which can lead to significantly worse performance */
+                pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+                /* lock main update/query thread to same cpu to improve overall performance
+                   main loop thread is essentially idle during query execution */
+                g_thread_pool_push (private->update_pool, GINT_TO_POINTER (1), NULL);
+        }
 #endif /* __USE_GNU */
 
 	g_static_private_set (&private_key,



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