aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-02-04 10:46:32 +0000
committerBart Polot <bart@net.in.tum.de>2013-02-04 10:46:32 +0000
commite821862808781a260728b1dfe3b8603b8c56d225 (patch)
tree633bc691a6c15fe91202036b39e46dea397842ac /src
parent923dc5362d568bc5033ad28430559d7571454f33 (diff)
downloadgnunet-e821862808781a260728b1dfe3b8603b8c56d225.tar.gz
gnunet-e821862808781a260728b1dfe3b8603b8c56d225.zip
- spread DHT PUTs over the announce period
Diffstat (limited to 'src')
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c
index b5c9aba20..a542facd7 100644
--- a/src/regex/gnunet-daemon-regexprofiler.c
+++ b/src/regex/gnunet-daemon-regexprofiler.c
@@ -74,6 +74,11 @@ static GNUNET_SCHEDULER_TaskIdentifier reannounce_task;
74static struct GNUNET_TIME_Relative reannounce_freq; 74static struct GNUNET_TIME_Relative reannounce_freq;
75 75
76/** 76/**
77 * Random delay to spread out load on the DHT.
78 */
79static struct GNUNET_TIME_Relative announce_delay;
80
81/**
77 * Local peer's PeerID. 82 * Local peer's PeerID.
78 */ 83 */
79static struct GNUNET_PeerIdentity my_full_id; 84static struct GNUNET_PeerIdentity my_full_id;
@@ -135,18 +140,38 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
135/** 140/**
136 * Announce a previously announced regex re-using cached data. 141 * Announce a previously announced regex re-using cached data.
137 * 142 *
138 * @param cls Clocuse (not used). 143 * @param cls Closure (regex to announce if needed).
139 * @param tc TaskContext. 144 * @param tc TaskContext.
140 */ 145 */
141static void 146static void
142reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 147reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
143{ 148{
149 char *regex = cls;
144 reannounce_task = GNUNET_SCHEDULER_NO_TASK; 150 reannounce_task = GNUNET_SCHEDULER_NO_TASK;
145 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 151 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
146 return; 152 return;
147 reannounce_task = GNUNET_SCHEDULER_add_delayed(reannounce_freq, 153
148 &reannounce_regex, 154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex);
149 cls); 155 GNUNET_STATISTICS_update (stats_handle, "# regexes announced", 1, GNUNET_NO);
156 if (NULL == announce_handle && NULL != regex)
157 {
158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
159 "First time, creating regex: %s\n",
160 regex);
161 announce_handle = GNUNET_REGEX_announce (dht_handle,
162 &my_full_id,
163 regex,
164 (unsigned int) max_path_compression,
165 stats_handle);
166 }
167 else
168 {
169 GNUNET_assert (NULL != announce_handle);
170 GNUNET_REGEX_reannounce (announce_handle);
171 }
172 reannounce_task = GNUNET_SCHEDULER_add_delayed (reannounce_freq,
173 &reannounce_regex,
174 cls);
150} 175}
151 176
152 177
@@ -165,17 +190,10 @@ announce_regex (const char * regex)
165 return; 190 return;
166 } 191 }
167 192
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex);
169 GNUNET_STATISTICS_update (stats_handle, "# regexes announced", 1, GNUNET_NO);
170 announce_handle = GNUNET_REGEX_announce (dht_handle,
171 &my_full_id,
172 regex,
173 (unsigned int) max_path_compression,
174 stats_handle);
175 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == reannounce_task); 193 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == reannounce_task);
176 reannounce_task = GNUNET_SCHEDULER_add_delayed (reannounce_freq, 194 reannounce_task = GNUNET_SCHEDULER_add_delayed (announce_delay,
177 reannounce_regex, 195 reannounce_regex,
178 NULL); 196 (void *) regex);
179} 197}
180 198
181 199
@@ -349,12 +367,15 @@ run (void *cls, char *const *args GNUNET_UNUSED,
349 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER", 367 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER",
350 "REANNOUNCE_FREQ", &reannounce_freq)) 368 "REANNOUNCE_FREQ", &reannounce_freq))
351 { 369 {
352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 370 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
353 "reannounce_freq not given. Using 10 minutes.\n"); 371 "reannounce_freq not given. Using 10 minutes.\n");
354 reannounce_freq = 372 reannounce_freq =
355 GNUNET_TIME_relative_multiply(GNUNET_TIME_relative_get_minute_(), 10); 373 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
356 374
357 } 375 }
376 announce_delay =
377 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
378 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 600));
358 379
359 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); 380 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg);
360 381