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

[release/7.0] [mono][sgen] Update memory load information after world is resumed #76534

Merged
merged 1 commit into from
Oct 4, 2022
Merged
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: 10 additions & 2 deletions src/mono/mono/sgen/sgen-memory-governor.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ update_gc_info (mword used_slots_size)

sgen_gc_info.heap_size_bytes = major_size + sgen_los_memory_usage_total;
sgen_gc_info.fragmented_bytes = sgen_gc_info.heap_size_bytes - sgen_los_memory_usage - major_size_in_use;
guint64 physical_ram_size = mono_determine_physical_ram_size ();
sgen_gc_info.memory_load_bytes = physical_ram_size ? sgen_gc_info.total_available_memory_bytes - (guint64)(((double)sgen_gc_info.total_available_memory_bytes*mono_determine_physical_ram_available_size ())/physical_ram_size) : 0;
sgen_gc_info.total_committed_bytes = major_size_in_use + sgen_los_memory_usage;
sgen_gc_info.total_promoted_bytes = sgen_total_promoted_size - total_promoted_size_start;
sgen_gc_info.total_major_size_bytes = major_size;
Expand All @@ -154,6 +152,14 @@ update_gc_info (mword used_slots_size)
sgen_gc_info.total_los_size_in_use_bytes = sgen_los_memory_usage;
}

static void
update_gc_info_memory_load (void)
{
// We update this separately because it is not safe to do it during GC stw
guint64 physical_ram_size = mono_determine_physical_ram_size ();
sgen_gc_info.memory_load_bytes = physical_ram_size ? sgen_gc_info.total_available_memory_bytes - (guint64)(((double)sgen_gc_info.total_available_memory_bytes*mono_determine_physical_ram_available_size ())/physical_ram_size) : 0;
}

gboolean
sgen_need_major_collection (mword space_needed, gboolean *forced)
{
Expand Down Expand Up @@ -387,6 +393,8 @@ sgen_memgov_collection_end (int generation, gint64 stw_time)
sgen_pointer_queue_clear (&log_entries);
mono_os_mutex_unlock (&log_entries_mutex);
}

update_gc_info_memory_load ();
}

/*
Expand Down