diff options
Diffstat (limited to 'src/namestore/perf_namestore_api_import.c')
-rw-r--r-- | src/namestore/perf_namestore_api_import.c | 110 |
1 files changed, 45 insertions, 65 deletions
diff --git a/src/namestore/perf_namestore_api_import.c b/src/namestore/perf_namestore_api_import.c index 369b29600..698a558b7 100644 --- a/src/namestore/perf_namestore_api_import.c +++ b/src/namestore/perf_namestore_api_import.c | |||
@@ -30,11 +30,7 @@ | |||
30 | 30 | ||
31 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | 31 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
32 | 32 | ||
33 | #define TEST_BATCH_COUNT 3 | 33 | #define TEST_RECORD_COUNT 10000 |
34 | |||
35 | #define TEST_BATCH_SIZE 500 | ||
36 | |||
37 | #define TEST_RECORD_COUNT TEST_BATCH_COUNT * TEST_BATCH_SIZE | ||
38 | 34 | ||
39 | /** | 35 | /** |
40 | * A #BENCHMARK_SIZE of 1000 takes less than a minute on a reasonably | 36 | * A #BENCHMARK_SIZE of 1000 takes less than a minute on a reasonably |
@@ -192,6 +188,10 @@ commit_cont (void *cls, | |||
192 | } | 188 | } |
193 | 189 | ||
194 | static void | 190 | static void |
191 | publish_records_bulk_tx (void *cls); | ||
192 | |||
193 | |||
194 | static void | ||
195 | put_cont_bulk_tx (void *cls, | 195 | put_cont_bulk_tx (void *cls, |
196 | int32_t success, | 196 | int32_t success, |
197 | const char *emsg) | 197 | const char *emsg) |
@@ -203,44 +203,29 @@ put_cont_bulk_tx (void *cls, | |||
203 | GNUNET_SCHEDULER_shutdown (); | 203 | GNUNET_SCHEDULER_shutdown (); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | qe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont, NULL); | 206 | if (bulk_count == TEST_RECORD_COUNT) |
207 | } | ||
208 | |||
209 | |||
210 | static void | ||
211 | publish_records_bulk_tx (void *cls); | ||
212 | |||
213 | static void | ||
214 | reput_cont_bulk_tx (void *cls, | ||
215 | int32_t success, | ||
216 | const char *emsg) | ||
217 | { | ||
218 | (void) cls; | ||
219 | qe = NULL; | ||
220 | if (GNUNET_OK != success) | ||
221 | { | 207 | { |
222 | GNUNET_break (0); | 208 | qe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont, NULL); |
223 | GNUNET_SCHEDULER_shutdown (); | ||
224 | return; | 209 | return; |
225 | } | 210 | } |
226 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL); | 211 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL); |
227 | |||
228 | |||
229 | } | 212 | } |
230 | 213 | ||
214 | |||
231 | static void | 215 | static void |
232 | publish_records_bulk_tx (void *cls) | 216 | publish_records_bulk_tx (void *cls) |
233 | { | 217 | { |
218 | unsigned int sent_rds; | ||
234 | t = NULL; | 219 | t = NULL; |
235 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | 220 | qe = GNUNET_NAMESTORE_records_store2 (nsh, |
236 | &privkey, | 221 | &privkey, |
237 | TEST_BATCH_SIZE, | 222 | TEST_RECORD_COUNT - bulk_count, |
238 | &ri[bulk_count * TEST_BATCH_SIZE], | 223 | &ri[bulk_count], |
239 | (bulk_count == TEST_BATCH_COUNT - 1) ? &put_cont_bulk_tx : | 224 | &sent_rds, |
240 | &reput_cont_bulk_tx, | 225 | &put_cont_bulk_tx, |
241 | NULL); | 226 | NULL); |
242 | bulk_count++; | 227 | bulk_count += sent_rds; |
243 | 228 | GNUNET_assert (sent_rds != 0); | |
244 | } | 229 | } |
245 | 230 | ||
246 | 231 | ||
@@ -249,18 +234,22 @@ begin_cont (void *cls, | |||
249 | int32_t success, | 234 | int32_t success, |
250 | const char *emsg) | 235 | const char *emsg) |
251 | { | 236 | { |
237 | unsigned int sent_rds; | ||
252 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | 238 | qe = GNUNET_NAMESTORE_records_store2 (nsh, |
253 | &privkey, | 239 | &privkey, |
254 | TEST_BATCH_SIZE, | 240 | TEST_RECORD_COUNT - bulk_count, |
255 | &ri[bulk_count * TEST_BATCH_SIZE], | 241 | &ri[bulk_count], |
256 | (bulk_count == TEST_BATCH_COUNT - 1) ? &put_cont_bulk_tx : | 242 | &sent_rds, |
257 | &reput_cont_bulk_tx, | 243 | &put_cont_bulk_tx, |
258 | NULL); | 244 | NULL); |
259 | bulk_count++; | 245 | bulk_count += sent_rds; |
260 | 246 | GNUNET_assert (sent_rds != 0); | |
261 | } | 247 | } |
262 | 248 | ||
263 | static void | 249 | static void |
250 | publish_records_bulk (void *cls); | ||
251 | |||
252 | static void | ||
264 | put_cont_bulk (void *cls, | 253 | put_cont_bulk (void *cls, |
265 | int32_t success, | 254 | int32_t success, |
266 | const char *emsg) | 255 | const char *emsg) |
@@ -276,28 +265,19 @@ put_cont_bulk (void *cls, | |||
276 | return; | 265 | return; |
277 | } | 266 | } |
278 | 267 | ||
279 | delay = GNUNET_TIME_absolute_get_duration (start); | 268 | if (bulk_count == TEST_RECORD_COUNT) |
280 | fprintf (stdout, | 269 | { |
281 | "BULK: Publishing %u records took %s\n", | 270 | delay = GNUNET_TIME_absolute_get_duration (start); |
282 | TEST_RECORD_COUNT, | 271 | fprintf (stdout, |
283 | GNUNET_STRINGS_relative_time_to_string (delay, | 272 | "BULK: Publishing %u records took %s\n", |
284 | GNUNET_YES)); | 273 | TEST_RECORD_COUNT, |
285 | start = GNUNET_TIME_absolute_get (); | 274 | GNUNET_STRINGS_relative_time_to_string (delay, |
286 | bulk_count = 0; | 275 | GNUNET_YES)); |
287 | qe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, NULL); | 276 | start = GNUNET_TIME_absolute_get (); |
288 | 277 | bulk_count = 0; | |
289 | } | 278 | qe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, NULL); |
290 | 279 | return; | |
291 | static void | 280 | } |
292 | publish_records_bulk (void *cls); | ||
293 | |||
294 | static void | ||
295 | reput_cont_bulk (void *cls, | ||
296 | int32_t success, | ||
297 | const char *emsg) | ||
298 | { | ||
299 | struct GNUNET_TIME_Relative delay; | ||
300 | |||
301 | (void) cls; | 281 | (void) cls; |
302 | qe = NULL; | 282 | qe = NULL; |
303 | if (GNUNET_OK != success) | 283 | if (GNUNET_OK != success) |
@@ -307,23 +287,23 @@ reput_cont_bulk (void *cls, | |||
307 | return; | 287 | return; |
308 | } | 288 | } |
309 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); | 289 | t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); |
310 | |||
311 | } | 290 | } |
312 | 291 | ||
313 | |||
314 | static void | 292 | static void |
315 | publish_records_bulk (void *cls) | 293 | publish_records_bulk (void *cls) |
316 | { | 294 | { |
295 | static unsigned int sent_rds = 0; | ||
317 | (void) cls; | 296 | (void) cls; |
318 | t = NULL; | 297 | t = NULL; |
319 | qe = GNUNET_NAMESTORE_records_store2 (nsh, | 298 | qe = GNUNET_NAMESTORE_records_store2 (nsh, |
320 | &privkey, | 299 | &privkey, |
321 | TEST_BATCH_SIZE, | 300 | TEST_RECORD_COUNT - bulk_count, |
322 | &ri[bulk_count * TEST_BATCH_SIZE], | 301 | &ri[bulk_count], |
323 | (bulk_count == TEST_BATCH_COUNT - 1) ? &put_cont_bulk : | 302 | &sent_rds, |
324 | &reput_cont_bulk, | 303 | &put_cont_bulk, |
325 | NULL); | 304 | NULL); |
326 | bulk_count++; | 305 | bulk_count += sent_rds; |
306 | GNUNET_assert (sent_rds != 0); | ||
327 | } | 307 | } |
328 | 308 | ||
329 | 309 | ||