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

Log space usage for a plan #968

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ pub use nogc::NOGC_CONSTRAINTS;
pub use pageprotect::PP_CONSTRAINTS;
pub use semispace::SS_CONSTRAINTS;
pub use sticky::immix::STICKY_IMMIX_CONSTRAINTS;

/// When we log the page usage for a plan, we also log page usage for each space.
pub(crate) const LOG_DETAILED_SPACE_USAGE: bool = false;

/// Collect reserved pages for each space in the plan, and return a string.
pub(crate) fn get_detailed_space_usage_string<VM: crate::vm::VMBinding>(plan: &dyn Plan<VM = VM>) -> String {
let mut print = String::new();
plan.for_each_space(&mut |space: &dyn crate::policy::space::Space<VM>| {
print.push_str(&format!("{}={},", space.name(), space.reserved_pages()));
});
print
}
7 changes: 6 additions & 1 deletion src/scheduler/gc_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,14 @@ pub struct EndOfGC {
impl<VM: VMBinding> GCWork<VM> for EndOfGC {
fn do_work(&mut self, worker: &mut GCWorker<VM>, mmtk: &'static MMTK<VM>) {
info!(
"End of GC ({}/{} pages, took {} ms)",
"End of GC ({}/{} pages{}, took {} ms)",
mmtk.get_plan().get_reserved_pages(),
mmtk.get_plan().get_total_pages(),
if crate::plan::LOG_DETAILED_SPACE_USAGE {
format!(": {}", crate::plan::get_detailed_space_usage_string(mmtk.get_plan()))
} else {
"".to_owned()
},
self.elapsed.as_millis()
);

Expand Down
7 changes: 6 additions & 1 deletion src/util/heap/gc_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<VM: VMBinding> GCTrigger<VM> {
let plan = unsafe { self.plan.assume_init() };
if self.policy.is_gc_required(space_full, space, plan) {
info!(
"[POLL] {}{} ({}/{} pages)",
"[POLL] {}{} ({}/{} pages{})",
if let Some(space) = space {
format!("{}: ", space.get_name())
} else {
Expand All @@ -63,6 +63,11 @@ impl<VM: VMBinding> GCTrigger<VM> {
"Triggering collection",
plan.get_reserved_pages(),
plan.get_total_pages(),
if crate::plan::LOG_DETAILED_SPACE_USAGE {
format!(": {}", crate::plan::get_detailed_space_usage_string(plan))
} else {
"".to_owned()
},
);
plan.base().gc_requester.request();
return true;
Expand Down
Loading