Changeset f6bc9e8


Ignore:
Timestamp:
Apr 2, 2009 6:55:40 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
49c7fc3
Parents:
53cb806
Message:

Profiles:

  • Remove unused calculators and RateStats?: CapacityCalculator?, StrictSpeedCalculator?, IsFailingCalculator?; sendFailureSize, processSuccessRate, processfailureRate, commErrorRate, tunnelTestResponseTimeSlow
  • Reduced number of Rates in these RateStats?: sendSuccessSize, receiveSize, rejectRate, failRate
  • ~5KB/profile savings total
  • Deflate speed calculation once an hour instead of once a day, to improve fast tier selection
Location:
router/java/src/net/i2p/router
Files:
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterContext.java

    r53cb806 rf6bc9e8  
    1717import net.i2p.router.peermanager.ProfileManagerImpl;
    1818import net.i2p.router.peermanager.ProfileOrganizer;
    19 import net.i2p.router.peermanager.ReliabilityCalculator;
    2019import net.i2p.router.peermanager.SpeedCalculator;
    21 import net.i2p.router.peermanager.StrictSpeedCalculator;
    2220import net.i2p.router.transport.CommSystemFacadeImpl;
    2321import net.i2p.router.transport.FIFOBandwidthLimiter;
     
    6664    private Calculator _integrationCalc;
    6765    private Calculator _speedCalc;
    68     private Calculator _reliabilityCalc;
    6966    private Calculator _capacityCalc;
    70     private Calculator _oldSpeedCalc;
    7167
    7268
     
    136132        _integrationCalc = new IntegrationCalculator(this);
    137133        _speedCalc = new SpeedCalculator(this);
    138         _oldSpeedCalc = new StrictSpeedCalculator(this);
    139         _reliabilityCalc = new ReliabilityCalculator(this);
    140134        _capacityCalc = new CapacityCalculator(this);
    141135    }
     
    271265    /** how do we rank the speed of profiles? */
    272266    public Calculator speedCalculator() { return _speedCalc; }
    273     public Calculator oldSpeedCalculator() { return _oldSpeedCalc; }
    274     /** how do we rank the reliability of profiles? */
    275     public Calculator reliabilityCalculator() { return _reliabilityCalc; }
    276267    /** how do we rank the capacity of profiles? */
    277268    public Calculator capacityCalculator() { return _capacityCalc; }
     
    302293        buf.append(_integrationCalc).append('\n');
    303294        buf.append(_speedCalc).append('\n');
    304         buf.append(_reliabilityCalc).append('\n');
    305295        return buf.toString();
    306296    }
  • router/java/src/net/i2p/router/peermanager/PeerProfile.java

    r53cb806 rf6bc9e8  
    3838    // periodic rates
    3939    private RateStat _sendSuccessSize = null;
    40     private RateStat _sendFailureSize = null;
    4140    private RateStat _receiveSize = null;
    4241    private RateStat _dbResponseTime = null;
    4342    private RateStat _tunnelCreateResponseTime = null;
    4443    private RateStat _tunnelTestResponseTime = null;
    45     private RateStat _tunnelTestResponseTimeSlow = null;
    46     private RateStat _commError = null;
    4744    private RateStat _dbIntroduction = null;
    4845    // calculation bonuses
    4946    private long _speedBonus;
    50     private long _reliabilityBonus;
    5147    private long _capacityBonus;
    5248    private long _integrationBonus;
    5349    // calculation values
    5450    private double _speedValue;
    55     private double _reliabilityValue;
    5651    private double _capacityValue;
    5752    private double _integrationValue;
    58     private double _oldSpeedValue;
    5953    private boolean _isFailing;
    6054    // good vs bad behavior
     
    7367        _expanded = false;
    7468        _speedValue = 0;
    75         _reliabilityValue = 0;
    7669        _capacityValue = 0;
    7770        _integrationValue = 0;
     
    112105     * Also mark active if it is connected, as this will tend to encourage use
    113106     * of already-connected peers.
     107     *
     108     * Note: this appears to be the only use for these two RateStats.
     109     *
     110     * @param period must be one of the periods in the RateStat constructors below
     111     *        (5*60*1000 or 60*60*1000)
    114112     */
    115113    public boolean getIsActive(long period) {
     
    155153    /** how large successfully sent messages are, calculated over a 1 minute, 1 hour, and 1 day period */
    156154    public RateStat getSendSuccessSize() { return _sendSuccessSize; }
    157     /** how large messages that could not be sent were, calculated over a 1 minute, 1 hour, and 1 day period */
    158     public RateStat getSendFailureSize() { return _sendFailureSize; }
    159155    /** how large received messages are, calculated over a 1 minute, 1 hour, and 1 day period */
    160156    public RateStat getReceiveSize() { return _receiveSize; }
     
    165161    /** how long it takes to successfully test a tunnel this peer participates in (in milliseconds), calculated over a 10 minute, 1 hour, and 1 day period */
    166162    public RateStat getTunnelTestResponseTime() { return _tunnelTestResponseTime; }
    167     /** how long it takes to successfully test the peer (in milliseconds) when the time exceeds 5s */
    168     public RateStat getTunnelTestResponseTimeSlow() { return _tunnelTestResponseTimeSlow; }
    169     /** how long between communication errors with the peer (disconnection, etc), calculated over a 1 minute, 1 hour, and 1 day period */
    170     public RateStat getCommError() { return _commError; }
    171163    /** how many new peers we get from dbSearchReplyMessages or dbStore messages, calculated over a 1 hour, 1 day, and 1 week period */
    172164    public RateStat getDbIntroduction() { return _dbIntroduction; }
     
    181173   
    182174    /**
    183      * extra factor added to the reliability ranking - this can be updated in the profile
    184      * written to disk to affect how the algorithm ranks reliability.  Negative values are
    185      * penalties
    186      */
    187     public long getReliabilityBonus() { return _reliabilityBonus; }
    188     public void setReliabilityBonus(long bonus) { _reliabilityBonus = bonus; }
    189    
    190     /**
    191175     * extra factor added to the capacity ranking - this can be updated in the profile
    192176     * written to disk to affect how the algorithm ranks capacity.  Negative values are
     
    211195     */
    212196    public double getSpeedValue() { return _speedValue; }
    213     public double getOldSpeedValue() { return _oldSpeedValue; }
    214     /**
    215      * How likely are they to stay up and pass on messages over the next few minutes.
    216      * Positive numbers means more likely, negative numbers means its probably not
    217      * even worth trying.
    218      *
    219      */
    220     public double getReliabilityValue() { return _reliabilityValue; }
    221197    /**
    222198     * How many tunnels do we think this peer can handle over the next hour?
     
    355331    public void shrinkProfile() {
    356332        _sendSuccessSize = null;
    357         _sendFailureSize = null;
    358333        _receiveSize = null;
    359334        _dbResponseTime = null;
    360335        _tunnelCreateResponseTime = null;
    361336        _tunnelTestResponseTime = null;
    362         _tunnelTestResponseTimeSlow = null;
    363         _commError = null;
    364337        _dbIntroduction = null;
    365338        _tunnelHistory = null;
     
    379352        String group = (null == _peer ? "profileUnknown" : _peer.toBase64().substring(0,6));
    380353        if (_sendSuccessSize == null)
    381             _sendSuccessSize = new RateStat("sendSuccessSize", "How large successfully sent messages are", group, new long[] { 60*1000l, 5*60*1000l, 60*60*1000l, 24*60*60*1000l });
    382         if (_sendFailureSize == null)
    383             _sendFailureSize = new RateStat("sendFailureSize", "How large messages that could not be sent were", group, new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000 } );
     354            _sendSuccessSize = new RateStat("sendSuccessSize", "How large successfully sent messages are", group, new long[] { 5*60*1000l, 60*60*1000l });
    384355        if (_receiveSize == null)
    385             _receiveSize = new RateStat("receiveSize", "How large received messages are", group, new long[] { 60*1000l, 5*60*1000l, 60*60*1000l, 24*60*60*1000 } );
     356            _receiveSize = new RateStat("receiveSize", "How large received messages are", group, new long[] { 5*60*1000l, 60*60*1000l } );
    386357        if (_dbResponseTime == null)
    387358            _dbResponseTime = new RateStat("dbResponseTime", "how long it takes to get a db response from the peer (in milliseconds)", group, new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000 } );
     
    390361        if (_tunnelTestResponseTime == null)
    391362            _tunnelTestResponseTime = new RateStat("tunnelTestResponseTime", "how long it takes to successfully test a tunnel this peer participates in (in milliseconds)", group, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000 } );
    392         if (_tunnelTestResponseTimeSlow == null)
    393             _tunnelTestResponseTimeSlow = new RateStat("tunnelTestResponseTimeSlow", "how long it takes to successfully test a peer when the time exceeds 5s", group, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l, });
    394         if (_commError == null)
    395             _commError = new RateStat("commErrorRate", "how long between communication errors with the peer (e.g. disconnection)", group, new long[] { 60*1000l, 10*60*1000l, 60*60*1000l, 24*60*60*1000 } );
    396363        if (_dbIntroduction == null)
    397364            _dbIntroduction = new RateStat("dbIntroduction", "how many new peers we get from dbSearchReplyMessages or dbStore messages", group, new long[] { 60*60*1000l, 6*60*60*1000l, 24*60*60*1000l });
     
    403370
    404371        _sendSuccessSize.setStatLog(_context.statManager().getStatLog());
    405         _sendFailureSize.setStatLog(_context.statManager().getStatLog());
    406372        _receiveSize.setStatLog(_context.statManager().getStatLog());
    407373        _dbResponseTime.setStatLog(_context.statManager().getStatLog());
    408374        _tunnelCreateResponseTime.setStatLog(_context.statManager().getStatLog());
    409375        _tunnelTestResponseTime.setStatLog(_context.statManager().getStatLog());
    410         _tunnelTestResponseTimeSlow.setStatLog(_context.statManager().getStatLog());
    411         _commError.setStatLog(_context.statManager().getStatLog());
    412376        _dbIntroduction.setStatLog(_context.statManager().getStatLog());
    413377        _expanded = true;
    414378    }
    415379    /** once a day, on average, cut the measured throughtput values in half */
    416     private static final long DROP_PERIOD_MINUTES = 24*60;
     380    /** let's try once an hour times 3/4 */
     381    private static final int DROP_PERIOD_MINUTES = 60;
     382    private static final double DEGRADE_FACTOR = 0.75;
    417383    private long _lastCoalesceDate = System.currentTimeMillis();
    418384    private void coalesceThroughput() {
     
    431397                    }
    432398                }
    433                
    434                 if (false && _log.shouldLog(Log.WARN) ) {
    435                     StringBuffer buf = new StringBuffer(128);
    436                     buf.append("Updating throughput after ").append(tot).append(" to ");
     399            } else {
     400                if (_context.random().nextInt(DROP_PERIOD_MINUTES*2) <= 0) {
    437401                    for (int i = 0; i < THROUGHPUT_COUNT; i++)
    438                         buf.append(_peakThroughput[i]).append(',');
    439                     buf.append(" for ").append(_peer.toBase64());
    440                     _log.warn(buf.toString());
    441                 }
    442             } else {
    443                 if (_context.random().nextLong(DROP_PERIOD_MINUTES*2) <= 0) {
    444                     for (int i = 0; i < THROUGHPUT_COUNT; i++)
    445                         _peakThroughput[i] /= 2;
    446 
    447                     if (false && _log.shouldLog(Log.WARN) ) {
    448                         StringBuffer buf = new StringBuffer(128);
    449                         buf.append("Degrading the throughput measurements to ");
    450                         for (int i = 0; i < THROUGHPUT_COUNT; i++)
    451                             buf.append(_peakThroughput[i]).append(',');
    452                         buf.append(" for ").append(_peer.toBase64());
    453                         _log.warn(buf.toString());
    454                     }
     402                        _peakThroughput[i] *= DEGRADE_FACTOR;
    455403                }
    456404            }
     
    458406            // we degrade the tunnel throughput here too, regardless of the current
    459407            // activity
    460             if (_context.random().nextLong(DROP_PERIOD_MINUTES*2) <= 0) {
     408            if (_context.random().nextInt(DROP_PERIOD_MINUTES*2) <= 0) {
    461409                for (int i = 0; i < THROUGHPUT_COUNT; i++) {
    462                     _peakTunnelThroughput[i] /= 2;
    463                     _peakTunnel1mThroughput[i] /= 2;
    464                 }
    465 
    466                 if (_log.shouldLog(Log.WARN) ) {
    467                     StringBuffer buf = new StringBuffer(128);
    468                     buf.append("Degrading the tunnel throughput measurements to ");
    469                     for (int i = 0; i < THROUGHPUT_COUNT; i++)
    470                         buf.append(_peakTunnel1mThroughput[i]).append(',');
    471                     buf.append(" for ").append(_peer.toBase64());
    472                     _log.warn(buf.toString());
     410                    _peakTunnelThroughput[i] *= DEGRADE_FACTOR;
     411                    _peakTunnel1mThroughput[i] *= DEGRADE_FACTOR;
    473412                }
    474413            }
     
    481420    public void coalesceStats() {
    482421        if (!_expanded) return;
    483         _commError.coalesceStats();
    484422        _dbIntroduction.coalesceStats();
    485423        _dbResponseTime.coalesceStats();
    486424        _receiveSize.coalesceStats();
    487         _sendFailureSize.coalesceStats();
    488425        _sendSuccessSize.coalesceStats();
    489426        _tunnelCreateResponseTime.coalesceStats();
    490427        _tunnelTestResponseTime.coalesceStats();
    491         _tunnelTestResponseTimeSlow.coalesceStats();
    492428        _dbHistory.coalesceStats();
    493429        _tunnelHistory.coalesceStats();
     
    496432       
    497433        _speedValue = calculateSpeed();
    498         _oldSpeedValue = calculateOldSpeed();
    499         _reliabilityValue = calculateReliability();
    500434        _capacityValue = calculateCapacity();
    501435        _integrationValue = calculateIntegration();
     
    503437       
    504438        if (_log.shouldLog(Log.DEBUG))
    505             _log.debug("Coalesced: speed [" + _speedValue + "] reliability [" + _reliabilityValue + "] capacity [" + _capacityValue + "] integration [" + _integrationValue + "] failing? [" + _isFailing + "]");
     439            _log.debug("Coalesced: speed [" + _speedValue + "] capacity [" + _capacityValue + "] integration [" + _integrationValue + "] failing? [" + _isFailing + "]");
    506440    }
    507441   
    508442    private double calculateSpeed() { return _context.speedCalculator().calc(this); }
    509     private double calculateOldSpeed() { return _context.oldSpeedCalculator().calc(this); }
    510     private double calculateReliability() { return _context.reliabilityCalculator().calc(this); }
    511443    private double calculateCapacity() { return _context.capacityCalculator().calc(this); }
    512444    private double calculateIntegration() { return _context.integrationCalculator().calc(this); }
     
    585517            buf.append("Peer " + profile.getPeer().toBase64()
    586518                       + ":\t Speed:\t" + fmt.format(profile.calculateSpeed())
    587                        + " Reliability:\t" + fmt.format(profile.calculateReliability())
    588519                       + " Capacity:\t" + fmt.format(profile.calculateCapacity())
    589520                       + " Integration:\t" + fmt.format(profile.calculateIntegration())
  • router/java/src/net/i2p/router/peermanager/ProfileManagerImpl.java

    r53cb806 rf6bc9e8  
    5151        if (data == null) return;
    5252        data.setLastSendFailed(_context.clock().now());
    53         data.getSendFailureSize().addData(0, 0); // yeah, should be a frequency...
    5453    }
    5554   
     
    6261        if (data == null) return;
    6362        data.setLastSendFailed(_context.clock().now());
    64         data.getSendFailureSize().addData(0, 0); // yeah, should be a frequency...
    6563    }
    6664   
     
    7573        if (data == null) return;
    7674        data.setLastSendFailed(_context.clock().now());
    77         data.getSendFailureSize().addData(1, 0); // yeah, should be a frequency...
    78         data.getCommError().addData(1, 0); // see above
    7975    }
    8076   
     
    126122        data.updateTunnelTestTimeAverage(responseTimeMs);
    127123        data.getTunnelTestResponseTime().addData(responseTimeMs, responseTimeMs);
    128         if (responseTimeMs > getSlowThreshold())
    129             data.getTunnelTestResponseTimeSlow().addData(responseTimeMs, responseTimeMs);
    130124    }
    131125   
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r53cb806 rf6bc9e8  
    10291029    /**
    10301030     * called after locking the reorganizeLock, place the profile in the appropriate tier.
    1031      * This is where we implement the (betterThanAverage ? goToPierX : goToPierY) algorithms
     1031     * This is where we implement the (betterThanAverage ? goToTierX : goToTierY) algorithms
    10321032     *
    10331033     */
     
    11541154                                     organizer.isFailing(peer) ? "IX  " : "I   ") + "]: "
    11551155                           + "\t Speed:\t" + fmt.format(profile.getSpeedValue())
    1156                            + " Reliability:\t" + fmt.format(profile.getReliabilityValue())
    11571156                           + " Capacity:\t" + fmt.format(profile.getCapacityValue())
    11581157                           + " Integration:\t" + fmt.format(profile.getIntegrationValue())
     
    11651164                                     organizer.isFailing(peer) ? "X   " : "    ") + "]: "
    11661165                           + "\t Speed:\t" + fmt.format(profile.getSpeedValue())
    1167                            + " Reliability:\t" + fmt.format(profile.getReliabilityValue())
    11681166                           + " Capacity:\t" + fmt.format(profile.getCapacityValue())
    11691167                           + " Integration:\t" + fmt.format(profile.getIntegrationValue())
  • router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java

    r53cb806 rf6bc9e8  
    9696            buf.append("# as calculated by ").append(_us.toBase64()).append(NL);
    9797        buf.append("#").append(NL);
    98         buf.append("# reliability: ").append(profile.getReliabilityValue()).append(NL);
    9998        buf.append("# capacity: ").append(profile.getCapacityValue()).append(NL);
    10099        buf.append("# integration: ").append(profile.getIntegrationValue()).append(NL);
     
    135134        if (profile.getIsExpanded()) {
    136135            // only write out expanded data if, uh, we've got it
    137             profile.getCommError().store(out, "commError");
    138136            profile.getDbIntroduction().store(out, "dbIntroduction");
    139137            profile.getDbResponseTime().store(out, "dbResponseTime");
    140138            profile.getReceiveSize().store(out, "receiveSize");
    141             profile.getSendFailureSize().store(out, "sendFailureSize");
    142139            profile.getSendSuccessSize().store(out, "sendSuccessSize");
    143140            profile.getTunnelCreateResponseTime().store(out, "tunnelCreateResponseTime");
    144141            profile.getTunnelTestResponseTime().store(out, "tunnelTestResponseTime");
    145             profile.getTunnelTestResponseTimeSlow().store(out, "tunnelTestResponseTimeSlow");
    146142        }
    147143    }
     
    218214            profile.getDBHistory().load(props);
    219215           
    220             profile.getCommError().load(props, "commError", true);
    221216            profile.getDbIntroduction().load(props, "dbIntroduction", true);
    222217            profile.getDbResponseTime().load(props, "dbResponseTime", true);
    223218            profile.getReceiveSize().load(props, "receiveSize", true);
    224             profile.getSendFailureSize().load(props, "sendFailureSize", true);
    225219            profile.getSendSuccessSize().load(props, "sendSuccessSize", true);
    226220            profile.getTunnelCreateResponseTime().load(props, "tunnelCreateResponseTime", true);
    227221            profile.getTunnelTestResponseTime().load(props, "tunnelTestResponseTime", true);
    228             profile.getTunnelTestResponseTimeSlow().load(props, "tunnelTestResponseTimeSlow", true);
    229222           
    230223            if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/router/peermanager/TunnelHistory.java

    r53cb806 rf6bc9e8  
    2727    private RateStat _rejectRate;
    2828    private RateStat _failRate;
    29     private RateStat _processSuccessRate;
    30     private RateStat _processFailureRate;
    3129    private String _statGroup;
    3230   
     
    4846   
    4947    private void createRates(String statGroup) {
    50         _rejectRate = new RateStat("tunnelHistory.rejectRate", "How often does this peer reject a tunnel request?", statGroup, new long[] { 60*1000l, 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
    51         _failRate = new RateStat("tunnelHistory.failRate", "How often do tunnels this peer accepts fail?", statGroup, new long[] { 60*1000l, 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
    52         _processSuccessRate = new RateStat("tunnelHistory.processSuccessRate", "How many messages does a tunnel process?", statGroup, new long[] { 5*60*1000l, 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
    53         _processFailureRate = new RateStat("tunnelHistory.processfailureRate", "How many messages does a tunnel fail?", statGroup, new long[] { 5*60*1000l, 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
     48        _rejectRate = new RateStat("tunnelHistory.rejectRate", "How often does this peer reject a tunnel request?", statGroup, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
     49        _failRate = new RateStat("tunnelHistory.failRate", "How often do tunnels this peer accepts fail?", statGroup, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000l });
    5450        _rejectRate.setStatLog(_context.statManager().getStatLog());
    5551        _failRate.setStatLog(_context.statManager().getStatLog());
    56         _processSuccessRate.setStatLog(_context.statManager().getStatLog());
    57         _processFailureRate.setStatLog(_context.statManager().getStatLog());
    5852    }
    5953   
     
    7872   
    7973    public void incrementProcessed(int processedSuccessfully, int failedProcessing) {
    80         if (processedSuccessfully > 0)
    81             _processSuccessRate.addData(processedSuccessfully, 0);
    82         if (failedProcessing > 0)
    83             _processFailureRate.addData(failedProcessing, 0);
     74        // old strict speed calculator
    8475    }
    8576   
     
    130121    public RateStat getRejectionRate() { return _rejectRate; }
    131122    public RateStat getFailedRate() { return _failRate; }
    132     public RateStat getProcessSuccessRate() { return _processSuccessRate; }
    133     public RateStat getProcessFailureRate() { return _processFailureRate; }
    134123   
    135124    public void coalesceStats() {
     
    138127        _rejectRate.coalesceStats();
    139128        _failRate.coalesceStats();
    140         _processFailureRate.coalesceStats();
    141         _processSuccessRate.coalesceStats();
    142129    }
    143130   
     
    162149        _rejectRate.store(out, "tunnelHistory.rejectRate");
    163150        _failRate.store(out, "tunnelHistory.failRate");
    164         _processSuccessRate.store(out, "tunnelHistory.processSuccessRate");
    165         _processFailureRate.store(out, "tunnelHistory.processFailureRate");
    166151    }
    167152   
     
    188173            if (_log.shouldLog(Log.DEBUG))
    189174                _log.debug("Loading tunnelHistory.failRate");
    190             _processFailureRate.load(props, "tunnelHistory.processFailureRate", true);
    191             if (_log.shouldLog(Log.DEBUG))
    192                 _log.debug("Loading tunnelHistory.processFailureRate");
    193             _processSuccessRate.load(props, "tunnelHistory.processSuccessRate", true);
    194             if (_log.shouldLog(Log.DEBUG))
    195                 _log.debug("Loading tunnelHistory.processSuccessRate");
    196175        } catch (IllegalArgumentException iae) {
    197176            _log.warn("TunnelHistory rates are corrupt, resetting", iae);
Note: See TracChangeset for help on using the changeset viewer.