-
Notifications
You must be signed in to change notification settings - Fork 349
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
Add GC heuristic #3997
base: master
Are you sure you want to change the base?
Add GC heuristic #3997
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,8 +208,23 @@ fn remove_unreachable_allocs<'tcx>(this: &mut MiriInterpCx<'tcx>, allocs: FxHash | |
|
||
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} | ||
pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> { | ||
fn should_run_provenance_gc(&self) -> bool { | ||
let this = self.eval_context_ref(); | ||
match this.machine.gc_settings { | ||
ProvenanceGcSettings::Disabled => false, | ||
ProvenanceGcSettings::Regularly { interval } => this.machine.since_gc >= interval, | ||
ProvenanceGcSettings::Heuristically => | ||
// no GC run if the last one was recently | ||
this.machine.since_gc >= 75 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 75 is an oddly specific number... did you try various values? On which benchmark? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is mostly based on vibes/previous experience with running TB on a bunch of crates. I found that usually, you find some local minimum (of the GC frequency -> performance function) around 100-500, so 75 seemed like a reasonable lower bound. Unfortunately I don't think I can pack these all up into a nice test case. But in general, you want to put the cutoff somewhere. If you feel like a different number should be chosen, suggest a better one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is somewhat surprising, given that the heuristic only kicks in when a tree doubled in size. Did you try different values with the heuristic already in place? Measurements done before you added the heuristic wouldn't really be valid any more. Also note that this code here is not TB-specific. This looks more like "guarding against an overeager heuristic" than anything else? Given it is entirely based on vibes, I'd go for 100 and add a comment for why the number was picked. But I am not sure we want a lower bound here at all; each heuristic is really responsible for ensuring a lower bound itself since it has more data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Indeed, that is also one of the points. It ensures that performance does not tank when a heuristic goes wrong. With the current setup, all the heuristics can do is request the GC happens earlier, so some measures should be taken that it does not happen too early. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A buggy heuristic making the GC fire all the time is bad even if we "cap" it at some number here this way. So this would paper over the issue and make it harder to notice, not fix it. |
||
// run GC if requested, or every 10000 blocks otherwise | ||
&& (this.machine.since_gc >= 10_000 || this.machine.gc_requested.get()), | ||
} | ||
} | ||
|
||
fn run_provenance_gc(&mut self) { | ||
let this = self.eval_context_mut(); | ||
this.machine.since_gc = 0; | ||
this.machine.gc_requested.set(false); | ||
|
||
// We collect all tags and AllocId from every part of the interpreter. | ||
let mut tags = FxHashSet::default(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.