diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-07-07 20:57:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-07-07 20:57:30 +0000 |
commit | 6b9fb6394e8d0deb3ae1802b7fc191a3b35cf587 (patch) | |
tree | a71d57365a0e0f4476150b0bac761a9b7ed5884e /src | |
parent | fe9c5d688c274fe3a64ae6c1e3fbaf9c2c11498c (diff) | |
download | gnunet-6b9fb6394e8d0deb3ae1802b7fc191a3b35cf587.tar.gz gnunet-6b9fb6394e8d0deb3ae1802b7fc191a3b35cf587.zip |
keep current priority average and use it
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index ea79d0711..44d787a96 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -24,9 +24,8 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * TODO: | 26 | * TODO: |
27 | * - trust not properly received and pushed back to peerinfo! | 27 | * - bound_priority should not charge if we are not loaded (excess-based economy) |
28 | * - bound_priority by priorities used by other peers | 28 | * - have a way to drop queries based on load (or just forward...) |
29 | * - have a way to drop queries based on load | ||
30 | * - introduce random latency in processing | 29 | * - introduce random latency in processing |
31 | * - consider more precise latency estimation (per-peer & request) | 30 | * - consider more precise latency estimation (per-peer & request) |
32 | * - better algorithm for priority selection for requests we initiate? | 31 | * - better algorithm for priority selection for requests we initiate? |
@@ -95,12 +94,6 @@ static uint64_t max_pending_requests = (32 * 1024); | |||
95 | struct PendingMessage; | 94 | struct PendingMessage; |
96 | 95 | ||
97 | /** | 96 | /** |
98 | * Our connection to the datastore. | ||
99 | */ | ||
100 | static struct GNUNET_DATASTORE_Handle *dsh; | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Function called upon completion of a transmission. | 97 | * Function called upon completion of a transmission. |
105 | * | 98 | * |
106 | * @param cls closure | 99 | * @param cls closure |
@@ -625,6 +618,12 @@ struct MigrationReadyBlock | |||
625 | 618 | ||
626 | 619 | ||
627 | /** | 620 | /** |
621 | * Our connection to the datastore. | ||
622 | */ | ||
623 | static struct GNUNET_DATASTORE_Handle *dsh; | ||
624 | |||
625 | |||
626 | /** | ||
628 | * Our scheduler. | 627 | * Our scheduler. |
629 | */ | 628 | */ |
630 | static struct GNUNET_SCHEDULER_Handle *sched; | 629 | static struct GNUNET_SCHEDULER_Handle *sched; |
@@ -716,6 +715,17 @@ static unsigned int mig_size; | |||
716 | */ | 715 | */ |
717 | static int active_migration; | 716 | static int active_migration; |
718 | 717 | ||
718 | /** | ||
719 | * Typical priorities we're seeing from other peers right now. Since | ||
720 | * most priorities will be zero, this value is the weighted average of | ||
721 | * non-zero priorities seen "recently". In order to ensure that new | ||
722 | * values do not dramatically change the ratio, values are first | ||
723 | * "capped" to a reasonable range (+N of the current value) and then | ||
724 | * averaged into the existing value by a ratio of 1:N. Hence | ||
725 | * receiving the largest possible priority can still only raise our | ||
726 | * "current_priorities" by at most 1. | ||
727 | */ | ||
728 | static double current_priorities; | ||
719 | 729 | ||
720 | /** | 730 | /** |
721 | * Get the filename under which we would store the GNUNET_HELLO_Message | 731 | * Get the filename under which we would store the GNUNET_HELLO_Message |
@@ -1395,11 +1405,6 @@ peer_disconnect_handler (void *cls, | |||
1395 | &consider_migration, | 1405 | &consider_migration, |
1396 | pos); | 1406 | pos); |
1397 | } | 1407 | } |
1398 | if (cp->trust > 0) | ||
1399 | { | ||
1400 | /* FIXME: push trust back to peerinfo! | ||
1401 | (need better peerinfo API!) */ | ||
1402 | } | ||
1403 | GNUNET_PEER_change_rc (cp->pid, -1); | 1408 | GNUNET_PEER_change_rc (cp->pid, -1); |
1404 | GNUNET_PEER_decrement_rcs (cp->last_p2p_replies, P2P_SUCCESS_LIST_SIZE); | 1409 | GNUNET_PEER_decrement_rcs (cp->last_p2p_replies, P2P_SUCCESS_LIST_SIZE); |
1405 | if (NULL != cp->cth) | 1410 | if (NULL != cp->cth) |
@@ -2316,8 +2321,12 @@ forward_request_task (void *cls, | |||
2316 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2321 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
2317 | 4)) | 2322 | 4)) |
2318 | pr->priority++; | 2323 | pr->priority++; |
2319 | /* FIXME: bound priority by "customary" priority used by other peers | 2324 | /* bound priority we use by priorities we see from other peers |
2320 | at this time! */ | 2325 | rounded up (must round up so that we can see non-zero |
2326 | priorities, but round up as little as possible to make it | ||
2327 | plausible that we forwarded another peers request) */ | ||
2328 | if (pr->priority > current_priorities + 1.0) | ||
2329 | pr->priority = (uint32_t) current_priorities + 1.0; | ||
2321 | pr->ttl = bound_ttl (pr->ttl + TTL_DECREMENT * 2, | 2330 | pr->ttl = bound_ttl (pr->ttl + TTL_DECREMENT * 2, |
2322 | pr->priority); | 2331 | pr->priority); |
2323 | #if DEBUG_FS | 2332 | #if DEBUG_FS |
@@ -3099,9 +3108,23 @@ static uint32_t | |||
3099 | bound_priority (uint32_t prio_in, | 3108 | bound_priority (uint32_t prio_in, |
3100 | struct ConnectedPeer *cp) | 3109 | struct ConnectedPeer *cp) |
3101 | { | 3110 | { |
3111 | #define N ((double)128.0) | ||
3112 | uint32_t ret; | ||
3113 | double rret; | ||
3102 | /* FIXME: check if load is low and we | 3114 | /* FIXME: check if load is low and we |
3103 | hence should not charge... */ | 3115 | hence should not charge... */ |
3104 | return change_host_trust (cp, prio_in); | 3116 | ret = change_host_trust (cp, prio_in); |
3117 | if (ret > 0) | ||
3118 | { | ||
3119 | if (ret > current_priorities + N) | ||
3120 | rret = current_priorities + N; | ||
3121 | else | ||
3122 | rret = ret; | ||
3123 | current_priorities | ||
3124 | = (current_priorities * (N-1) + rret)/N; | ||
3125 | } | ||
3126 | #undef N | ||
3127 | return ret; | ||
3105 | } | 3128 | } |
3106 | 3129 | ||
3107 | 3130 | ||