aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rps/gnunet-service-rps.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index cf3bd080e..2a2af94f4 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -56,6 +56,8 @@
56 56
57// TODO check that every id we get is valid - is it reachable? 57// TODO check that every id we get is valid - is it reachable?
58 58
59// TODO ignore list
60
59// hist_size_init, hist_size_max 61// hist_size_init, hist_size_max
60 62
61/** 63/**
@@ -175,12 +177,20 @@ static unsigned int gossip_list_size;
175 177
176 178
177/** 179/**
178 * The estimated size of the network. 180 * The size Brahms needs according to the network size.
179 * 181 *
180 * Influenced by the stdev. 182 * This is directly taken as the #gossip_list_size on update of the
183 * #gossip_list
184 * This is the minimum size the sampler grows to.
185 */
186static unsigned int sampler_size;
187//size_t sampler_size;
188
189/**
190 * The size of sampler we need to be able to satisfy the client's need of
191 * random peers.
181 */ 192 */
182static unsigned int est_size; 193static unsigned int sampler_size_client_need;
183//size_t est_size;
184 194
185 195
186/** 196/**
@@ -476,7 +486,7 @@ nse_callback(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimat
476 unsigned int old_est; 486 unsigned int old_est;
477 //double scale; // TODO this might go gloabal/config 487 //double scale; // TODO this might go gloabal/config
478 488
479 old_est = est_size; 489 old_est = sampler_size;
480 490
481 LOG (GNUNET_ERROR_TYPE_DEBUG, 491 LOG (GNUNET_ERROR_TYPE_DEBUG,
482 "Received a ns estimate - logest: %f, std_dev: %f (old_est: %f)\n", 492 "Received a ns estimate - logest: %f, std_dev: %f (old_est: %f)\n",
@@ -489,22 +499,22 @@ nse_callback(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimat
489 // estimate += (std_dev * scale); 499 // estimate += (std_dev * scale);
490 if ( 0 < estimate ) { 500 if ( 0 < estimate ) {
491 LOG (GNUNET_ERROR_TYPE_DEBUG, "Changing estimate to %f\n", estimate); 501 LOG (GNUNET_ERROR_TYPE_DEBUG, "Changing estimate to %f\n", estimate);
492 est_size = estimate; 502 sampler_size = estimate;
493 } else 503 } else
494 LOG (GNUNET_ERROR_TYPE_DEBUG, "Not using estimate %f\n", estimate); 504 LOG (GNUNET_ERROR_TYPE_DEBUG, "Not using estimate %f\n", estimate);
495 505
496 /* If the NSE has changed adapt the lists accordingly */ 506 /* If the NSE has changed adapt the lists accordingly */
497 // TODO respect the request rate, min, max 507 // TODO respect the request rate, min, max
498 if (old_est > est_size*4) 508 if (old_est > sampler_size*4)
499 { /* Shrinking */ 509 { /* Shrinking */
500 RPS_sampler_resize (old_est/2); 510 RPS_sampler_resize (old_est/2);
501 } 511 }
502 else if (old_est < est_size) 512 else if (old_est < sampler_size)
503 { /* Growing */ 513 { /* Growing */
504 if (est_size < old_est*2) 514 if (sampler_size < old_est*2)
505 RPS_sampler_resize (old_est*2); 515 RPS_sampler_resize (old_est*2);
506 else 516 else
507 RPS_sampler_resize (est_size); 517 RPS_sampler_resize (sampler_size);
508 } 518 }
509} 519}
510 520
@@ -807,7 +817,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
807 uint64_t first_border; 817 uint64_t first_border;
808 uint64_t second_border; 818 uint64_t second_border;
809 819
810 GNUNET_array_grow(gossip_list, gossip_list_size, est_size); 820 GNUNET_array_grow(gossip_list, gossip_list_size, sampler_size);
811 821
812 first_border = round(alpha * gossip_list_size); 822 first_border = round(alpha * gossip_list_size);
813 for ( i = 0 ; i < first_border ; i++ ) 823 for ( i = 0 ; i < first_border ; i++ )
@@ -1154,18 +1164,18 @@ run (void *cls,
1154 /* Get initial size of sampler/gossip list from the configuration */ 1164 /* Get initial size of sampler/gossip list from the configuration */
1155 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "RPS", 1165 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "RPS",
1156 "INITSIZE", 1166 "INITSIZE",
1157 (long long unsigned int *) &est_size)) 1167 (long long unsigned int *) &sampler_size))
1158 { 1168 {
1159 LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to read INITSIZE from config\n"); 1169 LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to read INITSIZE from config\n");
1160 GNUNET_SCHEDULER_shutdown (); 1170 GNUNET_SCHEDULER_shutdown ();
1161 return; 1171 return;
1162 } 1172 }
1163 LOG (GNUNET_ERROR_TYPE_DEBUG, "INITSIZE is %" PRIu64 "\n", est_size); 1173 LOG (GNUNET_ERROR_TYPE_DEBUG, "INITSIZE is %" PRIu64 "\n", sampler_size);
1164 1174
1165 //gossip_list_size = est_size; // TODO rename est_size 1175 //gossip_list_size = sampler_size; // TODO rename sampler_size
1166 1176
1167 gossip_list = NULL; 1177 gossip_list = NULL;
1168 GNUNET_array_grow (gossip_list, gossip_list_size, est_size); 1178 GNUNET_array_grow (gossip_list, gossip_list_size, sampler_size);
1169 1179
1170 1180
1171 /* connect to NSE */ 1181 /* connect to NSE */
@@ -1199,7 +1209,7 @@ run (void *cls,
1199 1209
1200 // TODO check that alpha + beta < 1 1210 // TODO check that alpha + beta < 1
1201 1211
1202 peer_map = GNUNET_CONTAINER_multipeermap_create (est_size, GNUNET_NO); 1212 peer_map = GNUNET_CONTAINER_multipeermap_create (sampler_size, GNUNET_NO);
1203 1213
1204 1214
1205 /* Initialise cadet */ 1215 /* Initialise cadet */
@@ -1221,7 +1231,7 @@ run (void *cls,
1221 1231
1222 1232
1223 /* Initialise sampler */ 1233 /* Initialise sampler */
1224 RPS_sampler_init (est_size, own_identity, insertCB, NULL, removeCB, NULL); 1234 RPS_sampler_init (sampler_size, own_identity, insertCB, NULL, removeCB, NULL);
1225 1235
1226 /* Initialise push and pull maps */ 1236 /* Initialise push and pull maps */
1227 push_list = NULL; 1237 push_list = NULL;