[tracker/cpuaffinity] tracker-store: Experimental CPU affinity setting
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/cpuaffinity] tracker-store: Experimental CPU affinity setting
- Date: Thu, 24 Jun 2010 12:35:16 +0000 (UTC)
commit b45ac9edc1dab9c29c92530b78d0e0d7efd3b54c
Author: Jürg Billeter <j bitron ch>
Date: Thu Jun 24 14:34:45 2010 +0200
tracker-store: Experimental CPU affinity setting
src/tracker-store/tracker-store.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 8b1c24c..cc6aa04 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -21,6 +21,10 @@
#include "config.h"
+#define _GNU_SOURCE
+#include <sched.h>
+#include <pthread.h>
+
#include <unistd.h>
#include <sys/types.h>
@@ -104,6 +108,8 @@ typedef struct {
static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+static int cpu;
+
static void start_handler (TrackerStorePrivate *private);
static void
@@ -445,6 +451,15 @@ pool_dispatch_cb (gpointer data,
TrackerStorePrivate *private;
TrackerStoreTask *task;
+ if (GPOINTER_TO_INT (data) == 1) {
+ cpu_set_t cpuset;
+ CPU_ZERO (&cpuset);
+ CPU_SET (cpu, &cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+
+ return;
+ }
+
private = user_data;
task = data;
@@ -629,6 +644,13 @@ tracker_store_init (void)
g_thread_pool_set_max_idle_time (15 * 1000);
g_thread_pool_set_max_unused_threads (2);
+ cpu_set_t cpuset;
+ cpu = sched_getcpu ();
+ CPU_ZERO (&cpuset);
+ CPU_SET (cpu, &cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ g_thread_pool_push (private->main_pool, GINT_TO_POINTER (1), NULL);
+
g_static_private_set (&private_key,
private,
private_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]