reinstate cache capacity calculation

This commit is contained in:
zab2
2018-07-08 12:38:53 +00:00
parent d992dbf92a
commit dfa1470c17
2 changed files with 6 additions and 2 deletions

View File

@@ -73,7 +73,6 @@ class EventPumper implements Runnable {
}
}
private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MAX_CACHE_SIZE);
/**
* every few seconds, iterate across all ntcp connections just to make sure
@@ -105,6 +104,8 @@ class EventPumper implements Runnable {
long maxMemory = SystemVersion.getMaxMemory();
MIN_BUFS = (int) Math.max(MIN_MINB, Math.min(MAX_MINB, 1 + (maxMemory / (16*1024*1024))));
}
private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MIN_BUFS);
public EventPumper(RouterContext ctx, NTCPTransport transport) {
_context = ctx;

View File

@@ -57,11 +57,14 @@ class UDPPacket implements CDQEntry {
private static final TryCache<UDPPacket> _packetCache;
private static final TryCache.ObjectFactory<UDPPacket> _packetFactory;
private static final boolean CACHE = true;
private static final int MIN_CACHE_SIZE = 64;
private static final int MAX_CACHE_SIZE = 256;
static {
if (CACHE) {
long maxMemory = SystemVersion.getMaxMemory();
int csize = (int) Math.max(MIN_CACHE_SIZE, Math.min(MAX_CACHE_SIZE, maxMemory / (1024*1024)));
_packetFactory = new PacketFactory();
_packetCache = new TryCache<>(_packetFactory, MAX_CACHE_SIZE);
_packetCache = new TryCache<>(_packetFactory, csize);
} else {
_packetCache = null;
_packetFactory = null;