Changeset 780479be


Ignore:
Timestamp:
Apr 8, 2015 1:36:56 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d868ca47
Parents:
4705f01
Message:

Tunnel: Add bloom filter warning if high bw but low memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java

    r4705f01 r780479be  
    11package net.i2p.router.tunnel;
     2
     3import java.io.File;
    24
    35import net.i2p.data.DataHelper;
     
    57import net.i2p.router.util.DecayingBloomFilter;
    68import net.i2p.router.util.DecayingHashSet;
     9import net.i2p.util.Log;
    710import net.i2p.util.SimpleByteCache;
    811import net.i2p.util.SystemVersion;
     
    4043        // See DBF, BloomSHA1, and KeySelector for details.
    4144        long maxMemory = SystemVersion.getMaxMemory();
    42         if (_context.getBooleanProperty(PROP_FORCE))
     45        if (_context.getBooleanProperty(PROP_FORCE)) {
    4346            _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV");  // 2MB fixed
    44         else if (KBps < MIN_SHARE_KBPS_TO_USE_BLOOM || maxMemory < MIN_MEM_TO_USE_BLOOM)
     47        } else if (KBps < MIN_SHARE_KBPS_TO_USE_BLOOM || maxMemory < MIN_MEM_TO_USE_BLOOM) {
     48            if (KBps >= MIN_SHARE_KBPS_TO_USE_BLOOM)
     49                warn(maxMemory, KBps, MIN_MEM_TO_USE_BLOOM, MIN_SHARE_KBPS_TO_USE_BLOOM);
    4550            _filter = new DecayingHashSet(ctx, HALFLIFE_MS, 16, "TunnelIVV"); // appx. 4MB max
    46         else if (KBps >= MIN_SHARE_KBPS_FOR_HUGE_BLOOM && maxMemory >= MIN_MEM_FOR_HUGE_BLOOM)
     51        } else if (KBps >= MIN_SHARE_KBPS_FOR_HUGE_BLOOM && maxMemory >= MIN_MEM_FOR_HUGE_BLOOM) {
    4752            _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV", 25);  // 8MB fixed
    48         else if (KBps >= MIN_SHARE_KBPS_FOR_BIG_BLOOM && maxMemory >= MIN_MEM_FOR_BIG_BLOOM)
     53        } else if (KBps >= MIN_SHARE_KBPS_FOR_BIG_BLOOM && maxMemory >= MIN_MEM_FOR_BIG_BLOOM) {
     54            if (KBps >= MIN_SHARE_KBPS_FOR_HUGE_BLOOM)
     55                warn(maxMemory, KBps, MIN_MEM_FOR_HUGE_BLOOM, MIN_SHARE_KBPS_FOR_HUGE_BLOOM);
    4956            _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV", 24);  // 4MB fixed
    50         else
     57        } else {
     58            if (KBps >= MIN_SHARE_KBPS_FOR_BIG_BLOOM)
     59                warn(maxMemory, KBps, MIN_MEM_FOR_BIG_BLOOM, MIN_SHARE_KBPS_FOR_BIG_BLOOM);
    5160            _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV");  // 2MB fixed
     61        }
    5262        ctx.statManager().createRateStat("tunnel.duplicateIV", "Note that a duplicate IV was received", "Tunnels",
    5363                                         new long[] { 60*60*1000l });
     
    6474
    6575    public void destroy() { _filter.stopDecaying(); }
     76
     77    /** @since 0.9.20 */
     78    private void warn(long maxMemory, int KBps, long recMaxMem, int threshKBps) {
     79        if (SystemVersion.isAndroid())
     80            return;
     81        String msg =
     82            "Configured for " + DataHelper.formatSize(KBps *1024) +
     83            "Bps share bandwidth but only " +
     84            DataHelper.formatSize(maxMemory) + "B available memory." +
     85            " Recommend increasing wrapper.java.maxmemory in " +
     86            _context.getBaseDir() + File.separatorChar + "wrapper.config" +
     87            // getMaxMemory() returns significantly lower than wrapper config, so add 10%
     88            " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" +
     89            " if the actual share bandwidth exceeds " +
     90            DataHelper.formatSize(threshKBps * 1024) + "Bps.";
     91        System.out.println("WARN: " + msg);
     92        _context.logManager().getLog(BloomFilterIVValidator.class).logAlways(Log.WARN, msg);
     93    }
    6694}
Note: See TracChangeset for help on using the changeset viewer.