gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r2325 - GNUnet/src/applications/fs/ecrs


From: grothoff
Subject: [GNUnet-SVN] r2325 - GNUnet/src/applications/fs/ecrs
Date: Thu, 15 Dec 2005 03:43:38 -0800 (PST)

Author: grothoff
Date: 2005-12-15 03:43:36 -0800 (Thu, 15 Dec 2005)
New Revision: 2325

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/search.c
Log:
weak is faster -- very performance critical

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2005-12-15 09:23:51 UTC (rev 
2324)
+++ GNUnet/src/applications/fs/ecrs/download.c  2005-12-15 11:43:36 UTC (rev 
2325)
@@ -986,17 +986,17 @@
   }
   mpriority = lastmpriority;
   priority
-    = entry->lastPriority + randomi(1 + entry->tries);
+    = entry->lastPriority + weak_randomi(1 + entry->tries);
   if (priority > mpriority) {
     /* mpriority is (2 * (current average priority + 2)) and
        is used as the maximum priority that we use; if the
        calculated tpriority is above it, we reduce tpriority
        to random value between the average (mpriority/2) but
        bounded by mpriority */
-    priority = 1 + mpriority / 2 + (randomi(2+mpriority/2));
+    priority = 1 + mpriority / 2 + (weak_randomi(2+mpriority/2));
   }
   if (priority > 0x0FFFFFF)
-    priority = randomi(0xFFFFFF); /* bound! */
+    priority = weak_randomi(0xFFFFFF); /* bound! */
 
   /* compute TTL */
 
@@ -1010,7 +1010,7 @@
   } else {
     ttl = entry->lastTimeout - entry->lasttime;
     if (ttl > MAX_TTL) {
-      ttl = MAX_TTL + randomi(2*TTL_DECREMENT);
+      ttl = MAX_TTL + weak_randomi(2*TTL_DECREMENT);
     } else if (ttl > rm->initialTTL) {
       /* switch to slow back-off */
       unsigned int rd;
@@ -1023,11 +1023,11 @@
       rd = TTL_DECREMENT / rd;
       if (rd == 0)
        rd = 1;
-      ttl += randomi(50 * cronMILLIS + rd);
+      ttl += weak_randomi(50 * cronMILLIS + rd);
       /* rd == TTL_DECREMENT / (con->ttl / rm->initialTTL) + saveguards
         50ms: minimum increment */
     } else {
-      ttl += randomi(ttl + 2 * TTL_DECREMENT); /* exponential backoff with 
random factor */
+      ttl += weak_randomi(ttl + 2 * TTL_DECREMENT); /* exponential backoff 
with random factor */
     }
     if (ttl > (priority+8)* TTL_DECREMENT)
       ttl = (priority+8) * TTL_DECREMENT; /* see adjustTTL in gap */
@@ -1060,14 +1060,14 @@
     entry->lastPriority = priority;
     entry->lastTimeout = timeout;
     entry->lasttime = now + 2 * TTL_DECREMENT;
-    if (randomi(1+entry->tries) > 1) {
+    if (weak_randomi(1+entry->tries) > 1) {
       /* do linear (in tries) extra back-off (in addition to ttl)
         to avoid repeatedly tie-ing with other peers; rm is somewhat
         equivalent to what ethernet is doing, only that 'tries' is our
         (rough) indicator for collisions.  For ethernet back-off, see:
         http://www.industrialethernetuniversity.com/courses/101_4.htm
       */
-      entry->lasttime += randomi(TTL_DECREMENT * (1+entry->tries));
+      entry->lasttime += weak_randomi(TTL_DECREMENT * (1+entry->tries));
     }
     entry->tries++;
   }
@@ -1133,8 +1133,8 @@
       if ( (pOCWCubed <= 0) ||
           (pOCWCubed * rm->requestListIndex <= 0) /* see #642 */ ||
           /* avoid no-start: override congestionWindow occasionally... */
-          (0 == randomi(rm->requestListIndex *
-                        pOCWCubed)) ) {
+          (0 == weak_randomi(rm->requestListIndex *
+                             pOCWCubed)) ) {
        issueRequest(rm, j);
        delta = (rm->requestList[j]->lastTimeout - now) + TTL_DECREMENT;
        pending++;

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2005-12-15 09:23:51 UTC (rev 
2324)
+++ GNUnet/src/applications/fs/ecrs/search.c    2005-12-15 11:43:36 UTC (rev 
2325)
@@ -131,7 +131,7 @@
   ps = MALLOC(sizeof(PendingSearch));
   ps->timeout = 0;
   ps->lastTransmission = 0;
-  ps->priority = 5 + randomi(20);
+  ps->priority = 5 + weak_randomi(20);
   ps->type = type;
   ps->keyCount = keyCount;
   ps->keys = MALLOC(sizeof(HashCode512) * keyCount);
@@ -579,17 +579,17 @@
       /* increase ttl/priority */
       new_ttl = ps->timeout - ps->lastTransmission;
       if (new_ttl < 4 * 5 * cronSECONDS)
-       new_ttl = 4 * 5 * cronSECONDS + randomi(5 * cronSECONDS);
-      new_ttl = new_ttl + randomi(5 * cronSECONDS + 2 * new_ttl);
+       new_ttl = 4 * 5 * cronSECONDS + weak_randomi(5 * cronSECONDS);
+      new_ttl = new_ttl + weak_randomi(5 * cronSECONDS + 2 * new_ttl);
       if (new_ttl > 0xFFFFFF)
-       new_ttl = randomi(0xFFFFFF); /* if we get to large, reduce! */
+       new_ttl = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
       if (remTime < new_ttl)
        new_ttl = remTime;
       ps->timeout = new_ttl + now;
       new_priority = ps->priority;
-      new_priority = new_priority + randomi(4 + 2 * new_priority);
+      new_priority = new_priority + weak_randomi(4 + 2 * new_priority);
       if (new_priority > 0xFFFFFF)
-       new_priority = randomi(0xFFFFFF); /* if we get to large, reduce! */
+       new_priority = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
       ps->priority = new_priority;
       ps->lastTransmission = now;
 #if DEBUG_SEARCH





reply via email to

[Prev in Thread] Current Thread [Next in Thread]