Skip to content

Commit 399e2ab

Browse files
committed
Allow concurrent_set to be collected in minor GC
When testing we've found that the concurrent_set objects used for fstrings can grow quite large, and because they reach oldgen quickly end up not being collected. This commit is a bit of a hack but aims to improve that by moving the objects to not be WB_PROTECTED. "Unprotected" objects do not age and can't become oldgen, so this allows them to be collected in a minor GC.
1 parent 9593627 commit 399e2ab

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

concurrent_set.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,26 @@ concurrent_set_size(const void *ptr)
4040
(set->capacity * sizeof(struct concurrent_set_entry));
4141
}
4242

43+
/* Hack: Though it would be trivial, we're intentionally avoiding WB-protecting
44+
* this object. This prevents the object from aging and ensures it can always be
45+
* collected in a minor GC.
46+
* Longer term this deserves a better way to reclaim memory promptly.
47+
*/
48+
static void
49+
concurrent_set_mark(void *ptr)
50+
{
51+
(void)ptr;
52+
}
53+
4354
static const rb_data_type_t concurrent_set_type = {
4455
.wrap_struct_name = "VM/concurrent_set",
4556
.function = {
46-
.dmark = NULL,
57+
.dmark = concurrent_set_mark,
4758
.dfree = concurrent_set_free,
4859
.dsize = concurrent_set_size,
4960
},
50-
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
61+
/* Hack: NOT WB_PROTECTED on purpose (see above) */
62+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
5163
};
5264

5365
VALUE

0 commit comments

Comments
 (0)