Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove no longer needed garbage collector meddling. #971

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

ArneBab
Copy link
Contributor

@ArneBab ArneBab commented Jul 25, 2024

We now have far more memory than before and file sizes also increased.

I’m not sure whether we could just delete the whole gc code, though, and trust the JVM.

We now have far more memory than before and file sizes also increased.

I’m not sure whether we could just delete the whole gc code, though,
and trust the JVM.
@Bombe
Copy link
Contributor

Bombe commented Jul 25, 2024

I’m not sure whether we could just delete the whole gc code, though, and trust the JVM.

We absolutely should, especially because that code is not guaranteed to actually trigger a GC. The only way to force the JVM to do a garbage collection is by exhausting all memory; when the OutOfMemoryError is thrown, a garbage collection will have happened.

@ArneBab
Copy link
Contributor Author

ArneBab commented Jul 28, 2024

@Bombe I now removed that code and also the aggressiveGC option that was only used there.

Also Hyphanet no longer dies during startup when an ignored option is used during startup (but I’m not happy about the error reporting: do we have a way to report this very loudly?).

@ArneBab ArneBab changed the title Trigger manual GC earlier Remove no longer needed garbage collector meddling. Sep 1, 2024
@@ -14,8 +14,7 @@ public class MemoryChecker implements Runnable {
private volatile boolean goon = false;
private final Ticker ps;
private int aggressiveGCModificator;
private RunningAverage avgFreeMemory;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field aggressiveGCModificator can be removed, it’s always -1 now.

avgFreeMemory.report(freeMemory);
}
}

int sleeptime = aggressiveGCModificator;
if(sleeptime <= 0) { // We are done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aggressiveGCModificator going away means this also doesn’t need an if anymore.

@@ -407,21 +407,7 @@ 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 :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment can also be removed. 🙂

}
},false);
aggressiveGCModificator = statsConfig.getInt("aggressiveGC");
statsConfig.registerIgnoredOption("aggressiveGC");

myMemoryChecker = new MemoryChecker(node.getTicker(), aggressiveGCModificator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aggressiveGCModificator should also be removed from this class, including the comment above its declaration. 🙂

Comment on lines 173 to +176
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace the ternaries with the more descriptive Map.getOrDefault?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this class still serve any purpose (aside from scheduling itself 😄) after removing pretty much all of its code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, that is an excellent observation! 😄 Kill it with 🔥! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants