summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-09 00:27:54 +0200
committerwm4 <wm4@nowhere>2020-04-09 00:33:38 +0200
commitfd3caa264ea0848e7e30db94390063c87e247003 (patch)
tree3eb8268c1afc7a0bab5a544e4664cce23d2ab712 /demux
parentc5f8ec76b16268b05d1e3af8f1931eddf5165b8b (diff)
downloadmpv-fd3caa264ea0848e7e30db94390063c87e247003.tar.bz2
mpv-fd3caa264ea0848e7e30db94390063c87e247003.tar.xz
stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in some places. Add rendering of them to stats.lua. There were two main goals: minimal impact on the normal code and normal playback. So all these stats_* function calls either happen only during initialization, or return immediately if no stats collection is going on. That's why it does this lazily adding of stats entries etc. (a first iteration made each stats entry an API thing, instead of just a single stats_ctx, but I thought that was getting too intrusive in the "normal" code, even if everything gets worse inside of stats.c). You could get most of this information from various profilers (including the extremely primitive --dump-stats thing in mpv), but this makes it easier to see the most important information at once (at least in theory), partially because we know best about the context of various things. Not very happy with this. It's all pretty primitive and dumb. At this point I just wanted to get over with it, without necessarily having to revisit it later, but with having my stupid statistics. Somehow the code feels terrible. There are a lot of meh decisions in there that could be better or worse (but mostly could be better), and it just sucks but it's also trivial and uninteresting and does the job. I guess I hate programming. It's so tedious and the result is always shit. Anyway, enjoy.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 1922f68397..ad1a72ac5d 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -39,6 +39,7 @@
#include "common/msg.h"
#include "common/global.h"
#include "common/recorder.h"
+#include "common/stats.h"
#include "misc/charset_conv.h"
#include "misc/thread_tools.h"
#include "osdep/atomic.h"
@@ -167,6 +168,7 @@ const struct m_sub_options demux_conf = {
struct demux_internal {
struct mp_log *log;
struct mpv_global *global;
+ struct stats_ctx *stats;
bool can_cache; // not a slave demuxer; caching makes sense
bool can_record; // stream recording is allowed
@@ -2551,6 +2553,8 @@ static void *demux_thread(void *pctx)
mpthread_set_name("demux");
pthread_mutex_lock(&in->lock);
+ stats_register_thread_cputime(in->stats, "thread");
+
while (!in->thread_terminate) {
if (thread_work(in))
continue;
@@ -2568,6 +2572,8 @@ static void *demux_thread(void *pctx)
in->wakeup_cb(in->wakeup_cb_ctx);
}
+ stats_unregister_thread(in->stats, "thread");
+
pthread_mutex_unlock(&in->lock);
return NULL;
}
@@ -3262,6 +3268,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
*in = (struct demux_internal){
.global = global,
.log = demuxer->log,
+ .stats = stats_ctx_create(in, global, "demuxer"),
.can_cache = params && params->is_top_level,
.can_record = params && params->stream_record,
.opts = opts,