Changeset 10d9eb7


Ignore:
Timestamp:
Sep 1, 2012 4:30:12 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4e78517
Parents:
8bfbe855
Message:

CoDel?:

  • Add logging of drops
  • Set drop stat to delay of dropped item
  • Add no-drop priority
Location:
router/java/src/net/i2p/router/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/util/CoDelBlockingQueue.java

    r8bfbe855 r10d9eb7  
    66
    77import net.i2p.I2PAppContext;
     8import net.i2p.util.Log;
    89
    910/**
     
    2526
    2627    private final I2PAppContext _context;
     28    private final Log _log;
     29    private final String _name;
    2730
    2831    // following 4 are state variables defined by sample code, locked by this
     
    6770        super(capacity);
    6871        _context = ctx;
     72        _log = ctx.logManager().getLog(CoDelBlockingQueue.class);
     73        _name = name;
    6974        STAT_DROP = "codel." + name + ".drop";
    7075        STAT_DELAY = "codel." + name + ".delay";
    71         ctx.statManager().createRequiredRateStat(STAT_DROP, "AQM drop events", "Router", RATES);
     76        ctx.statManager().createRequiredRateStat(STAT_DROP, "queue delay of dropped items", "Router", RATES);
    7277        ctx.statManager().createRequiredRateStat(STAT_DELAY, "average queue delay", "Router", RATES);
    7378    }
     
    255260
    256261    private void drop(E entry) {
    257         _context.statManager().addRateData(STAT_DROP, 1);
     262        long delay = _context.clock().now() - entry.getEnqueueTime();
     263        _context.statManager().addRateData(STAT_DROP, delay);
     264        if (_log.shouldLog(Log.WARN))
     265            _log.warn(_name + " dropped item with delay " + delay + ", " +
     266                      size() + " remaining in queue: " + entry);
    258267        entry.drop();
    259268    }
  • router/java/src/net/i2p/router/util/CoDelPriorityBlockingQueue.java

    r8bfbe855 r10d9eb7  
    88
    99import net.i2p.I2PAppContext;
     10import net.i2p.util.Log;
    1011
    1112/**
     
    2728
    2829    private final I2PAppContext _context;
     30    private final Log _log;
     31    private final String _name;
    2932    private final AtomicLong _seqNum = new AtomicLong();
    3033
     
    6669    private static final long[] RATES = {5*60*1000};
    6770    private static final int[] PRIORITIES = {100, 200, 300, 400, 500};
     71    /** if priority is >= this, never drop */
     72    public static final int DONT_DROP_PRIORITY = 1000;
    6873
    6974    /**
     
    7378        super(initialCapacity, new PriorityComparator());
    7479        _context = ctx;
     80        _log = ctx.logManager().getLog(CoDelPriorityBlockingQueue.class);
     81        _name = name;
    7582        STAT_DROP = "codel." + name + ".drop.";
    7683        STAT_DELAY = "codel." + name + ".delay";
    7784        for (int i = 0; i < PRIORITIES.length; i++) {
    78             ctx.statManager().createRequiredRateStat(STAT_DROP + PRIORITIES[i], "AQM drop events by priority", "Router", RATES);
     85            ctx.statManager().createRequiredRateStat(STAT_DROP + PRIORITIES[i], "queue delay of dropped items by priority", "Router", RATES);
    7986        }
    8087        ctx.statManager().createRequiredRateStat(STAT_DELAY, "average queue delay", "Router", RATES);
     
    238245                }
    239246            } else if (ok_to_drop &&
     247                       rv.getPriority() < DONT_DROP_PRIORITY &&
    240248                       (_now - _drop_next < INTERVAL || _now - _first_above_time >= INTERVAL)) {
    241249                // If we get here, then we're not in dropping state. If the sojourn time has been above
     
    267275
    268276    private void drop(E entry) {
    269         _context.statManager().addRateData(STAT_DROP + entry.getPriority(), 1);
     277        long delay = _context.clock().now() - entry.getEnqueueTime();
     278        _context.statManager().addRateData(STAT_DROP + entry.getPriority(), delay);
     279        if (_log.shouldLog(Log.WARN))
     280            _log.warn(_name + " dropped item with delay " + delay + ", priority " +
     281                      entry.getPriority() + ", seq " +
     282                      entry.getSeqNum() + ", " +
     283                      size() + " remaining in queue: " + entry);
    270284        entry.drop();
    271285    }
Note: See TracChangeset for help on using the changeset viewer.