big ol' memory, cpu usage, and shutdown handling update. main changes include:

* rather than have all jobs created hooked into the clock for offset updates, have the jobQueue stay hooked up and update any active jobs accordingly (killing a memory leak of a JobTiming objects - one per job)
* dont go totally insane during shutdown and log like mad (though the clientApp things still log like mad, since they don't know the router is going down)
* adjust memory buffer sizes based on real world values so we don't have to expand/contract a lot
* dont display things that are completely useless (who cares what the first 32 bytes of a public key are?)
* reduce temporary object creation
* use more efficient collections at times
* on shutdown, log some state information (ready/timed jobs, pending messages, etc)
* explicit GC every 10 jobs.  yeah, not efficient, but just for now we'll keep 'er in there
* only reread the router config file if it changes (duh)
This commit is contained in:
jrandom
2004-05-16 04:54:50 +00:00
committed by zzz
parent 8c6bf5a1cc
commit ff0023a889
32 changed files with 195 additions and 99 deletions

View File

@ -350,7 +350,7 @@ public class Rate {
}
public void store(OutputStream out, String prefix) throws IOException {
StringBuffer buf = new StringBuffer(2048);
StringBuffer buf = new StringBuffer(16*1048);
PersistenceHelper.add(buf, prefix, ".period", "Number of milliseconds in the period", _period);
PersistenceHelper.add(buf, prefix, ".creationDate",
"When was this rate created? (milliseconds since the epoch, GMT)", _creationDate);

View File

@ -76,7 +76,7 @@ public class RateStat {
private final static String NL = System.getProperty("line.separator");
public String toString() {
StringBuffer buf = new StringBuffer(512);
StringBuffer buf = new StringBuffer(4096);
buf.append(getGroupName()).append('.').append(getName()).append(": ").append(getDescription()).append('\n');
long periods[] = getPeriods();
Arrays.sort(periods);
@ -103,7 +103,7 @@ public class RateStat {
}
public void store(OutputStream out, String prefix) throws IOException {
StringBuffer buf = new StringBuffer(128);
StringBuffer buf = new StringBuffer(1024);
buf.append(NL);
buf.append("################################################################################").append(NL);
buf.append("# Rate: ").append(_groupName).append(": ").append(_statName).append(NL);
@ -112,7 +112,7 @@ public class RateStat {
out.write(buf.toString().getBytes());
buf = null;
for (int i = 0; i < _rates.length; i++) {
StringBuffer rbuf = new StringBuffer(256);
StringBuffer rbuf = new StringBuffer(1024);
rbuf.append("#######").append(NL);
rbuf.append("# Period : ").append(DataHelper.formatDuration(_rates[i].getPeriod())).append(" for rate ")
.append(_groupName).append(" - ").append(_statName).append(NL);

View File

@ -80,18 +80,20 @@ public class StatManager {
}
public void coallesceStats() {
for (Iterator iter = getFrequencyNames().iterator(); iter.hasNext();) {
String name = (String) iter.next();
FrequencyStat stat = getFrequency(name);
if (stat != null) {
stat.coallesceStats();
synchronized (_frequencyStats) {
for (Iterator iter = _frequencyStats.values().iterator(); iter.hasNext();) {
FrequencyStat stat = (FrequencyStat)iter.next();
if (stat != null) {
stat.coallesceStats();
}
}
}
for (Iterator iter = getRateNames().iterator(); iter.hasNext();) {
String name = (String) iter.next();
RateStat stat = getRate(name);
if (stat != null) {
stat.coallesceStats();
synchronized (_rateStats) {
for (Iterator iter = _rateStats.values().iterator(); iter.hasNext();) {
RateStat stat = (RateStat)iter.next();
if (stat != null) {
stat.coallesceStats();
}
}
}
}
@ -105,11 +107,11 @@ public class StatManager {
}
public Set getFrequencyNames() {
return Collections.unmodifiableSet(new HashSet(_frequencyStats.keySet()));
return new HashSet(_frequencyStats.keySet());
}
public Set getRateNames() {
return Collections.unmodifiableSet(new HashSet(_rateStats.keySet()));
return new HashSet(_rateStats.keySet());
}
/** is the given stat a monitored rate? */