GNUnet 0.22.2
Load library

Load calculations. More...

Collaboration diagram for Load library:

Macros

#define GNUNET_LOAD_value_free(lv)   GNUNET_free (lv)
 Free a load value. More...
 

Functions

struct GNUNET_LOAD_ValueGNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline)
 Create a new load value. More...
 
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. More...
 
double GNUNET_LOAD_get_load (struct GNUNET_LOAD_Value *load)
 Get the current load. More...
 
double GNUNET_LOAD_get_average (struct GNUNET_LOAD_Value *load)
 Get the average value given to update so far. More...
 
void GNUNET_LOAD_update (struct GNUNET_LOAD_Value *load, uint64_t data)
 Update the current load. More...
 

Detailed Description

Load calculations.

Macro Definition Documentation

◆ GNUNET_LOAD_value_free

#define GNUNET_LOAD_value_free (   lv)    GNUNET_free (lv)

Free a load value.

Parameters
lvvalue to free

Definition at line 83 of file gnunet_load_lib.h.

Function Documentation

◆ GNUNET_LOAD_value_init()

struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init ( struct GNUNET_TIME_Relative  autodecline)

Create a new load value.

Parameters
autodeclinespeed at which this value should automatically decline in the absence of external events; at the given frequency, 0-load values will be added to the load
Returns
the new load value

Definition at line 124 of file load.c.

125{
126 struct GNUNET_LOAD_Value *ret;
127
129 ret->autodecline = autodecline;
130 ret->last_update = GNUNET_TIME_absolute_get ();
131 return ret;
132}
static int ret
Final status code.
Definition: gnunet-arm.c:93
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
Values we track for load calculations.
Definition: load.c:36
struct GNUNET_TIME_Relative autodecline
How fast should the load decline if no values are added?
Definition: load.c:40

References GNUNET_LOAD_Value::autodecline, GNUNET_new, GNUNET_TIME_absolute_get(), and ret.

Referenced by GSF_peer_connect_handler(), GSF_pending_request_init_(), main_init(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_LOAD_value_set_decline()

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.

Parameters
loadload to update
autodeclinefrequency of load decline

Definition at line 142 of file load.c.

144{
146 load->autodecline = autodecline;
147}
static void load()
Load persistent values from disk.
static void internal_update(struct GNUNET_LOAD_Value *load)
Definition: load.c:83

References GNUNET_LOAD_Value::autodecline, internal_update(), and load().

Referenced by GSF_update_peer_latency_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_LOAD_get_load()

double GNUNET_LOAD_get_load ( struct GNUNET_LOAD_Value load)

Get the current load.

Parameters
loadload handle
Returns
zero for below-average load, otherwise number of std. devs we are above average; 100 if the latest updates were so large that we could not do proper calculations

Definition at line 200 of file load.c.

201{
204 return load->load;
205}
static void calculate_load(struct GNUNET_LOAD_Value *load)
Recalculate our load value.
Definition: load.c:156

References calculate_load(), internal_update(), and load().

Referenced by GSF_test_get_load_too_high_(), handle_p2p_get(), handle_p2p_put(), and test_put_load_too_high().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_LOAD_get_average()

double GNUNET_LOAD_get_average ( struct GNUNET_LOAD_Value load)

Get the average value given to update so far.

Parameters
loadload handle
Returns
zero if update was never called

Definition at line 215 of file load.c.

216{
217 double n;
218 double sum_val_i;
219
221 if (load->cummulative_request_count == 0)
222 return 0.0;
223 n = ((double) load->cummulative_request_count);
224 sum_val_i = (double) load->cummulative_delay;
225 return sum_val_i / n;
226}

References internal_update(), and load().

Referenced by handle_p2p_get(), and test_put_load_too_high().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_LOAD_update()

void GNUNET_LOAD_update ( struct GNUNET_LOAD_Value load,
uint64_t  data 
)

Update the current load.

Parameters
loadto update
datalatest measurement value (for example, delay)

Definition at line 236 of file load.c.

237{
238 uint32_t dv;
239
241 load->last_update = GNUNET_TIME_absolute_get ();
242 if (data > 64 * 1024)
243 {
244 /* very large */
245 load->load = 100.0;
246 return;
247 }
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;
253}
static char * data
The data to insert into the dht.

References data, GNUNET_TIME_absolute_get(), internal_update(), and load().

Referenced by GSF_update_datastore_delay_(), peer_transmit(), process_reply(), and put_migration_continuation().

Here is the call graph for this function:
Here is the caller graph for this function: