On Dec 12, 2007, at 7:58 PM, Ed Tomlinson wrote:
> On December 12, 2007, Robert Hailey wrote:
>>
>> On Dec 11, 2007, at 5:59 PM, Matthew Toseland wrote:
>>> Ok that could be interesting. Although ideally we'd have a
>>> circular-keyspace-aware averager.
>>>> ...
>>> Ok. I suggest you commit, I will review post-commit.
>>
>> Committed it r16508, though it has changed slightly according to my
>> experiments with swap-biasing (e.g. shows number of cache/store
>> writes
>> as well).
>
> Were should this appear? Does it take a while to show up? I have
> r16509 running and am not seeing anything new (yet).
Sorry for the confusion, I thought the last message was on the list.
The commit (r16509) is only for the statistics, not any routing change.
>> From what I have discovered (or theorized) thus far, using the
>> average location of the entire store to bias against is way too much
>> of an anchor. This is good, because it takes up way to much memory to
>> remember such a running average anyway. If we end up implementing
>> such
>> a bias, in the end, it will likely just take into account the last
>> few
>> inserts or successes (a small constant amount). In this way, the
>> pressure of your peers can still pull you into a new location
>> (dragging the weight of the last few inserts with you; which will be
>> updated).
>
> Keeping the average key location and standard deviation just requires
> a few counters along hooks to update them when adding or deleting the
> store... It also requires a single pass to get the initial
> numbers. Should
> not be expensive except for that first pass.
Yes, but again, I suspect that using the entire store would not allow
the node to change locations. Also, varying store sizes would make the
network that much harder to derive solid math for.
> I agree that using the average would be very restrictive. Average
> plus
> or minus standard deviation would give a much better 'limit'. I
> suspect
> that It would take a fair length of time for it to start limiting at
> all (e.g.
> 2 x standard deviation would be greater than 1).
It appears that you are interested in the routing change portion of
the patch, so I've pasted it below (It will probably be wrapped
terribly). I'm not sure I understand your point with regards to
standard deviations, so I'll let you compare that logic to how I use
the average in the not-even-proposed-yet routing change. Note that
(with the recent commit) the below uses the average of all recently
stored keys, and I have already said that probably wont work.
--
Robert Hailey
===================================================================
--- src/freenet/node/LocationManager.java (revision 16462)
+++ src/freenet/node/LocationManager.java (working copy)
@@ -378,9 +378,7 @@
// Randomise our location every 2*SWAP_RESET swap
attempts, whichever way it went.
if(node.random.nextInt(SWAP_RESET) == 0) {
- setLocation(node.random.nextDouble());
- announceLocChange();
- node.writeNodeFile();
+ randomizeLocation();
}
SHA256.returnMessageDigest(md);
@@ -394,6 +392,12 @@
}
+ public void randomizeLocation() {
+ setLocation(node.random.nextDouble());
+ announceLocChange();
+ node.writeNodeFile();
+ }
+
/**
* Locks the LocationManager.
* Sends an FNPSwapRequest out into the network.
@@ -646,7 +650,7 @@
* Anyway:
* Two nodes choose each other and decide to attempt a switch.
They
* calculate the distance of all their edges currently (that is
the
- * distance between their currend ID and that of their
neighbors), and
+ * distance between their current ID and that of their
neighbors), and
* multiply up all these values to get A. Then they calculate the
* distance to all their neighbors as it would be if they switched
* IDs, and multiply up these values to get B.
@@ -692,6 +696,10 @@
if(logMINOR) Logger.minor(this, sb.toString());
+ //If storeBias is true, count the location of the store as one
friend (on our side).
+ boolean
storeBias=(node.nodeStats.avgStoreLocation.countReports()>50);
+ double
storeLocation=node.nodeStats.avgStoreLocation.currentValue();
+
double A = 1.0;
for(int i=0;i<friendLocs.length;i++) {
if(Math.abs(friendLocs[i] - myLoc) <= Double.MIN_VALUE)
continue;
@@ -701,6 +709,8 @@
if(Math.abs(hisFriendLocs[i] - hisLoc) <=
Double.MIN_VALUE) continue;
A *= Location.distance(hisFriendLocs[i], hisLoc);
}
+ if (storeBias)
+ A *= Location.distance(storeLocation, myLoc);
// B = the same, with our two values swapped
double B = 1.0;
@@ -712,6 +722,8 @@
if(Math.abs(hisFriendLocs[i] - myLoc) <=
Double.MIN_VALUE) continue;
B *= Location.distance(hisFriendLocs[i], myLoc);
}
+ if (storeBias)
+ B *= Location.distance(storeLocation, hisLoc);
//Logger.normal(this, "A="+A+" B="+B);
@@ -804,7 +816,7 @@
// Either forward it or handle it
if(htl <= 0) {
if(logMINOR) Logger.minor(this, "Accepting?... "+oldID);
- // Accept - handle locally
+ // MARK: Accept swap - lock, handle locally, spawn
incomingSwapRequestHandler
if(!lock()) {
if(logMINOR) Logger.minor(this, "Can't obtain lock on
"+oldID+" - rejecting to "+pn);
// Reject
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20071213/c4bea68f/attachment.html>