summaryrefslogtreecommitdiff
path: root/src/zonemaster
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-30 18:51:37 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-30 18:51:37 +0200
commit75bc13ffbb0c3081129706f7c22bf61234f2358e (patch)
treed225b23fb47084fd18909791509cbcc59a79f44f /src/zonemaster
parentffa966400b18d6a51e72d5d8f2343e957dbef3b7 (diff)
downloadgnunet-75bc13ffbb0c3081129706f7c22bf61234f2358e.tar.gz
gnunet-75bc13ffbb0c3081129706f7c22bf61234f2358e.zip
update velocity always at the end of iteration
Diffstat (limited to 'src/zonemaster')
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c86
1 files changed, 48 insertions, 38 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index c4d9bcc17..3be822529 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -378,34 +378,6 @@ dht_put_monitor_continuation (void *cls)
378 378
379 379
380/** 380/**
381 * Check if the current zone iteration needs to be continued
382 * by calling #publish_zone_namestore_next(), and if so with what delay.
383 */
384static void
385check_zone_namestore_next ()
386{
387 struct GNUNET_TIME_Relative delay;
388
389 if (0 != ns_iteration_left)
390 return; /* current NAMESTORE iteration not yet done */
391 delay = GNUNET_TIME_relative_subtract (next_put_interval,
392 sub_delta);
393 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
394 per-record delay calculated so far with the #NS_BLOCK_SIZE */
395 delay = GNUNET_TIME_relative_multiply (delay,
396 NS_BLOCK_SIZE);
397 GNUNET_assert (NULL == zone_publish_task);
398 GNUNET_STATISTICS_set (statistics,
399 "Current artificial NAMESTORE delay (μs)",
400 delay.rel_value_us,
401 GNUNET_NO);
402 zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay,
403 &publish_zone_namestore_next,
404 NULL);
405}
406
407
408/**
409 * Calculate #next_put_interval. 381 * Calculate #next_put_interval.
410 */ 382 */
411static void 383static void
@@ -434,10 +406,10 @@ calculate_put_interval ()
434 next_put_interval 406 next_put_interval
435 = GNUNET_TIME_relative_divide (zone_publish_time_window, 407 = GNUNET_TIME_relative_divide (zone_publish_time_window,
436 last_num_public_records); 408 last_num_public_records);
437 next_put_interval
438 = GNUNET_TIME_relative_min (next_put_interval,
439 MAXIMUM_ZONE_ITERATION_INTERVAL);
440 } 409 }
410 next_put_interval
411 = GNUNET_TIME_relative_min (next_put_interval,
412 MAXIMUM_ZONE_ITERATION_INTERVAL);
441 GNUNET_STATISTICS_set (statistics, 413 GNUNET_STATISTICS_set (statistics,
442 "Minimum relative record expiration (in ms)", 414 "Minimum relative record expiration (in ms)",
443 last_min_relative_record_time.rel_value_us / 1000LL, 415 last_min_relative_record_time.rel_value_us / 1000LL,
@@ -446,6 +418,10 @@ calculate_put_interval ()
446 "Zone publication time window (in ms)", 418 "Zone publication time window (in ms)",
447 zone_publish_time_window.rel_value_us / 1000LL, 419 zone_publish_time_window.rel_value_us / 1000LL,
448 GNUNET_NO); 420 GNUNET_NO);
421 GNUNET_STATISTICS_set (statistics,
422 "Target zone iteration velocity (μs)",
423 next_put_interval.rel_value_us,
424 GNUNET_NO);
449} 425}
450 426
451 427
@@ -453,16 +429,20 @@ calculate_put_interval ()
453 * Re-calculate our velocity and the desired velocity. 429 * Re-calculate our velocity and the desired velocity.
454 * We have succeeded in making #DELTA_INTERVAL puts, so 430 * We have succeeded in making #DELTA_INTERVAL puts, so
455 * now calculate the new desired delay between puts. 431 * now calculate the new desired delay between puts.
432 *
433 * @param cnt how many records were processed since the last call?
456 */ 434 */
457static void 435static void
458update_velocity () 436update_velocity (unsigned int cnt)
459{ 437{
460 struct GNUNET_TIME_Relative delta; 438 struct GNUNET_TIME_Relative delta;
461 unsigned long long pct = 0; 439 unsigned long long pct = 0;
462 440
441 if (0 == cnt)
442 return;
463 /* How fast were we really? */ 443 /* How fast were we really? */
464 delta = GNUNET_TIME_absolute_get_duration (last_put_100); 444 delta = GNUNET_TIME_absolute_get_duration (last_put_100);
465 delta.rel_value_us /= DELTA_INTERVAL; 445 delta.rel_value_us /= cnt;
466 last_put_100 = GNUNET_TIME_absolute_get (); 446 last_put_100 = GNUNET_TIME_absolute_get ();
467 447
468 /* calculate expected frequency */ 448 /* calculate expected frequency */
@@ -481,10 +461,6 @@ update_velocity ()
481 461
482 /* Tell statistics actual vs. desired speed */ 462 /* Tell statistics actual vs. desired speed */
483 GNUNET_STATISTICS_set (statistics, 463 GNUNET_STATISTICS_set (statistics,
484 "Target zone iteration velocity (μs)",
485 next_put_interval.rel_value_us,
486 GNUNET_NO);
487 GNUNET_STATISTICS_set (statistics,
488 "Current zone iteration velocity (μs)", 464 "Current zone iteration velocity (μs)",
489 delta.rel_value_us, 465 delta.rel_value_us,
490 GNUNET_NO); 466 GNUNET_NO);
@@ -550,6 +526,36 @@ update_velocity ()
550 526
551 527
552/** 528/**
529 * Check if the current zone iteration needs to be continued
530 * by calling #publish_zone_namestore_next(), and if so with what delay.
531 */
532static void
533check_zone_namestore_next ()
534{
535 struct GNUNET_TIME_Relative delay;
536
537 if (0 != ns_iteration_left)
538 return; /* current NAMESTORE iteration not yet done */
539 update_velocity (put_cnt);
540 put_cnt = 0;
541 delay = GNUNET_TIME_relative_subtract (next_put_interval,
542 sub_delta);
543 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
544 per-record delay calculated so far with the #NS_BLOCK_SIZE */
545 delay = GNUNET_TIME_relative_multiply (delay,
546 NS_BLOCK_SIZE);
547 GNUNET_assert (NULL == zone_publish_task);
548 GNUNET_STATISTICS_set (statistics,
549 "Current artificial NAMESTORE delay (μs)",
550 delay.rel_value_us,
551 GNUNET_NO);
552 zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay,
553 &publish_zone_namestore_next,
554 NULL);
555}
556
557
558/**
553 * Continuation called from DHT once the PUT operation is done. 559 * Continuation called from DHT once the PUT operation is done.
554 * 560 *
555 * @param cls a `struct DhtPutActivity` 561 * @param cls a `struct DhtPutActivity`
@@ -805,7 +811,7 @@ put_gns_record (void *cls,
805 ma); 811 ma);
806 put_cnt++; 812 put_cnt++;
807 if (0 == put_cnt % DELTA_INTERVAL) 813 if (0 == put_cnt % DELTA_INTERVAL)
808 update_velocity (); 814 update_velocity (DELTA_INTERVAL);
809 check_zone_namestore_next (); 815 check_zone_namestore_next ();
810 if (NULL == ma->ph) 816 if (NULL == ma->ph)
811 { 817 {
@@ -997,6 +1003,10 @@ run (void *cls,
997 = GNUNET_TIME_relative_multiply (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, 1003 = GNUNET_TIME_relative_multiply (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY,
998 PUBLISH_OPS_PER_EXPIRATION); 1004 PUBLISH_OPS_PER_EXPIRATION);
999 next_put_interval = INITIAL_PUT_INTERVAL; 1005 next_put_interval = INITIAL_PUT_INTERVAL;
1006 GNUNET_STATISTICS_set (statistics,
1007 "Target zone iteration velocity (μs)",
1008 next_put_interval.rel_value_us,
1009 GNUNET_NO);
1000 namestore_handle = GNUNET_NAMESTORE_connect (c); 1010 namestore_handle = GNUNET_NAMESTORE_connect (c);
1001 if (NULL == namestore_handle) 1011 if (NULL == namestore_handle)
1002 { 1012 {