#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/time.h>
Go to the source code of this file.
|
#define | ASSERT_ON_TIME_TRAVEL(_tt, _now) |
| We use a monotonic time source. More...
|
|
#define | DPRINT(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_delta_unwrap(tt->_x)) |
|
#define | DPRINT_TIME(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_unwrap(tt->_x)) |
|
#define | IALPHA (8) |
|
#define | RTT(_old, _new) fr_time_delta_wrap((fr_time_delta_unwrap(_new) + (fr_time_delta_unwrap(_old) * (IALPHA - 1))) / IALPHA) |
|
#define | UPDATE_PARENT_RUN_TIME(_tt, _run_time, _event, _now) |
| Update total run time up the list of parents. More...
|
|
#define | UPDATE_PARENT_START_TIME(_tt, _now) |
| Set the last time a tracked entity started in its list of parents. More...
|
|
#define | UPDATE_PARENT_WAIT_TIME(_tt, _wait_time, _event, _now) |
| Update total wait time up the list of parents. More...
|
|
|
static void | fr_time_tracking_debug (fr_time_tracking_t *tt, FILE *fp) |
| Print debug information about the time tracking structure. More...
|
|
static void | fr_time_tracking_end (fr_time_delta_t *predicted, fr_time_tracking_t *tt, fr_time_t now) |
| End time tracking for this entity. More...
|
|
static void | fr_time_tracking_init (fr_time_tracking_t *tt) |
| Initialise a time tracking structure. More...
|
|
static void | fr_time_tracking_pop (fr_time_tracking_t *tt, fr_time_t now) |
| Tracked entity left a tracked nested code area. More...
|
|
static void | fr_time_tracking_push (fr_time_tracking_t *parent, fr_time_tracking_t *tt, fr_time_t now) |
| Tracked entity entered a deeper time tracked code area. More...
|
|
static void | fr_time_tracking_resume (fr_time_tracking_t *tt, fr_time_t now) |
| Track that a request resumed. More...
|
|
static void | fr_time_tracking_start (fr_time_tracking_t *parent, fr_time_tracking_t *tt, fr_time_t now) |
| Start time tracking for a tracked entity. More...
|
|
static void | fr_time_tracking_yield (fr_time_tracking_t *tt, fr_time_t now) |
| Transition to the yielded state, recording the time we just spent running. More...
|
|
◆ fr_time_tracking_s
struct fr_time_tracking_s |
Definition at line 60 of file time_tracking.h.
Data Fields |
fr_time_t |
ended |
Last time this tracked entity or a child left the running state, or popped a time tracked parent. |
fr_time_t |
last_changed |
last time we changed a field |
fr_time_t |
last_resumed |
Last time this tracked entity or a child resumed;. |
fr_time_t |
last_yielded |
Last time this tracked entity or a child yielded. |
fr_time_tracking_t * |
parent |
To update with our time tracking data when tracking is complete. |
fr_time_delta_t |
running_total |
total time spent running |
fr_time_t |
started |
Last time this tracked entity or a child entered the running state, or entered a time tracked parent. |
fr_time_tracking_state_t |
state |
What state we're currently in. only used for the leaf node.
|
fr_time_delta_t |
waiting_total |
total time spent waiting |
◆ ASSERT_ON_TIME_TRAVEL
#define ASSERT_ON_TIME_TRAVEL |
( |
|
_tt, |
|
|
|
_now |
|
) |
| |
Value:do { \
} while(0)
#define fr_time_lteq(_a, _b)
We use a monotonic time source.
Definition at line 89 of file time_tracking.h.
◆ DPRINT
#define DPRINT |
( |
|
_x | ) |
fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_delta_unwrap(tt->_x)) |
◆ DPRINT_TIME
#define DPRINT_TIME |
( |
|
_x | ) |
fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_unwrap(tt->_x)) |
◆ IALPHA
◆ RTT
◆ UPDATE_PARENT_RUN_TIME
#define UPDATE_PARENT_RUN_TIME |
( |
|
_tt, |
|
|
|
_run_time, |
|
|
|
_event, |
|
|
|
_now |
|
) |
| |
Value:do { \
fr_time_tracking_t *_parent; \
for (_parent = (_tt)->
parent; _parent; _parent = _parent->parent) { \
_parent->_event = _now; \
_parent->last_changed = _now; \
} \
} while (0)
static fr_time_delta_t fr_time_delta_add(fr_time_delta_t a, fr_time_delta_t b)
Update total run time up the list of parents.
Definition at line 113 of file time_tracking.h.
◆ UPDATE_PARENT_START_TIME
#define UPDATE_PARENT_START_TIME |
( |
|
_tt, |
|
|
|
_now |
|
) |
| |
Value:do { \
fr_time_tracking_t *_parent; \
for (_parent = (_tt)->
parent; _parent; _parent = _parent->parent) { \
_parent->started = _now; \
_parent->last_changed = _now; \
} \
} while (0)
Set the last time a tracked entity started in its list of parents.
Definition at line 101 of file time_tracking.h.
◆ UPDATE_PARENT_WAIT_TIME
#define UPDATE_PARENT_WAIT_TIME |
( |
|
_tt, |
|
|
|
_wait_time, |
|
|
|
_event, |
|
|
|
_now |
|
) |
| |
Value:do { \
fr_time_tracking_t *_parent; \
for (_parent = (_tt)->
parent; _parent; _parent = _parent->parent){ \
_parent->_event = _now; \
_parent->last_changed = _now; \
} \
} while (0)
Update total wait time up the list of parents.
Definition at line 126 of file time_tracking.h.
◆ fr_time_tracking_t
A structure to track the time spent processing a request.
The same structure is used by threads to track when they are running / waiting. The functions modifying fr_time_tracking_t all take an explicit "when" parameter. This parameter allows the thread to update a requests tracking structure, and then use that same fr_time_t to update the threads tracking structure.
While fr_time() is fast, it is also called very often. We should therefore be careful to call it only when necessary.
Definition at line 38 of file time_tracking.h.
◆ fr_time_tracking_state_t
Enumerator |
---|
FR_TIME_TRACKING_STOPPED | Time tracking is not running.
|
FR_TIME_TRACKING_RUNNING | We're currently tracking time in the running state.
|
FR_TIME_TRACKING_YIELDED | We're currently tracking time in the yielded state.
|
Definition at line 40 of file time_tracking.h.
◆ fr_time_tracking_debug()
Print debug information about the time tracking structure.
- Parameters
-
[in] | tt | the time tracking structure |
[in] | fp | the file where the debug output is printed. |
Definition at line 299 of file time_tracking.h.
◆ fr_time_tracking_end()
End time tracking for this entity.
- Parameters
-
[in,out] | predicted | Update our prediction of how long requests should run for. |
[in] | tt | the time tracking structure. |
[in] | now | the current time. |
Definition at line 270 of file time_tracking.h.
◆ fr_time_tracking_init()
◆ fr_time_tracking_pop()
Tracked entity left a tracked nested code area.
Updates parent to point to the current time tracking parent.
- Parameters
-
[in] | tt | the time tracked entity. |
[in] | now | the current time. |
Definition at line 202 of file time_tracking.h.
◆ fr_time_tracking_push()
Tracked entity entered a deeper time tracked code area.
- Parameters
-
[in] | parent | we entered. Must be a direct descendent of the current tt->parent. |
[in] | tt | the time tracked entity. |
[in] | now | the current time. |
Definition at line 177 of file time_tracking.h.
◆ fr_time_tracking_resume()
Track that a request resumed.
- Parameters
-
[in] | tt | the time tracked entity. |
[in] | now | the current time. |
Definition at line 245 of file time_tracking.h.
◆ fr_time_tracking_start()
Start time tracking for a tracked entity.
Should be called when the tracked entity starts running.
- Parameters
-
[in] | parent | to update when time tracking ends. |
[in] | tt | the time tracked entity. |
[in] | now | the current time. |
Definition at line 152 of file time_tracking.h.
◆ fr_time_tracking_yield()
Transition to the yielded state, recording the time we just spent running.
- Parameters
-
[in] | tt | the time tracked entity. |
[in] | now | the current time. |
Definition at line 224 of file time_tracking.h.
◆ fr_time_tracking_state_table
◆ fr_time_tracking_state_table_len
size_t fr_time_tracking_state_table_len |
|
extern |