[gegl] gegl-stats: add active-threads stat
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-stats: add active-threads stat
- Date: Sat, 20 Jul 2019 21:00:34 +0000 (UTC)
commit 6a3a6314d4d4cd668e0f6164afc0fde8b9c7c001
Author: Ell <ell_se yahoo com>
Date: Sat Jul 20 23:46:50 2019 +0300
gegl-stats: add active-threads stat
... which reports the number of currently-active worker threads.
Note that this doesn't include the calling thread, which also
participates in processing, hence this is usually one thread fewer
than the actual number of active thredas.
gegl/gegl-parallel-private.h | 5 +++++
gegl/gegl-parallel.c | 10 ++++++++++
gegl/gegl-stats.c | 31 ++++++++++++++++++++++++++++++-
3 files changed, 45 insertions(+), 1 deletion(-)
---
diff --git a/gegl/gegl-parallel-private.h b/gegl/gegl-parallel-private.h
index c7840e9f8..5d5c69f50 100644
--- a/gegl/gegl-parallel-private.h
+++ b/gegl/gegl-parallel-private.h
@@ -32,6 +32,11 @@ gint gegl_parallel_distribute_get_optimal_n_threads (gdouble n_elements,
gdouble thread_cost);
+/* stats */
+
+gint gegl_parallel_get_n_active_worker_threads (void);
+
+
G_END_DECLS
diff --git a/gegl/gegl-parallel.c b/gegl/gegl-parallel.c
index c699633ff..6b191e8a3 100644
--- a/gegl/gegl-parallel.c
+++ b/gegl/gegl-parallel.c
@@ -359,6 +359,16 @@ gegl_parallel_distribute_area (const GeglRectangle *area,
}
+/* public functions (stats) */
+
+
+gint
+gegl_parallel_get_n_active_worker_threads (void)
+{
+ return gegl_parallel_distribute_completion_counter;
+}
+
+
/* private functions */
diff --git a/gegl/gegl-stats.c b/gegl/gegl-stats.c
index d10a81347..ff2855542 100644
--- a/gegl/gegl-stats.c
+++ b/gegl/gegl-stats.c
@@ -28,6 +28,7 @@
#include "buffer/gegl-tile-handler-cache.h"
#include "buffer/gegl-tile-backend-swap.h"
#include "buffer/gegl-tile-handler-zoom.h"
+#include "gegl-parallel-private.h"
#include "gegl-stats.h"
@@ -52,7 +53,9 @@ enum
PROP_SWAP_WRITE_TOTAL,
PROP_ZOOM_TOTAL,
PROP_TILE_ALLOC_TOTAL,
- PROP_SCRATCH_TOTAL
+ PROP_SCRATCH_TOTAL,
+ PROP_ACTIVE_THREADS,
+ PROP_MALLOC_N
};
@@ -214,6 +217,20 @@ gegl_stats_class_init (GeglStatsClass *klass)
"Total size of scratch memory",
0, G_MAXUINT64, 0,
G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class, PROP_ACTIVE_THREADS,
+ g_param_spec_int ("active-threads",
+ "Active threads",
+ "Number of active worker threads",
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class, PROP_MALLOC_N,
+ g_param_spec_int ("malloc-n",
+ "Malloc n",
+ "Number of buffers currently allocated using
gegl_malloc()",
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
}
static void
@@ -319,6 +336,18 @@ gegl_stats_get_property (GObject *object,
g_value_set_uint64 (value, gegl_scratch_get_total ());
break;
+ case PROP_ACTIVE_THREADS:
+ g_value_set_int (value, gegl_parallel_get_n_active_worker_threads ());
+ break;
+
+ case PROP_MALLOC_N:
+ {
+ extern volatile gint gegl_malloc_n;
+
+ g_value_set_int (value, gegl_malloc_n);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]