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

explore: take advantage of modern CRuby GC features #2107

Closed
flavorjones opened this issue Nov 1, 2020 · 3 comments
Closed

explore: take advantage of modern CRuby GC features #2107

flavorjones opened this issue Nov 1, 2020 · 3 comments
Labels
topic/memory Segfaults, memory leaks, valgrind testing, etc.

Comments

@flavorjones
Copy link
Member

After reading Peter's Adventures in Ruby: Garbage Collection in Ruby - Peter Zhu:

Can we use rb_gc_mark_movable instead of rb_gc_mark?

I think we can.


And after peeking at Gradual Write-Barrier Insertion into a Ruby Interpreter:

Can we take advantage of WB protection?

I need to learn more here, but:

a) it doesn't look like we can make Node or Document objects use WB, because they are T_DATA and so are always created with wb_protected=false; and (from the linked doc above) "WB-unprotected objects can not become WB-protected objects."

b) we've already (long ago) removed RB_ARRAY_PTR in favor of rb_ary_entry so I'm not sure we're unprotecting anything we don't need or intend to unprotect


Things I'd like to do before we start working on this, though:

So anyone who's interested in this topic, I'm open to learning, but I'm unlikely to merge anything until and unless all of the above are addressed first.

@flavorjones flavorjones added the topic/memory Segfaults, memory leaks, valgrind testing, etc. label Nov 1, 2020
@flavorjones
Copy link
Member Author

cc @tenderlove to tell me how I'm incomplete or wrong here

@larskanis
Copy link
Member

I migrated ruby-pg from Data_Wrap_Struct to TypedData_Wrap_Struct a.k. typed-data recently here: ged/ruby-pg#349

This changed all T_DATA objects to typed-data, implements the GC.compact callbacks and removed all rb_gc_mark calls.

I did not make use of write barriers so far, since I didn't estimate a big performance advantage, but more complexity.

@flavorjones
Copy link
Member Author

We implemented TypedData_Wrap_Struct in #2579 which I think took care of all the compaction support. Given Lars's comment above about write barriers, I'm going to deprioritize this work and close this issue.

If there's GC-related work anybody thinks we should do, please comment and we can re-open or open a new sisue.

@flavorjones flavorjones removed this from the v1.14.0 milestone Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/memory Segfaults, memory leaks, valgrind testing, etc.
Projects
None yet
Development

No branches or pull requests

2 participants