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.
2020-04-08 22:27:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
struct mpv_global;
|
|
|
|
struct mpv_node;
|
|
|
|
struct stats_ctx;
|
|
|
|
|
|
|
|
void stats_global_init(struct mpv_global *global);
|
|
|
|
void stats_global_query(struct mpv_global *global, struct mpv_node *out);
|
|
|
|
|
|
|
|
// stats_ctx can be free'd with ta_free(), or by using the ta_parent.
|
|
|
|
struct stats_ctx *stats_ctx_create(void *ta_parent, struct mpv_global *global,
|
|
|
|
const char *prefix);
|
|
|
|
|
|
|
|
// A static numeric value.
|
|
|
|
void stats_value(struct stats_ctx *ctx, const char *name, double val);
|
|
|
|
|
|
|
|
// Like stats_value(), but render as size in bytes.
|
|
|
|
void stats_size_value(struct stats_ctx *ctx, const char *name, double val);
|
|
|
|
|
|
|
|
// Report the real time and CPU time in seconds between _start and _end calls
|
|
|
|
// as value, and report the average and number of all times.
|
|
|
|
void stats_time_start(struct stats_ctx *ctx, const char *name);
|
|
|
|
void stats_time_end(struct stats_ctx *ctx, const char *name);
|
|
|
|
|
2020-04-09 22:55:39 +00:00
|
|
|
// Display number of events per poll period.
|
|
|
|
void stats_event(struct stats_ctx *ctx, const char *name);
|
|
|
|
|
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.
2020-04-08 22:27:54 +00:00
|
|
|
// Report the thread's CPU time. This needs to be called only once per thread.
|
|
|
|
// The current thread is assumed to stay valid until the stats_ctx is destroyed
|
|
|
|
// or stats_unregister_thread() is called, otherwise UB will occur.
|
|
|
|
void stats_register_thread_cputime(struct stats_ctx *ctx, const char *name);
|
|
|
|
|
2023-10-22 00:34:42 +00:00
|
|
|
// Remove reference to the current thread.
|
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.
2020-04-08 22:27:54 +00:00
|
|
|
void stats_unregister_thread(struct stats_ctx *ctx, const char *name);
|