From: <th...@us...> - 2011-11-07 22:17:17
|
Revision: 2061 http://azsmrc.svn.sourceforge.net/azsmrc/?rev=2061&view=rev Author: the8472 Date: 2011-11-07 22:17:11 +0000 (Mon, 07 Nov 2011) Log Message: ----------- new RTT tweaks. this should make it blazing fast if everything goes right, without killing correctness. Modified Paths: -------------- mldht/trunk/DHTIndexer.jar mldht/trunk/lbms/plugins/mldht/kad/AnnounceNodeCache.java mldht/trunk/lbms/plugins/mldht/kad/DHTConstants.java mldht/trunk/lbms/plugins/mldht/kad/KBucket.java mldht/trunk/lbms/plugins/mldht/kad/utils/ResponseTimeoutFilter.java Modified: mldht/trunk/DHTIndexer.jar =================================================================== (Binary files differ) Modified: mldht/trunk/lbms/plugins/mldht/kad/AnnounceNodeCache.java =================================================================== --- mldht/trunk/lbms/plugins/mldht/kad/AnnounceNodeCache.java 2011-11-05 16:40:57 UTC (rev 2060) +++ mldht/trunk/lbms/plugins/mldht/kad/AnnounceNodeCache.java 2011-11-07 22:17:11 UTC (rev 2061) @@ -141,6 +141,7 @@ if(anchorEntry == null || !targetBucket.prefix.isPrefixOf(anchorEntry.getValue())) { + // if this bucket is full and cannot be split for(Iterator<KBucketEntry> it=targetBucket.entries.iterator();it.hasNext();) { KBucketEntry kbe = it.next(); Modified: mldht/trunk/lbms/plugins/mldht/kad/DHTConstants.java =================================================================== --- mldht/trunk/lbms/plugins/mldht/kad/DHTConstants.java 2011-11-05 16:40:57 UTC (rev 2060) +++ mldht/trunk/lbms/plugins/mldht/kad/DHTConstants.java 2011-11-07 22:17:11 UTC (rev 2061) @@ -41,7 +41,7 @@ public static final int TOKEN_TIMEOUT = 3 * 60 * 1000; public static final int RPC_CALL_TIMEOUT_MAX = 10 * 1000; - public static final int RPC_CALL_TIMEOUT_MIN = 500; // ms + public static final int RPC_CALL_TIMEOUT_BASELINE_MIN = 100; // ms public static final int TASK_TIMEOUT = 2 * 60 * 1000; public static final int MAX_DB_ENTRIES_PER_KEY = 6000; Modified: mldht/trunk/lbms/plugins/mldht/kad/KBucket.java =================================================================== --- mldht/trunk/lbms/plugins/mldht/kad/KBucket.java 2011-11-05 16:40:57 UTC (rev 2060) +++ mldht/trunk/lbms/plugins/mldht/kad/KBucket.java 2011-11-07 22:17:11 UTC (rev 2061) @@ -407,7 +407,7 @@ int next = (current+1) % replacementBucket.length(); KBucketEntry nextEntry = replacementBucket.get(next); - if(nextEntry == null || entry.getLastSeen() - nextEntry.getLastSeen() > 1000) + if(nextEntry == null || entry.getLastSeen() - nextEntry.getLastSeen() > 1000 || entry.getRTT() < nextEntry.getRTT()) { for(int i=0;i<replacementBucket.length();i++) { Modified: mldht/trunk/lbms/plugins/mldht/kad/utils/ResponseTimeoutFilter.java =================================================================== --- mldht/trunk/lbms/plugins/mldht/kad/utils/ResponseTimeoutFilter.java 2011-11-05 16:40:57 UTC (rev 2060) +++ mldht/trunk/lbms/plugins/mldht/kad/utils/ResponseTimeoutFilter.java 2011-11-07 22:17:11 UTC (rev 2061) @@ -26,12 +26,14 @@ public class ResponseTimeoutFilter { public static final int NUM_SAMPLES = 256; - public static final int QUANTILE_INDEX = (int) (NUM_SAMPLES * 0.9f); + public static final int HIGH_QUANTILE_INDEX = (int) (NUM_SAMPLES * 0.9f); + public static final int LOW_QUANTILE_INDEX = (int) (NUM_SAMPLES * 0.1f); final long[] rttRingbuffer = new long[NUM_SAMPLES]; volatile int bufferIndex; - long targetTimeoutMillis; + long timeoutCeiling; + long timeoutBaseline; public ResponseTimeoutFilter() { @@ -39,7 +41,7 @@ } public void reset() { - targetTimeoutMillis = DHTConstants.RPC_CALL_TIMEOUT_MAX; + timeoutBaseline = timeoutCeiling = DHTConstants.RPC_CALL_TIMEOUT_MAX; Arrays.fill(rttRingbuffer, DHTConstants.RPC_CALL_TIMEOUT_MAX); } @@ -65,13 +67,15 @@ { long[] sortableBuffer = rttRingbuffer.clone(); Arrays.sort(sortableBuffer); - targetTimeoutMillis = sortableBuffer[QUANTILE_INDEX]; + timeoutCeiling = sortableBuffer[HIGH_QUANTILE_INDEX]; + timeoutBaseline = sortableBuffer[LOW_QUANTILE_INDEX]; } } public long getStallTimeout() { - long timeout = Math.max(DHTConstants.RPC_CALL_TIMEOUT_MIN, targetTimeoutMillis); - //System.out.println(timeout); + // either the 90th percentile or the 10th percentile + 100ms baseline, whichever is HIGHER (to prevent descent to zero and missing more than 10% of the packets in the worst case). + // but At most RPC_CALL_TIMEOUT_MAX + long timeout = Math.min(Math.max(timeoutBaseline + DHTConstants.RPC_CALL_TIMEOUT_BASELINE_MIN, timeoutCeiling), DHTConstants.RPC_CALL_TIMEOUT_MAX); return timeout; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |