Changeset dfa1470 for router


Ignore:
Timestamp:
Jul 8, 2018 12:38:53 PM (2 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
7a0f384
Parents:
d992dbf
Message:

reinstate cache capacity calculation

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

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    rd992dbf rdfa1470  
    7474    }
    7575   
    76     private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MAX_CACHE_SIZE);
    7776
    7877    /**
     
    106105        MIN_BUFS = (int) Math.max(MIN_MINB, Math.min(MAX_MINB, 1 + (maxMemory / (16*1024*1024))));
    107106    }
     107   
     108    private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MIN_BUFS);
    108109
    109110    public EventPumper(RouterContext ctx, NTCPTransport transport) {
  • router/java/src/net/i2p/router/transport/udp/UDPPacket.java

    rd992dbf rdfa1470  
    5858    private static final TryCache.ObjectFactory<UDPPacket> _packetFactory;
    5959    private static final boolean CACHE = true;
     60    private static final int MIN_CACHE_SIZE = 64;
    6061    private static final int MAX_CACHE_SIZE = 256;
    6162    static {
    6263        if (CACHE) {
     64            long maxMemory = SystemVersion.getMaxMemory();
     65            int csize = (int) Math.max(MIN_CACHE_SIZE, Math.min(MAX_CACHE_SIZE, maxMemory / (1024*1024)));
    6366            _packetFactory = new PacketFactory();
    64             _packetCache = new TryCache<>(_packetFactory, MAX_CACHE_SIZE);
     67            _packetCache = new TryCache<>(_packetFactory, csize);
    6568        } else {
    6669            _packetCache = null;
Note: See TracChangeset for help on using the changeset viewer.