Skip to content

Commit

Permalink
Merge branch 'trigger-manual-gc-earlier' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Dec 1, 2024
2 parents 25916aa + fdc6f6f commit 85027a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 155 deletions.
18 changes: 12 additions & 6 deletions src/freenet/config/SubConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,47 +172,53 @@ public int getInt(String optionName) {
synchronized(this) {
o = (IntOption) map.get(optionName);
}
return o.getValue();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? -1 : o.getValue();
}

public long getLong(String optionName) {
LongOption o;
synchronized(this) {
o = (LongOption) map.get(optionName);
}
return o.getValue();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? -1L : o.getValue();
}

public boolean getBoolean(String optionName) {
BooleanOption o;
synchronized(this) {
o = (BooleanOption) map.get(optionName);
}
return o.getValue();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? false : o.getValue();
}

public String getString(String optionName) {
StringOption o;
synchronized(this) {
o = (StringOption) map.get(optionName);
}
return o.getValue().trim();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? "" : o.getValue().trim();
}

public String[] getStringArr(String optionName) {
StringArrOption o;
synchronized(this) {
o = (StringArrOption) map.get(optionName);
}
return o.getValue();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? new String[]{} : o.getValue();
}

public short getShort(String optionName) {
ShortOption o;
synchronized(this) {
o = (ShortOption) map.get(optionName);
}
return o.getValue();
// return fallback value for ignored options (null). This avoids breaking plugins which try to get ignored options.
return o == null ? -1 : o.getValue();
}

public Option<?> removeOption(String optionName) {
Expand Down
108 changes: 0 additions & 108 deletions src/freenet/node/MemoryChecker.java

This file was deleted.

43 changes: 2 additions & 41 deletions src/freenet/node/NodeStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ final int[] getCounts(final int[] total) {
private volatile long maxPingTime;

final Node node;
private MemoryChecker myMemoryChecker;
public final PeerManager peers;

final RandomSource hardRandom;
Expand Down Expand Up @@ -284,10 +283,6 @@ public void shouldUpdate(){
final StringCounter preemptiveRejectReasons;
final StringCounter localPreemptiveRejectReasons;

// Enable this if you run into hard to debug OOMs.
// Disabled to prevent long pauses every 30 seconds.
private int aggressiveGCModificator = -1 /*250*/;

// Peers stats
/** Next time to update PeerManagerUserAlert stats */
private long nextPeerManagerUserAlertStatsUpdateTime = -1;
Expand Down Expand Up @@ -407,43 +402,9 @@ public void set(Integer val) throws InvalidConfigValueException {
threadLimit = statsConfig.getInt("threadLimit");

// Yes it could be in seconds insteed of multiples of 0.12, but we don't want people to play with it :)
statsConfig.register("aggressiveGC", aggressiveGCModificator, sortOrder++, true, false, "NodeStat.aggressiveGC", "NodeStat.aggressiveGCLong",
new IntCallback() {
@Override
public Integer get() {
return aggressiveGCModificator;
}
@Override
public void set(Integer val) throws InvalidConfigValueException {
if (get().equals(val))
return;
Logger.normal(this, "Changing aggressiveGCModificator to "+val);
aggressiveGCModificator = val;
}
},false);
aggressiveGCModificator = statsConfig.getInt("aggressiveGC");

myMemoryChecker = new MemoryChecker(node.getTicker(), aggressiveGCModificator);
statsConfig.register("memoryChecker", true, sortOrder++, true, false, "NodeStat.memCheck", "NodeStat.memCheckLong",
new BooleanCallback(){
@Override
public Boolean get() {
return myMemoryChecker.isRunning();
}

@Override
public void set(Boolean val) throws InvalidConfigValueException {
if (get().equals(val))
return;
statsConfig.registerIgnoredOption("aggressiveGC");

if(val)
myMemoryChecker.start();
else
myMemoryChecker.terminate();
}
});
if(statsConfig.getBoolean("memoryChecker"))
myMemoryChecker.start();
statsConfig.registerIgnoredOption("memoryChecker");

statsConfig.register("ignoreLocalVsRemoteBandwidthLiability", false, sortOrder++, true, false, "NodeStat.ignoreLocalVsRemoteBandwidthLiability", "NodeStat.ignoreLocalVsRemoteBandwidthLiabilityLong", new BooleanCallback() {

Expand Down

0 comments on commit 85027a9

Please sign in to comment.