30#define LOG(kind, ...) GNUNET_log_from (kind, "util-load", __VA_ARGS__)
88 if (
load->autodecline.rel_value_us ==
94 if (0 ==
load->autodecline.rel_value_us)
96 load->runavg_delay = 0.0;
103 load->runavg_delay = 0.0;
110 load->runavg_delay = (
load->runavg_delay * 7.0) / 8.0;
164 if (
load->cummulative_request_count <= 1)
172sum_val_i = (double)
load->cummulative_delay;
173 n = ((
double)
load->cummulative_request_count);
175 avgdel = sum_val_i / n;
177 (((double)
load->cummulative_squared_delay) - 2.0 * avgdel * sum_val_i
178 + n * avgdel * avgdel) / nm1;
183 if (
load->runavg_delay < avgdel)
186 load->load = (
load->runavg_delay - avgdel) / stddev;
221 if (
load->cummulative_request_count == 0)
223 n = ((double)
load->cummulative_request_count);
224 sum_val_i = (double)
load->cummulative_delay;
225 return sum_val_i / n;
242 if (
data > 64 * 1024)
248 dv = (uint32_t)
data;
249 load->cummulative_delay += dv;
250 load->cummulative_squared_delay += dv * dv;
251 load->cummulative_request_count++;
252 load->runavg_delay = ((
load->runavg_delay * 7.0) + dv) / 8.0;
static int ret
Final status code.
static char * data
The data to insert into the dht.
static void load()
Load persistent values from disk.
Functions related to load calculations.
void GNUNET_LOAD_value_set_decline(struct GNUNET_LOAD_Value *load, struct GNUNET_TIME_Relative autodecline)
Change the value by which the load automatically declines.
double GNUNET_LOAD_get_average(struct GNUNET_LOAD_Value *load)
Get the average value given to update so far.
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
static void internal_update(struct GNUNET_LOAD_Value *load)
static void calculate_load(struct GNUNET_LOAD_Value *load)
Recalculate our load value.
static struct GNUNET_TIME_Relative delta
Values we track for load calculations.
struct GNUNET_TIME_Relative autodecline
How fast should the load decline if no values are added?
uint64_t cummulative_request_count
Total number of requests included in the cumulative datastore delay values.
double runavg_delay
Current running average datastore delay.
struct GNUNET_TIME_Absolute last_update
Last time this load value was updated by an event.
uint64_t cummulative_squared_delay
Sum of squares of all datastore delays ever observed (in ms).
uint64_t cummulative_delay
Sum of all datastore delays ever observed (in ms).
double load
How high is the load? 0 for below average, otherwise the number of std.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.