Changeset 4ff62c2 for router


Ignore:
Timestamp:
Jul 15, 2018 11:39:30 AM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6c3cf9bf
Parents:
d499293
Message:

NTCP: Increase failsafe sleep threshold for busy routers (ticket #2251)
Hardcode useDirectBuffers config

Location:
router/java/src/net/i2p/router
Files:
2 edited

Legend:

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

    rd499293 r4ff62c2  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 12;
     21    public final static long BUILD = 13;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    rd499293 r4ff62c2  
    5555    private final ObjectCounter<ByteArray> _blockedIPs;
    5656    private long _expireIdleWriteTime;
    57     private static boolean _useDirect;
     57    private static final boolean _useDirect = false;
    5858   
    5959    /**
     
    8383     */
    8484    private static final long FAILSAFE_ITERATION_FREQ = 2*1000l;
     85    private static final int FAILSAFE_LOOP_COUNT = 512;
    8586    private static final long SELECTOR_LOOP_DELAY = 200;
    8687    private static final long BLOCKED_IP_FREQ = 3*60*1000;
     
    9495     *  Do we use direct buffers for reading? Default false.
    9596     *  NOT recommended as we don't keep good track of them so they will leak.
     97     *
     98     *  Unsupported, set _useDirect above.
     99     *
    96100     *  @see java.nio.ByteBuffer
    97101     */
    98     private static final String PROP_DIRECT = "i2np.ntcp.useDirectBuffers";
     102    //private static final String PROP_DIRECT = "i2np.ntcp.useDirectBuffers";
    99103
    100104    private static final int MIN_MINB = 4;
     
    179183    public void run() {
    180184        int loopCount = 0;
     185        int failsafeLoopCount = FAILSAFE_LOOP_COUNT;
    181186        long lastFailsafeIteration = System.currentTimeMillis();
    182187        long lastBlockedIPClear = lastFailsafeIteration;
     
    215220                    try {
    216221                        Set<SelectionKey> all = _selector.keys();
    217                         _context.statManager().addRateData("ntcp.pumperKeySetSize", all.size());
     222                        int lastKeySetSize = all.size();
     223                        _context.statManager().addRateData("ntcp.pumperKeySetSize", lastKeySetSize);
    218224                        _context.statManager().addRateData("ntcp.pumperLoopsPerSecond", loopCount / (FAILSAFE_ITERATION_FREQ / 1000));
     225                        // reset the failsafe loop counter,
     226                        // and recalculate the max loops before failsafe sleep, based on number of keys
    219227                        loopCount = 0;
     228                        failsafeLoopCount = Math.max(FAILSAFE_LOOP_COUNT, 2 * lastKeySetSize);
    220229                       
    221230                        int failsafeWrites = 0;
     
    309318                    // another 100% CPU workaround
    310319                    // TODO remove or only if we appear to be looping with no interest ops
    311                     if ((loopCount % 512) == 511) {
     320                    if ((loopCount % failsafeLoopCount) == failsafeLoopCount - 1) {
    312321                        if (_log.shouldLog(Log.INFO))
    313322                            _log.info("EventPumper throttle " + loopCount + " loops in " +
     
    323332                    lastBlockedIPClear = now;
    324333                }
    325 
    326 
    327                 _useDirect = _context.getBooleanProperty(PROP_DIRECT);
    328334            } catch (RuntimeException re) {
    329335                _log.error("Error in the event pumper", re);
Note: See TracChangeset for help on using the changeset viewer.