mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Refactor VM root modules
This `st_table` is used to both mark and pin classes defined from the C API. But `vm->mark_object_ary` already does both much more efficiently. Currently a Ruby process starts with 252 rooted classes, which uses `7224B` in an `st_table` or `2016B` in an `RArray`. So a baseline of 5kB saved, but since `mark_object_ary` is preallocated with `1024` slots but only use `405` of them, it's a net `7kB` save. `vm->mark_object_ary` is also being refactored. Prior to this changes, `mark_object_ary` was a regular `RArray`, but since this allows for references to be moved, it was marked a second time from `rb_vm_mark()` to pin these objects. This has the detrimental effect of marking these references on every minors even though it's a mostly append only list. But using a custom TypedData we can save from having to mark all the references on minor GC runs. Addtionally, immediate values are now ignored and not appended to `vm->mark_object_ary` as it's just wasted space.
This commit is contained in:
parent
16ec54ec41
commit
d4f3dcf4df
27 changed files with 167 additions and 101 deletions
6
time.c
6
time.c
|
@ -1501,7 +1501,7 @@ guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, VALUE *zone_ret)
|
|||
localtime_with_gmtoff_zone(&now, &tm, &now_gmtoff, &zone);
|
||||
now_isdst = tm.tm_isdst;
|
||||
zone = rb_fstring(zone);
|
||||
rb_gc_register_mark_object(zone);
|
||||
rb_vm_register_global_object(zone);
|
||||
now_zone = zone;
|
||||
}
|
||||
if (isdst_ret)
|
||||
|
@ -5773,9 +5773,9 @@ Init_Time(void)
|
|||
sym_zone = ID2SYM(rb_intern_const("zone"));
|
||||
|
||||
str_utc = rb_fstring_lit("UTC");
|
||||
rb_gc_register_mark_object(str_utc);
|
||||
rb_vm_register_global_object(str_utc);
|
||||
str_empty = rb_fstring_lit("");
|
||||
rb_gc_register_mark_object(str_empty);
|
||||
rb_vm_register_global_object(str_empty);
|
||||
|
||||
rb_cTime = rb_define_class("Time", rb_cObject);
|
||||
VALUE scTime = rb_singleton_class(rb_cTime);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue