2013-11-20 07:22:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* gstrusage.c: tracing module that logs resource usage stats
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2014-07-16 16:48:52 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstrusage
|
|
|
|
* @short_description: log resource usage stats
|
|
|
|
*
|
2016-01-12 13:59:04 +00:00
|
|
|
* A tracing module that take rusage() snapshots and logs them.
|
2014-07-16 16:48:52 +00:00
|
|
|
*/
|
2013-11-20 07:22:58 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-09-11 11:02:51 +00:00
|
|
|
#include <unistd.h>
|
2013-11-20 07:22:58 +00:00
|
|
|
#include "gstrusage.h"
|
|
|
|
|
2015-10-07 10:22:34 +00:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
2014-09-11 11:02:51 +00:00
|
|
|
#ifndef __USE_GNU
|
|
|
|
# define __USE_GNU /* RUSAGE_THREAD */
|
|
|
|
#endif
|
2013-11-20 07:22:58 +00:00
|
|
|
#include <sys/resource.h>
|
2015-10-07 10:22:34 +00:00
|
|
|
#endif
|
2013-11-20 07:22:58 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_rusage_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_rusage_debug
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
G_LOCK_DEFINE (_proc);
|
|
|
|
|
2013-11-20 07:22:58 +00:00
|
|
|
#define _do_init \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_rusage_debug, "rusage", 0, "rusage tracer");
|
|
|
|
#define gst_rusage_tracer_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstRUsageTracer, gst_rusage_tracer, GST_TYPE_TRACER,
|
|
|
|
_do_init);
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
/* remember x measurements per self->window */
|
2014-09-10 05:55:33 +00:00
|
|
|
#define WINDOW_SUBDIV 100
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
/* number of cpus to scale cpu-usage in threads */
|
2014-09-11 11:02:51 +00:00
|
|
|
static glong num_cpus = 1;
|
2014-07-28 20:08:49 +00:00
|
|
|
|
2016-01-12 13:59:04 +00:00
|
|
|
static GstTracerRecord *tr_proc, *tr_thread;
|
|
|
|
|
2013-11-20 07:22:58 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* time spend in this thread */
|
2014-07-28 20:08:49 +00:00
|
|
|
GstClockTime tthread;
|
2014-09-10 05:55:33 +00:00
|
|
|
GstTraceValues *tvs_thread;
|
2013-11-20 07:22:58 +00:00
|
|
|
} GstThreadStats;
|
|
|
|
|
|
|
|
/* data helper */
|
|
|
|
|
2014-09-10 05:55:33 +00:00
|
|
|
static void
|
|
|
|
free_trace_value (gpointer data)
|
|
|
|
{
|
|
|
|
g_slice_free (GstTraceValue, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstTraceValues *
|
|
|
|
make_trace_values (GstClockTime window)
|
|
|
|
{
|
|
|
|
GstTraceValues *self = g_slice_new0 (GstTraceValues);
|
|
|
|
self->window = window;
|
|
|
|
g_queue_init (&self->values);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_trace_values (GstTraceValues * self)
|
|
|
|
{
|
2016-04-13 09:38:05 +00:00
|
|
|
g_queue_foreach (&self->values, (GFunc) free_trace_value, NULL);
|
|
|
|
g_queue_clear (&self->values);
|
2014-09-10 05:55:33 +00:00
|
|
|
g_slice_free (GstTraceValues, self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
update_trace_value (GstTraceValues * self, GstClockTime nts,
|
|
|
|
GstClockTime nval, GstClockTime * dts, GstClockTime * dval)
|
|
|
|
{
|
|
|
|
GstTraceValue *lv;
|
|
|
|
GstClockTimeDiff dt;
|
|
|
|
GstClockTime window = self->window;
|
|
|
|
GQueue *q = &self->values;
|
|
|
|
GList *node = q->tail;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
/* search from the tail of the queue for a good GstTraceValue */
|
|
|
|
while (node) {
|
|
|
|
lv = node->data;
|
|
|
|
dt = GST_CLOCK_DIFF (lv->ts, nts);
|
|
|
|
if (dt < window) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
node = g_list_previous (node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node) {
|
|
|
|
/* calculate the windowed value */
|
|
|
|
*dts = dt;
|
|
|
|
*dval = GST_CLOCK_DIFF (lv->val, nval);
|
|
|
|
|
|
|
|
/* drop all older measurements */
|
|
|
|
while (q->tail != node) {
|
|
|
|
free_trace_value (g_queue_pop_tail (q));
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
} else {
|
|
|
|
*dts = nts;
|
|
|
|
*dval = nval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't push too many data items */
|
|
|
|
lv = q->head ? q->head->data : NULL;
|
|
|
|
if (!lv || (GST_CLOCK_DIFF (lv->ts, nts) > (window / WINDOW_SUBDIV))) {
|
|
|
|
/* push the new measurement */
|
|
|
|
lv = g_slice_new0 (GstTraceValue);
|
|
|
|
lv->ts = nts;
|
|
|
|
lv->val = nval;
|
|
|
|
g_queue_push_head (q, lv);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-20 07:22:58 +00:00
|
|
|
static void
|
|
|
|
free_thread_stats (gpointer data)
|
|
|
|
{
|
2014-09-10 05:55:33 +00:00
|
|
|
free_trace_values (((GstThreadStats *) data)->tvs_thread);
|
2013-11-20 07:22:58 +00:00
|
|
|
g_slice_free (GstThreadStats, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_stats (GstTracer * obj, guint64 ts)
|
2013-11-20 07:22:58 +00:00
|
|
|
{
|
|
|
|
GstRUsageTracer *self = GST_RUSAGE_TRACER_CAST (obj);
|
|
|
|
GstThreadStats *stats;
|
|
|
|
gpointer thread_id = g_thread_self ();
|
2014-09-10 05:55:33 +00:00
|
|
|
guint avg_cpuload, cur_cpuload;
|
2013-11-20 07:22:58 +00:00
|
|
|
struct rusage ru;
|
2014-07-28 20:08:49 +00:00
|
|
|
GstClockTime tproc = G_GUINT64_CONSTANT (0);
|
2014-09-11 11:02:51 +00:00
|
|
|
GstClockTime tthread = G_GUINT64_CONSTANT (0);
|
2014-09-10 05:55:33 +00:00
|
|
|
GstClockTime dts, dtproc;
|
2013-11-20 07:22:58 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CLOCK_GETTIME
|
|
|
|
{
|
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
if (!clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &now)) {
|
2014-07-28 20:08:49 +00:00
|
|
|
tproc = GST_TIMESPEC_TO_TIME (now);
|
2013-11-20 07:22:58 +00:00
|
|
|
} else {
|
2014-09-11 11:02:51 +00:00
|
|
|
GST_WARNING_OBJECT (obj,
|
|
|
|
"clock_gettime (CLOCK_PROCESS_CPUTIME_ID,...) failed: %s",
|
|
|
|
g_strerror (errno));
|
|
|
|
getrusage (RUSAGE_SELF, &ru);
|
2014-07-28 20:08:49 +00:00
|
|
|
tproc =
|
2013-11-20 07:22:58 +00:00
|
|
|
GST_TIMEVAL_TO_TIME (ru.ru_utime) + GST_TIMEVAL_TO_TIME (ru.ru_stime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cpu time per thread */
|
|
|
|
if (!clock_gettime (CLOCK_THREAD_CPUTIME_ID, &now)) {
|
2014-09-11 11:02:51 +00:00
|
|
|
tthread = GST_TIMESPEC_TO_TIME (now);
|
2013-11-20 07:22:58 +00:00
|
|
|
} else {
|
2014-09-11 11:02:51 +00:00
|
|
|
GST_WARNING_OBJECT (obj,
|
|
|
|
"clock_gettime (CLOCK_THREAD_CPUTIME_ID,...) failed: %s",
|
|
|
|
g_strerror (errno));
|
2015-10-07 10:21:56 +00:00
|
|
|
#ifdef RUSAGE_THREAD
|
2014-09-11 11:02:51 +00:00
|
|
|
getrusage (RUSAGE_THREAD, &ru);
|
|
|
|
tthread =
|
|
|
|
GST_TIMEVAL_TO_TIME (ru.ru_utime) + GST_TIMEVAL_TO_TIME (ru.ru_stime);
|
2015-10-07 10:21:56 +00:00
|
|
|
#endif
|
2013-11-20 07:22:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2014-09-11 11:02:51 +00:00
|
|
|
getrusage (RUSAGE_SELF, &ru);
|
2014-07-28 20:08:49 +00:00
|
|
|
tproc = GST_TIMEVAL_TO_TIME (ru.ru_utime) + GST_TIMEVAL_TO_TIME (ru.ru_stime);
|
2015-10-07 10:21:56 +00:00
|
|
|
#ifdef RUSAGE_THREAD
|
2014-09-11 11:02:51 +00:00
|
|
|
getrusage (RUSAGE_THREAD, &ru);
|
|
|
|
tthread =
|
|
|
|
GST_TIMEVAL_TO_TIME (ru.ru_utime) + GST_TIMEVAL_TO_TIME (ru.ru_stime);
|
2015-10-07 10:21:56 +00:00
|
|
|
#endif
|
2013-11-20 07:22:58 +00:00
|
|
|
#endif
|
2014-09-11 11:02:51 +00:00
|
|
|
/* get stats record for current thread */
|
|
|
|
if (!(stats = g_hash_table_lookup (self->threads, thread_id))) {
|
|
|
|
stats = g_slice_new0 (GstThreadStats);
|
|
|
|
stats->tvs_thread = make_trace_values (GST_SECOND);
|
|
|
|
g_hash_table_insert (self->threads, thread_id, stats);
|
|
|
|
}
|
|
|
|
stats->tthread = tthread;
|
2013-11-20 07:22:58 +00:00
|
|
|
|
2014-07-28 20:08:49 +00:00
|
|
|
/* Calibrate ts for the process and main thread. For tthread[main] and tproc
|
|
|
|
* the time is larger than ts, as our base-ts is taken after the process has
|
|
|
|
* started.
|
|
|
|
*/
|
2014-09-17 06:38:02 +00:00
|
|
|
if (G_UNLIKELY (thread_id == self->main_thread_id)) {
|
|
|
|
self->main_thread_id = NULL;
|
2014-07-28 20:08:49 +00:00
|
|
|
/* when the registry gets updated, the tproc is less than the debug time ? */
|
|
|
|
/* TODO(ensonic): we still see cases where tproc overtakes ts, especially
|
|
|
|
* when with sync=false, can this be due to multiple cores in use? */
|
|
|
|
if (tproc > ts) {
|
2014-09-17 06:38:02 +00:00
|
|
|
self->tproc_base = tproc - ts;
|
2014-07-28 20:08:49 +00:00
|
|
|
GST_DEBUG ("rusage: calibrating by %" G_GUINT64_FORMAT ", thread: %"
|
|
|
|
G_GUINT64_FORMAT ", proc: %" G_GUINT64_FORMAT,
|
2014-09-17 06:38:02 +00:00
|
|
|
self->tproc_base, stats->tthread, tproc);
|
|
|
|
stats->tthread -= self->tproc_base;
|
2014-07-28 20:08:49 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-10 05:55:33 +00:00
|
|
|
/* we always need to correct proc time */
|
2014-09-17 06:38:02 +00:00
|
|
|
tproc -= self->tproc_base;
|
2013-11-20 07:22:58 +00:00
|
|
|
|
|
|
|
/* FIXME: how can we take cpu-frequency scaling into account?
|
|
|
|
* - looking at /sys/devices/system/cpu/cpu0/cpufreq/
|
|
|
|
* scale_factor=scaling_max_freq/scaling_cur_freq
|
|
|
|
* - as a workaround we can switch it via /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
|
|
|
* cpufreq-selector -g performance
|
|
|
|
* cpufreq-selector -g ondemand
|
|
|
|
*/
|
2014-09-04 08:11:52 +00:00
|
|
|
/* *INDENT-OFF* */
|
2014-09-10 05:55:33 +00:00
|
|
|
avg_cpuload = (guint) gst_util_uint64_scale (stats->tthread,
|
2014-09-11 11:02:51 +00:00
|
|
|
G_GINT64_CONSTANT (1000), ts);
|
2014-09-10 05:55:33 +00:00
|
|
|
update_trace_value (stats->tvs_thread, ts, stats->tthread, &dts, &dtproc);
|
2014-09-11 11:02:51 +00:00
|
|
|
cur_cpuload = (guint) gst_util_uint64_scale (dtproc,
|
|
|
|
G_GINT64_CONSTANT (1000), dts);
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_thread, (guint64) (guintptr) thread_id, ts,
|
2016-01-12 13:59:04 +00:00
|
|
|
MIN (avg_cpuload, 1000), MIN (cur_cpuload, 1000), stats->tthread);
|
2014-09-10 05:55:33 +00:00
|
|
|
|
2014-09-11 11:02:51 +00:00
|
|
|
avg_cpuload = (guint) gst_util_uint64_scale (tproc / num_cpus,
|
|
|
|
G_GINT64_CONSTANT (1000), ts);
|
2014-09-17 06:38:02 +00:00
|
|
|
G_LOCK (_proc);
|
|
|
|
update_trace_value (self->tvs_proc, ts, tproc, &dts, &dtproc);
|
|
|
|
G_UNLOCK (_proc);
|
2014-09-11 11:02:51 +00:00
|
|
|
cur_cpuload = (guint) gst_util_uint64_scale (dtproc / num_cpus,
|
|
|
|
G_GINT64_CONSTANT (1000), dts);
|
2016-10-08 11:20:58 +00:00
|
|
|
gst_tracer_record_log (tr_proc, (guint64) getpid (), ts,
|
|
|
|
MIN (avg_cpuload, 1000), MIN (cur_cpuload, 1000), tproc);
|
2014-09-04 08:11:52 +00:00
|
|
|
/* *INDENT-ON* */
|
2013-11-20 07:22:58 +00:00
|
|
|
}
|
2014-09-15 11:15:17 +00:00
|
|
|
|
|
|
|
/* tracer class */
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
static void
|
|
|
|
gst_rusage_tracer_finalize (GObject * obj)
|
|
|
|
{
|
|
|
|
GstRUsageTracer *self = GST_RUSAGE_TRACER (obj);
|
|
|
|
|
|
|
|
g_hash_table_destroy (self->threads);
|
|
|
|
free_trace_values (self->tvs_proc);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:15:17 +00:00
|
|
|
static void
|
|
|
|
gst_rusage_tracer_class_init (GstRUsageTracerClass * klass)
|
|
|
|
{
|
2014-09-17 06:38:02 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->finalize = gst_rusage_tracer_finalize;
|
|
|
|
|
|
|
|
if ((num_cpus = sysconf (_SC_NPROCESSORS_ONLN)) == -1) {
|
|
|
|
GST_WARNING ("failed to get number of cpus online");
|
|
|
|
if ((num_cpus = sysconf (_SC_NPROCESSORS_CONF)) == -1) {
|
|
|
|
GST_WARNING ("failed to get number of cpus, assuming 1");
|
|
|
|
num_cpus = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GST_DEBUG ("rusage: num_cpus=%ld", num_cpus);
|
|
|
|
|
2014-09-15 11:15:17 +00:00
|
|
|
/* announce trace formats */
|
|
|
|
/* *INDENT-OFF* */
|
2016-01-21 07:12:01 +00:00
|
|
|
tr_thread = gst_tracer_record_new ("thread-rusage.class",
|
2014-09-15 11:15:17 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"average-cpuload", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
|
|
|
"description", G_TYPE_STRING, "average cpu usage per thread in ‰",
|
2016-01-16 17:52:32 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_AGGREGATED,
|
2016-01-12 13:59:04 +00:00
|
|
|
"min", G_TYPE_UINT, 0,
|
2014-09-15 11:15:17 +00:00
|
|
|
"max", G_TYPE_UINT, 1000,
|
|
|
|
NULL),
|
|
|
|
"current-cpuload", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
|
|
|
"description", G_TYPE_STRING, "current cpu usage per thread in ‰",
|
2016-01-12 13:59:04 +00:00
|
|
|
"min", G_TYPE_UINT, 0,
|
2014-09-15 11:15:17 +00:00
|
|
|
"max", G_TYPE_UINT, 1000,
|
|
|
|
NULL),
|
|
|
|
"time", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "time spent in thread in ns",
|
2016-01-16 17:52:32 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_AGGREGATED,
|
2014-09-15 11:15:17 +00:00
|
|
|
"min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
|
|
|
"max", G_TYPE_UINT64, G_MAXUINT64,
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_proc = gst_tracer_record_new ("proc-rusage.class",
|
2016-10-08 11:20:58 +00:00
|
|
|
"process-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PROCESS,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"average-cpuload", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
|
|
|
"description", G_TYPE_STRING, "average cpu usage per process in ‰",
|
2016-01-16 17:52:32 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_AGGREGATED,
|
2016-01-12 13:59:04 +00:00
|
|
|
"min", G_TYPE_UINT, 0,
|
2014-09-15 11:15:17 +00:00
|
|
|
"max", G_TYPE_UINT, 1000,
|
|
|
|
NULL),
|
|
|
|
"current-cpuload", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
|
|
|
"description", G_TYPE_STRING, "current cpu usage per process in ‰",
|
2016-01-12 13:59:04 +00:00
|
|
|
"min", G_TYPE_UINT, 0,
|
2014-09-15 11:15:17 +00:00
|
|
|
"max", G_TYPE_UINT, 1000,
|
|
|
|
NULL),
|
|
|
|
"time", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "time spent in process in ns",
|
2016-01-16 17:52:32 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_AGGREGATED,
|
2014-09-15 11:15:17 +00:00
|
|
|
"min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
|
|
|
"max", G_TYPE_UINT64, G_MAXUINT64,
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
2014-09-15 11:15:17 +00:00
|
|
|
/* *INDENT-ON* */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rusage_tracer_init (GstRUsageTracer * self)
|
|
|
|
{
|
|
|
|
GstTracer *tracer = GST_TRACER (self);
|
|
|
|
|
2016-01-06 19:41:26 +00:00
|
|
|
gst_tracing_register_hook (tracer, NULL, G_CALLBACK (do_stats));
|
2014-09-15 11:15:17 +00:00
|
|
|
|
|
|
|
self->threads = g_hash_table_new_full (NULL, NULL, NULL, free_thread_stats);
|
2014-09-17 06:38:02 +00:00
|
|
|
self->tvs_proc = make_trace_values (GST_SECOND);
|
|
|
|
self->main_thread_id = g_thread_self ();
|
2014-09-15 11:15:17 +00:00
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
GST_DEBUG ("rusage: main thread=%p", self->main_thread_id);
|
2014-09-15 11:15:17 +00:00
|
|
|
}
|