changeset 1273:e831cabceab0

Switch to logarithmic scaling.
author Thomas Klausner <tk@giga.or.at>
date Fri, 23 May 2014 16:08:04 +0200
parents 34265c9c1e94
children 681e8e55af27
files extensions/rt_load_balance/rt_load_balance.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/rt_load_balance/rt_load_balance.c	Fri May 23 16:05:38 2014 +0200
+++ b/extensions/rt_load_balance/rt_load_balance.c	Fri May 23 16:08:04 2014 +0200
@@ -2,7 +2,7 @@
 * Software License Agreement (BSD License)                                                               *
 * Author: Thomas Klausner <tk@giga.or.at>                                                                *
 *                                                                                                        *
-* Copyright (c) 2013, Thomas Klausner                                                                    *
+* Copyright (c) 2013, 2014 Thomas Klausner                                                               *
 * All rights reserved.                                                                                   *
 *                                                                                                        *
 * Written under contract by nfotex IT GmbH, http://nfotex.com/                                           *
@@ -58,11 +58,17 @@
 		CHECK_FCT(fd_peer_getbyid(cand->diamid, cand->diamidlen, 0, &peer));
 		CHECK_FCT(fd_peer_get_load_pending(peer, &to_receive, &to_send));
                 load = to_receive + to_send;
-		score = cand->score;
-		if ((cand->score > 0) && (load >= cand->score))
-			cand->score = 1;
-		else
-			cand->score -= load;
+		/* other routing mechanisms need to add to the
+		 * appropriate entries so their base value is high
+		 * enough that they are considered */
+
+		/* logarithmic scaling */
+                int load_log = 0;
+                while (load > 0) {
+                    load_log++;
+                    load /= 2;
+                }
+		cand->score -= load_log;
 		TRACE_DEBUG(FULL, "evaluated peer `%.*s', score was %d, now %d", (int)cand->diamidlen, cand->diamid, score, cand->score);
 	}
 
"Welcome to our mercurial repository"