void unlang_frame_perf_init(unlang_t const *instruction)
{
unlang_thread_t *t;
+ fr_time_t now;
if (!instruction->number || !unlang_thread_array) return;
t = &unlang_thread_array[instruction->number];
t->use_count++;
+ now = fr_time();
- t->enter = fr_time();
+ fr_time_tracking_start(NULL, &t->tracking, now);
+ fr_time_tracking_yield(&t->tracking, now);
+}
+
+void unlang_frame_perf_yield(unlang_t const *instruction)
+{
+ unlang_thread_t *t;
+
+ if (!instruction->number || !unlang_thread_array) return;
+
+ fr_assert(instruction->number <= unlang_number);
+
+ t = &unlang_thread_array[instruction->number];
+
+ fr_time_tracking_yield(&t->tracking, fr_time());
+}
+
+void unlang_frame_perf_resume(unlang_t const *instruction)
+{
+ unlang_thread_t *t;
+
+ if (!instruction->number || !unlang_thread_array) return;
+
+ fr_assert(instruction->number <= unlang_number);
+
+ t = &unlang_thread_array[instruction->number];
+
+ fr_time_tracking_resume(&t->tracking, fr_time());
}
void unlang_frame_perf_cleanup(unlang_t const *instruction)
t = &unlang_thread_array[instruction->number];
- t->cpu_time = fr_time_add(t->cpu_time, fr_time_sub(fr_time(), t->enter));
+ fr_time_tracking_end(NULL, &t->tracking, fr_time());
}
t = &unlang_thread_array[instruction->number];
- fr_log(log, L_DBG, file, line, "count=%" PRIu64 " cpu_time=%" PRIu64,
- t->use_count, fr_time_delta_unwrap(t->cpu_time));
+ fr_log(log, L_DBG, file, line, "count=%" PRIu64 " cpu_time=%" PRIu64 " yielded_time=%" PRIu64 ,
+ t->use_count, fr_time_delta_unwrap(t->tracking.running_total), fr_time_delta_unwrap(t->tracking.waiting_total));
if (g->children) {
unlang_t *child;
RDEBUG4("** [%i] %s >> %s", stack->depth, __FUNCTION__,
unlang_ops[instruction->type].name);
+ unlang_frame_perf_resume(instruction);
fr_assert(frame->process != NULL);
/*
* should be evaluated again.
*/
repeatable_clear(frame);
+ unlang_frame_perf_resume(frame->instruction);
ua = frame->process(result, request, frame);
/*
* called the interpreter.
*/
case UNLANG_ACTION_YIELD:
+ unlang_frame_perf_yield(instruction);
yielded_set(frame);
RDEBUG4("** [%i] %s - yielding with current (%s %d)", stack->depth, __FUNCTION__,
fr_table_str_by_value(mod_rcode_table, frame->result, "<invalid>"),
void *thread_inst; //!< thread-specific instance data
#ifdef WITH_PERF
uint64_t use_count;
- fr_time_t enter;
-
- fr_time_delta_t cpu_time;
+ fr_time_tracking_t tracking; //!< tracking cpu time
#endif
} unlang_thread_t;
#ifdef WITH_PERF
void unlang_frame_perf_init(unlang_t const *instruction);
-
+void unlang_frame_perf_yield(unlang_t const *instruction);
+void unlang_frame_perf_resume(unlang_t const *instruction);
void unlang_frame_perf_cleanup(unlang_t const *instruction);
#else
#define unlang_frame_perf_init(_x)
+#define unlang_frame_perf_resume(_x)
#define unlang_frame_perf_cleanup(_x)
#endif