[gegl] gegl-stats: add assigned-threads stat
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-stats: add assigned-threads stat
- Date: Tue, 23 Jul 2019 14:15:09 +0000 (UTC)
commit fc532f06773bd292c86abee31ac18f62e26d39df
Author: Ell <ell_se yahoo com>
Date: Tue Jul 23 17:09:27 2019 +0300
gegl-stats: add assigned-threads stat
... which reports the number of worker threads which currently have
work assigned. This can be larger than active-threads, if worker
threads that have been assigned work had already finished it, but
the operation as a whole is not finished yet.
gegl/gegl-parallel-private.h | 1 +
gegl/gegl-parallel.c | 11 +++++++++++
gegl/gegl-stats.c | 12 ++++++++++++
3 files changed, 24 insertions(+)
---
diff --git a/gegl/gegl-parallel-private.h b/gegl/gegl-parallel-private.h
index 5d5c69f50..e355959b6 100644
--- a/gegl/gegl-parallel-private.h
+++ b/gegl/gegl-parallel-private.h
@@ -34,6 +34,7 @@ gint gegl_parallel_distribute_get_optimal_n_threads (gdouble n_elements,
/* stats */
+gint gegl_parallel_get_n_assigned_worker_threads (void);
gint gegl_parallel_get_n_active_worker_threads (void);
diff --git a/gegl/gegl-parallel.c b/gegl/gegl-parallel.c
index 9012c1c6c..8703b3de1 100644
--- a/gegl/gegl-parallel.c
+++ b/gegl/gegl-parallel.c
@@ -74,6 +74,7 @@ static GMutex gegl_parallel_distribute_completion_mutex;
static GCond gegl_parallel_distribute_completion_cond;
static volatile gint gegl_parallel_distribute_completion_counter;
static volatile gint gegl_parallel_distribute_busy;
+static gint gegl_parallel_distribute_n_assigned_threads;
static gdouble gegl_parallel_distribute_thread_time;
@@ -173,6 +174,8 @@ gegl_parallel_distribute (gint max_n,
task.func = func;
task.user_data = user_data;
+ gegl_parallel_distribute_n_assigned_threads = task.n - 1;
+
g_atomic_int_set (&gegl_parallel_distribute_completion_counter, task.n - 1);
for (i = 0; i < task.n - 1; i++)
@@ -205,6 +208,8 @@ gegl_parallel_distribute (gint max_n,
g_mutex_unlock (&gegl_parallel_distribute_completion_mutex);
}
+ gegl_parallel_distribute_n_assigned_threads = 0;
+
g_atomic_int_set (&gegl_parallel_distribute_busy, 0);
}
@@ -362,6 +367,12 @@ gegl_parallel_distribute_area (const GeglRectangle *area,
/* public functions (stats) */
+gint
+gegl_parallel_get_n_assigned_worker_threads (void)
+{
+ return gegl_parallel_distribute_n_assigned_threads;
+}
+
gint
gegl_parallel_get_n_active_worker_threads (void)
{
diff --git a/gegl/gegl-stats.c b/gegl/gegl-stats.c
index bad4a194b..e336ee555 100644
--- a/gegl/gegl-stats.c
+++ b/gegl/gegl-stats.c
@@ -54,6 +54,7 @@ enum
PROP_ZOOM_TOTAL,
PROP_TILE_ALLOC_TOTAL,
PROP_SCRATCH_TOTAL,
+ PROP_ASSIGNED_THREADS,
PROP_ACTIVE_THREADS
};
@@ -217,6 +218,13 @@ gegl_stats_class_init (GeglStatsClass *klass)
0, G_MAXUINT64, 0,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_ASSIGNED_THREADS,
+ g_param_spec_int ("assigned-threads",
+ "Assigned threads",
+ "Number of assigned worker threads",
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
+
g_object_class_install_property (object_class, PROP_ACTIVE_THREADS,
g_param_spec_int ("active-threads",
"Active threads",
@@ -328,6 +336,10 @@ gegl_stats_get_property (GObject *object,
g_value_set_uint64 (value, gegl_scratch_get_total ());
break;
+ case PROP_ASSIGNED_THREADS:
+ g_value_set_int (value, gegl_parallel_get_n_assigned_worker_threads ());
+ break;
+
case PROP_ACTIVE_THREADS:
g_value_set_int (value, gegl_parallel_get_n_active_worker_threads ());
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]