Router, naming, I2CP: Increase lookup cache max sizes (except on Android),

reduce max lookup depth, and increase non-floodfill profile bonus
to attempt to reduce load on floodfills
This commit is contained in:
zzz
2015-12-11 15:40:11 +00:00
parent 7680ecbdc4
commit ea9c4a1957
4 changed files with 13 additions and 7 deletions

View File

@ -170,11 +170,12 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
private volatile boolean _routerSupportsFastReceive; private volatile boolean _routerSupportsFastReceive;
private volatile boolean _routerSupportsHostLookup; private volatile boolean _routerSupportsHostLookup;
protected static final int CACHE_MAX_SIZE = SystemVersion.isAndroid() ? 32 : 128;
/** /**
* Since 0.9.11, key is either a Hash or a String * Since 0.9.11, key is either a Hash or a String
* @since 0.8.9 * @since 0.8.9
*/ */
private static final Map<Object, Destination> _lookupCache = new LHMCache<Object, Destination>(64); private static final Map<Object, Destination> _lookupCache = new LHMCache<Object, Destination>(CACHE_MAX_SIZE);
private static final String MIN_HOST_LOOKUP_VERSION = "0.9.11"; private static final String MIN_HOST_LOOKUP_VERSION = "0.9.11";
private static final boolean TEST_LOOKUP = false; private static final boolean TEST_LOOKUP = false;

View File

@ -15,6 +15,7 @@ import net.i2p.I2PAppContext;
import net.i2p.client.I2PSessionException; import net.i2p.client.I2PSessionException;
import net.i2p.data.Destination; import net.i2p.data.Destination;
import net.i2p.util.LHMCache; import net.i2p.util.LHMCache;
import net.i2p.util.SystemVersion;
/** /**
* A Dummy naming service that can only handle base64 and b32 destinations. * A Dummy naming service that can only handle base64 and b32 destinations.
@ -23,7 +24,7 @@ class DummyNamingService extends NamingService {
protected static final int BASE32_HASH_LENGTH = 52; // 1 + Hash.HASH_LENGTH * 8 / 5 protected static final int BASE32_HASH_LENGTH = 52; // 1 + Hash.HASH_LENGTH * 8 / 5
public final static String PROP_B32 = "i2p.naming.hostsTxt.useB32"; public final static String PROP_B32 = "i2p.naming.hostsTxt.useB32";
protected static final int CACHE_MAX_SIZE = 32; protected static final int CACHE_MAX_SIZE = SystemVersion.isAndroid() ? 32 : 128;
public static final int DEST_SIZE = 516; // Std. Base64 length (no certificate) public static final int DEST_SIZE = 516; // Std. Base64 length (no certificate)
/** /**

View File

@ -74,7 +74,7 @@ class IterativeSearchJob extends FloodSearchJob {
private static final int MAX_NON_FF = 3; private static final int MAX_NON_FF = 3;
/** Max number of peers to query */ /** Max number of peers to query */
private static final int TOTAL_SEARCH_LIMIT = 6; private static final int TOTAL_SEARCH_LIMIT = 5;
/** Max number of peers to query if we are ff */ /** Max number of peers to query if we are ff */
private static final int TOTAL_SEARCH_LIMIT_WHEN_FF = 3; private static final int TOTAL_SEARCH_LIMIT_WHEN_FF = 3;
/** TOTAL_SEARCH_LIMIT * SINGLE_SEARCH_TIME, plus some extra */ /** TOTAL_SEARCH_LIMIT * SINGLE_SEARCH_TIME, plus some extra */
@ -539,16 +539,20 @@ class IterativeSearchJob extends FloodSearchJob {
unheard = new ArrayList<Hash>(_unheardFrom); unheard = new ArrayList<Hash>(_unheardFrom);
} }
// blame the unheard-from (others already blamed in failed() above) // blame the unheard-from (others already blamed in failed() above)
for (Hash h : unheard) for (Hash h : unheard) {
getContext().profileManager().dbLookupFailed(h); getContext().profileManager().dbLookupFailed(h);
}
long time = System.currentTimeMillis() - _created; long time = System.currentTimeMillis() - _created;
if (_log.shouldLog(Log.INFO)) { if (_log.shouldLog(Log.INFO)) {
long timeRemaining = _expiration - getContext().clock().now(); long timeRemaining = _expiration - getContext().clock().now();
_log.info(getJobId() + ": ISJ for " + _key + " failed with " + timeRemaining + " remaining after " + time + _log.info(getJobId() + ": ISJ for " + _key + " failed with " + timeRemaining + " remaining after " + time +
", peers queried: " + tries); ", peers queried: " + tries);
} }
getContext().statManager().addRateData("netDb.failedTime", time); if (tries > 0) {
getContext().statManager().addRateData("netDb.failedRetries", Math.max(0, tries - 1)); // don't bias the stats with immediate fails
getContext().statManager().addRateData("netDb.failedTime", time);
getContext().statManager().addRateData("netDb.failedRetries", tries - 1);
}
for (Job j : _onFailed) { for (Job j : _onFailed) {
getContext().jobQueue().addJob(j); getContext().jobQueue().addJob(j);
} }

View File

@ -29,7 +29,7 @@ class CapacityCalculator {
private static final double PENALTY_UNREACHABLE = 2; private static final double PENALTY_UNREACHABLE = 2;
// we make this a bonus for non-ff, not a penalty for ff, so we // we make this a bonus for non-ff, not a penalty for ff, so we
// don't drive the ffs below the default // don't drive the ffs below the default
private static final double BONUS_NON_FLOODFILL = 0.5; private static final double BONUS_NON_FLOODFILL = 1.0;
public static double calc(PeerProfile profile) { public static double calc(PeerProfile profile) {
double capacity; double capacity;