aboutsummaryrefslogtreecommitdiffstats
path: root/vm_trace.c
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-01-11 12:47:22 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2022-01-21 14:34:53 -0800
commitfc6fd4c31e957a4b15ba2c03cbd1cea0a8af6513 (patch)
treeec1681ac98d098f35d2751fd4d33138d3141f8a0 /vm_trace.c
parent5e3a32021849718ae483eaaa9fbf155f91828039 (diff)
downloadruby-fc6fd4c31e957a4b15ba2c03cbd1cea0a8af6513.tar.gz
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.
Diffstat (limited to 'vm_trace.c')
-rw-r--r--vm_trace.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/vm_trace.c b/vm_trace.c
index 466856341d..7f6a60b0cb 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1578,6 +1578,29 @@ struct rb_workqueue_job {
rb_postponed_job_t job;
};
+// Used for VM memsize reporting. Returns the size of a list of rb_workqueue_job
+// structs. Defined here because the struct definition lives here as well.
+size_t
+rb_vm_memsize_workqueue(struct list_head *workqueue)
+{
+ struct rb_workqueue_job *work = 0;
+ size_t size = 0;
+
+ list_for_each(workqueue, work, jnode) {
+ size += sizeof(struct rb_workqueue_job);
+ }
+
+ return size;
+}
+
+// Used for VM memsize reporting. Returns the total size of the postponed job
+// buffer that was allocated at initialization.
+size_t
+rb_vm_memsize_postponed_job_buffer()
+{
+ return sizeof(rb_postponed_job_t) * MAX_POSTPONED_JOB;
+}
+
void
Init_vm_postponed_job(void)
{