Detect large flushes (>10 ms)

This commit is contained in:
Rodrigo Arias 2023-02-21 15:40:54 +01:00 committed by Rodrigo Arias Mallo
parent 933b0f48f9
commit 80eb1f3bdd

View File

@ -390,7 +390,7 @@ static int
pre_flush(struct emu *emu) pre_flush(struct emu *emu)
{ {
struct ovni_thread *th = EXT(emu->thread, 'O'); struct ovni_thread *th = EXT(emu->thread, 'O');
struct chan *flush = &th->ch[CH_FLUSH]; struct chan *flush = &th->m.ch[CH_FLUSH];
switch (emu->ev->v) { switch (emu->ev->v) {
case '[': case '[':
@ -398,12 +398,21 @@ pre_flush(struct emu *emu)
err("chan_set failed"); err("chan_set failed");
return -1; return -1;
} }
th->flush_start = emu->ev->dclock;
break; break;
case ']': case ']':
if (chan_set(flush, value_null()) != 0) { if (chan_set(flush, value_null()) != 0) {
err("chan_set failed"); err("chan_set failed");
return -1; return -1;
} }
int64_t flush_ns = emu->ev->dclock - th->flush_start;
double flush_ms = (double) flush_ns * 1e-6;
/* Avoid last flush warnings */
if (flush_ms > 10.0 && emu->thread->is_running)
warn("large flush of %.1f ms at dclock=%ld ns in tid=%d",
flush_ms,
emu->ev->dclock,
emu->thread->tid);
break; break;
default: default:
err("unexpected value '%c' (expecting '[' or ']')\n", err("unexpected value '%c' (expecting '[' or ']')\n",