Accurately report VM memsize

Currently the calculation only counts the size of the struct. This commit adds the size of the associated st tables, id tables, and linked lists.

Still missing is the size of the ractors and (potentially) the size of the object space.
This commit is contained in:
Kevin Newton 2022-01-11 12:47:22 -05:00 committed by Aaron Patterson
parent 5e3a320218
commit fc6fd4c31e
Notes: git 2022-01-22 07:35:22 +09:00
4 changed files with 105 additions and 4 deletions

View file

@ -1090,6 +1090,21 @@ waitpid_signal(struct waitpid_state *w)
return FALSE;
}
// Used for VM memsize reporting. Returns the size of a list of waitpid_state
// structs. Defined here because the struct definition lives here as well.
size_t
rb_vm_memsize_waiting_list(struct list_head *waiting_list)
{
struct waitpid_state *waitpid = 0;
size_t size = 0;
list_for_each(waiting_list, waitpid, wnode) {
size += sizeof(struct waitpid_state);
}
return size;
}
/*
* When a thread is done using sigwait_fd and there are other threads
* sleeping on waitpid, we must kick one of the threads out of