Author: toad
Date: 2008-03-11 17:33:44 +0000 (Tue, 11 Mar 2008)
New Revision: 18466
Modified:
trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/NodeStats.java
Log:
Improve the overhead calculation logic.
Display total request overhead (rate and percent) on the stats page.
Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2008-03-11 17:19:36 UTC (rev 18465)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2008-03-11 17:33:44 UTC (rev 18466)
@@ -850,6 +850,9 @@
activityList.addChild("li", l10n("nodeToNodeBytes",
"total", SizeUtil.formatSize(totalBytesSentNodeToNode, true)));
activityList.addChild("li", l10n("unaccountedBytes",
new String[] { "total", "percent" },
new String[] {
SizeUtil.formatSize(totalBytesSentRemaining, true),
Integer.toString((int)(totalBytesSentRemaining*100 / total[0])) }));
+ double sentOverheadPerSecond =
node.nodeStats.getSentOverheadPerSecond();
+ activityList.addChild("li", l10n("totalOverhead", new
String[] { "rate", "percent" },
+ new String[] {
SizeUtil.formatSize((long)sentOverheadPerSecond), Integer.toString((int)((100 *
sentOverheadPerSecond) / total_output_rate)) }));
}
}
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-03-11
17:19:36 UTC (rev 18465)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-03-11
17:33:44 UTC (rev 18466)
@@ -1002,6 +1002,7 @@
StatisticsToadlet.threadDumpButton=Generate a Thread Dump
StatisticsToadlet.threads=Running threads: ${running}/${max}
StatisticsToadlet.threadsByPriority=Threads by priority
+StatisticsToadlet.totalOverhead=Total non-request overhead: ${rate}/sec
(${percent}%).
StatisticsToadlet.priority=Priority
StatisticsToadlet.resendBytes=Resent bytes: ${total}
StatisticsToadlet.running=Running
Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java 2008-03-11 17:19:36 UTC
(rev 18465)
+++ trunk/freenet/src/freenet/node/NodeStats.java 2008-03-11 17:33:44 UTC
(rev 18466)
@@ -373,6 +373,11 @@
}
};
+ static final double DEFAULT_OVERHEAD = 0.7;
+ static final long DEFAULT_ONLY_PERIOD = 60*1000;
+ static final long DEFAULT_TRANSITION_PERIOD = 240*1000;
+ static final double MIN_OVERHEAD = 0.01;
+
/* return reject reason as string if should reject, otherwise return
null */
public String shouldRejectRequest(boolean canAcceptAnyway, boolean
isInsert, boolean isSSK, boolean isLocal, boolean isOfferReply, PeerNode
source) {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
@@ -397,12 +402,20 @@
long timeFirstAnyConnections = peers.timeFirstAnyConnections;
long now = System.currentTimeMillis();
if(logMINOR) Logger.minor(this, "Output rate:
"+((double)totalSent*1000.0)/uptime+" overhead rate "+sentOverheadPerSecond+"
non-overhead fraction "+overheadFraction);
- if(overheadFraction == 0.0 || (timeFirstAnyConnections == 0 ||
now - timeFirstAnyConnections < 5*60*1000)) {
- overheadFraction = 0.7;
- if(logMINOR) Logger.minor(this, "Adjusted overhead
fraction: "+overheadFraction);
- if(overheadFraction == 0.0) {
- Logger.error(this, "Overhead fraction is still
100% after 5 minutes uptime??!?");
+ if(timeFirstAnyConnections > 0) {
+ long time = now - timeFirstAnyConnections;
+ if(time < DEFAULT_ONLY_PERIOD) {
+ overheadFraction = DEFAULT_OVERHEAD;
+ if(logMINOR) Logger.minor(this, "Adjusted
overhead fraction: "+overheadFraction);
+ } else if(time < DEFAULT_ONLY_PERIOD +
DEFAULT_TRANSITION_PERIOD) {
+ time -= DEFAULT_ONLY_PERIOD;
+ overheadFraction = (time * overheadFraction +
+ (DEFAULT_TRANSITION_PERIOD - time) *
DEFAULT_OVERHEAD) / DEFAULT_TRANSITION_PERIOD;
+ if(logMINOR) Logger.minor(this, "Adjusted
overhead fraction: "+overheadFraction);
}
+ } else if(overheadFraction < MIN_OVERHEAD) {
+ Logger.error(this, "Overhead fraction is
"+overheadFraction+" - assuming this is self-inflicted and using default");
+ overheadFraction = DEFAULT_OVERHEAD;
}
// If no recent reports, no packets have been sent; correct the
average downwards.