Changeset 19089bd


Ignore:
Timestamp:
Feb 16, 2008 4:25:21 PM (13 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
68829dd
Parents:
69cc0af
Message:
  • Fix race in TunnelDispatcher? which caused participating tunnel count to seesaw - should increase network capacity
  • Leave participating tunnels in 10s batches for efficiency
  • Update participating tunnel ratestat when leaving a tunnel too, to generate a smoother graph
  • Fix tunnel.participatingMessageCount stat to include all participating tunnels, not just outbound endpoints
  • Simplify Expire Tunnel job name
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r69cc0af r19089bd  
    1 2008-02-17 zzz
     12008-02-16 zzz
     2    * Fix race in TunnelDispatcher which caused
     3      participating tunnel count to seesaw -
     4      should increase network capacity
     5    * Leave participating tunnels in 10s batches for efficiency
     6    * Update participating tunnel ratestat when leaving a tunnel too,
     7      to generate a smoother graph
     8    * Fix tunnel.participatingMessageCount stat to include all
     9      participating tunnels, not just outbound endpoints
     10    * Simplify Expire Tunnel job name
     11
     122008-02-13 zzz
    213    * PersistentDataStore: Write out 300 records every 10 min
    314      rather than 1 every 10 sec;
  • router/java/src/net/i2p/router/RouterVersion.java

    r69cc0af r19089bd  
    1818    public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $";
    1919    public final static String VERSION = "0.6.1.31";
    20     public final static long BUILD = 3;
     20    public final static long BUILD = 4;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    r69cc0af r19089bd  
    339339       
    340340        boolean removed = false;
     341        int numParticipants = 0;
    341342        synchronized (_participatingConfig) {
    342343            removed = (null != _participatingConfig.remove(recvId));
     344            numParticipants = _participatingConfig.size();
    343345        }
    344346        if (!removed) {
     
    347349        }
    348350       
     351        _context.statManager().addRateData("tunnel.participatingTunnels", numParticipants, 0);
     352        _context.statManager().addRateData("tunnel.participatingMessageCount", cfg.getProcessedMessagesCount(), 10*60*1000);
     353
    349354        synchronized (_participants) {
    350355            removed = (null != _participants.remove(recvId));
     
    358363            removed = (null != _outboundEndpoints.remove(recvId));
    359364        }
    360        
    361         _context.statManager().addRateData("tunnel.participatingMessageCount", cfg.getProcessedMessagesCount(), 10*60*1000);
    362365    }
    363366   
     
    636639        }
    637640       
     641        private static final int LEAVE_BATCH_TIME = 10*1000;
    638642        public void add(HopConfig cfg) {
    639             Long dropTime = new Long(cfg.getExpiration() + 2*Router.CLOCK_FUDGE_FACTOR);
     643            Long dropTime = new Long(cfg.getExpiration() + 2*Router.CLOCK_FUDGE_FACTOR + LEAVE_BATCH_TIME);
     644            boolean noTunnels;
    640645            synchronized (LeaveTunnel.this) {
     646                noTunnels = _configs.size() <= 0;
    641647                _configs.add(cfg);
    642648                _times.add(dropTime);
    643             }
    644649           
     650                // Make really sure we queue or requeue the job only when we have to, or else bad things happen.
     651                // Locking around this part may not be sufficient but there was nothing before.
     652                // Symptom is the Leave Participant job not running for 12m, leading to seesaw participating tunnel count
     653
     654                long oldAfter = getTiming().getStartAfter();
     655                long oldStart = getTiming().getActualStart();
     656                if ( noTunnels || (oldAfter <= 0) ||
     657                     (oldAfter < getContext().clock().now() && oldAfter <= oldStart) || // if oldAfter > oldStart, it's late but it will run, so don't do this (race)
     658                     (oldAfter >= dropTime.longValue()) ) {
     659                    getTiming().setStartAfter(dropTime.longValue());
     660                    getContext().jobQueue().addJob(LeaveTunnel.this);
     661                } else {
     662                    // already scheduled for the future, and before this expiration
     663                }
     664            }
    645665            if (_log.shouldLog(Log.INFO)) {
    646666                long now = getContext().clock().now();
    647667                _log.info("Scheduling leave in " + DataHelper.formatDuration(dropTime.longValue()-now) +": " + cfg);
    648             }
    649            
    650             long oldAfter = getTiming().getStartAfter();
    651             if ( (oldAfter <= 0) || (oldAfter < getContext().clock().now()) || (oldAfter >= dropTime.longValue()) ) {
    652                 getTiming().setStartAfter(dropTime.longValue());
    653                 getContext().jobQueue().addJob(LeaveTunnel.this);
    654             } else {
    655                 // already scheduled for the future, and before this expiration
    656668            }
    657669        }
     
    661673            HopConfig cur = null;
    662674            Long nextTime = null;
    663             long now = getContext().clock().now();
     675            long now = getContext().clock().now() + LEAVE_BATCH_TIME; // leave all expiring in next 10 sec
    664676            while (true) {
    665677                synchronized (LeaveTunnel.this) {
     
    686698           
    687699            if (nextTime != null) {
    688                 getTiming().setStartAfter(nextTime.longValue());
    689                 getContext().jobQueue().addJob(LeaveTunnel.this);
     700                synchronized (LeaveTunnel.this) {
     701                    getTiming().setStartAfter(nextTime.longValue());
     702                    getContext().jobQueue().addJob(LeaveTunnel.this);
     703                }
    690704            }
    691705        }
  • router/java/src/net/i2p/router/tunnel/pool/ExpireJob.java

    r69cc0af r19089bd  
    3030    }
    3131    public String getName() {
    32         if (_pool.getSettings().isExploratory()) {
    33             if (_pool.getSettings().isInbound()) {
    34                 return "Expire exploratory inbound tunnel";
    35             } else {
    36                 return "Expire exploratory outbound tunnel";
    37             }
    38         } else {
    39             StringBuffer rv = new StringBuffer(32);
    40             if (_pool.getSettings().isInbound())
    41                 rv.append("Expire inbound client tunnel for ");
    42             else
    43                 rv.append("Expire outbound client tunnel for ");
    44             if (_pool.getSettings().getDestinationNickname() != null)
    45                 rv.append(_pool.getSettings().getDestinationNickname());
    46             else
    47                 rv.append(_pool.getSettings().getDestination().toBase64().substring(0,4));
    48             return rv.toString();
    49         }
     32        return "Expire tunnel";
    5033    }
    5134    public void runJob() {
Note: See TracChangeset for help on using the changeset viewer.