Changeset eb7e1d2


Ignore:
Timestamp:
Feb 15, 2011 3:21:32 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8fa4996
Parents:
c1d7182b
Message:
  • Profiles: Punish rejections more, in an attempt to spread the

load more through the network

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/peermanager/CapacityCalculator.java

    rc1d7182b reb7e1d2  
    1212   
    1313    /** used to adjust each period so that we keep trying to expand the peer's capacity */
    14     static long GROWTH_FACTOR = 5;
     14    static final long GROWTH_FACTOR = 5;
    1515   
    1616    /** the calculator estimates over a 1 hour period */
     
    8484     * Let A = accects, R = rejects, F = fails
    8585     * @return estimated and adjusted accepts per hour, for the given period
    86      *         which is, more or less, max(0, 5 + (A * (A / (A + R))) - (4 * F))
     86     *         which is, more or less, max(0, 5 + (A * (A / (A + 2R))) - (4 * F))
    8787     */
    8888    private static double estimateCapacity(RateStat acceptStat, RateStat rejectStat, RateStat failedStat, int period) {
     
    9191        Rate curFailed = failedStat.getRate(period);
    9292
    93         long eventCount = 0;
    94         if (curAccepted != null)
     93        double eventCount = 0;
     94        if (curAccepted != null) {
    9595            eventCount = curAccepted.getCurrentEventCount() + curAccepted.getLastEventCount();
    96         // Punish for rejections.
    97         // We don't want to simply do eventCount -= rejected or we get to zero with 50% rejection,
    98         // and we don't want everybody to be at zero during times of congestion.
    99         if (eventCount > 0) {
    100             long rejected = curRejected.getCurrentEventCount() + curRejected.getLastEventCount();
    101             eventCount = eventCount * eventCount / (eventCount + rejected);
     96            // Punish for rejections.
     97            // We don't want to simply do eventCount -= rejected or we get to zero with 50% rejection,
     98            // and we don't want everybody to be at zero during times of congestion.
     99            if (eventCount > 0 && curRejected != null) {
     100                long rejected = curRejected.getCurrentEventCount() + curRejected.getLastEventCount();
     101                if (rejected > 0)
     102                    eventCount *= eventCount / (eventCount + (2 * rejected));
     103            }
    102104        }
     105
    103106        double stretch = ((double)ESTIMATE_PERIOD) / period;
    104107        double val = eventCount * stretch;
    105         long failed = 0;
     108
    106109        // Let's say a failure is 4 times worse than a rejection.
    107110        // It's actually much worse than that, but with 2-hop tunnels and a 8-peer
    108111        // fast pool, for example, you have a 1/7 chance of being falsely blamed.
    109112        // We also don't want to drive everybody's capacity to zero, that isn't helpful.
    110         if (curFailed != null)
    111             failed = (long) (0.5 + (4.0 * (curFailed.getCurrentTotalValue() + curFailed.getLastTotalValue()) / 100.0));
    112         if (failed > 0) {
    113             //if ( (period <= 10*60*1000) && (curFailed.getCurrentEventCount() > 0) )
    114             //    return 0.0d; // their tunnels have failed in the last 0-10 minutes
    115             //else
    116             val -= failed * stretch;
     113        if (curFailed != null) {
     114            double failed = curFailed.getCurrentTotalValue() + curFailed.getLastTotalValue();
     115            if (failed > 0) {
     116                //if ( (period <= 10*60*1000) && (curFailed.getCurrentEventCount() > 0) )
     117                //    return 0.0d; // their tunnels have failed in the last 0-10 minutes
     118                //else
     119                // .04 = 4.0 / 100.0 adjustment to failed
     120                val -= 0.04 * failed * stretch;
     121            }
    117122        }
    118123       
Note: See TracChangeset for help on using the changeset viewer.