From 43a503514ba04e3291292308c5ffbdd4ef8bc094 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 23 Oct 2020 20:29:30 +0100 Subject: [PATCH] introduce minimum history size for Markov computation --- core/src/main/groovy/com/muwire/core/MuWireSettings.groovy | 4 +++- .../groovy/com/muwire/core/hostcache/H2HostCache.groovy | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index c3a897bc..03c1a1dd 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -54,7 +54,7 @@ class MuWireSettings { Set watchedDirectories float downloadSequentialRatio int hostClearInterval, hostHopelessInterval, hostRejectInterval, hostHopelessPurgeInterval - int hostProfileHistory + int hostProfileHistory, minHostProfileHistory int meshExpiration int speedSmoothSeconds boolean embeddedRouter @@ -96,6 +96,7 @@ class MuWireSettings { hostRejectInterval = Integer.valueOf(props.getProperty("hostRejectInterval", "1")) hostHopelessPurgeInterval = Integer.valueOf(props.getProperty("hostHopelessPurgeInterval","1440")) hostProfileHistory = Integer.valueOf(props.getProperty("hostProfileHistory","100")) + minHostProfileHistory = Integer.valueOf(props.getProperty("minHostProfileHistory","3")) meshExpiration = Integer.valueOf(props.getProperty("meshExpiration","60")) embeddedRouter = Boolean.valueOf(props.getProperty("embeddedRouter","false")) plugin = Boolean.valueOf(props.getProperty("plugin","false")) @@ -176,6 +177,7 @@ class MuWireSettings { props.setProperty("hostRejectInterval", String.valueOf(hostRejectInterval)) props.setProperty("hostHopelessPurgeInterval", String.valueOf(hostHopelessPurgeInterval)) props.setProperty("hostProfileHistory", String.valueOf(hostProfileHistory)) + props.setProperty("minHostProfileHistory", String.valueOf(minHostProfileHistory)) props.setProperty("meshExpiration", String.valueOf(meshExpiration)) props.setProperty("embeddedRouter", String.valueOf(embeddedRouter)) props.setProperty("plugin", String.valueOf(plugin)) diff --git a/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy b/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy index 20f1a251..a86d461b 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy @@ -71,7 +71,11 @@ class H2HostCache extends HostCache { sql.execute("insert into HOST_ATTEMPTS values ('${d.toBase64()}', '$timestamp', '${status.name()}');") def count = sql.firstRow("select count(*) as COUNT from HOST_ATTEMPTS where DESTINATION=${d.toBase64()}") - + if (count.COUNT < settings.minHostProfileHistory) { + log.fine("not enough history for Markov") + return + } + log.fine("recomputing Markov for ${d.toBase32()} from history items $count.COUNT") int ss = 0