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

rb_check_symbol_cstr is not yet implemented #1814

Closed
larskanis opened this issue Nov 16, 2019 · 6 comments
Closed

rb_check_symbol_cstr is not yet implemented #1814

larskanis opened this issue Nov 16, 2019 · 6 comments
Assignees
Milestone

Comments

@larskanis
Copy link
Contributor

pg-1.2.0 will probably introduce field names deliverable as symbols. In MRI there are two types of symbols: dynamic and static symbols. PG will primary use dynamic symbols per rb_check_symbol_cstr() , to allow GC'ing of field names. Static symbols on the other hand can lead to memory bloat if field names are dynamically generated.

Unfortunately Truffleruby doesn't implement rb_check_symbol_cstr so that tests fail currently.

However the tests run fine on Truffleruby with static symbols allocated by ID2SYM().

So my questions are:

  1. Does Truffleruby distinguish between static and dynamic symbols like MRI does?
  2. Can I use ID2SYM() to allocate symbols on Truffleruby?
  3. Will you support rb_check_symbol_cstr() to make pg-1.2.0 work?
@eregon
Copy link
Member

eregon commented Nov 17, 2019

Thanks for the bug report!

  1. No, all Symbols are the same and GC'd.
  2. Yes.
  3. We will, but that will need to wait for the next release (20.0), so it would be helpful if pg can use ID2SYM() on TruffleRuby.

@eregon eregon self-assigned this Nov 17, 2019
larskanis added a commit to larskanis/ruby-pg that referenced this issue Nov 17, 2019
Truffleruby doesn't support rb_check_symbol_cstr() so far, but all symbols in Truffleruby are GC'd anyway.
So we can use classic ID2SYM to allocate the Symbol objects.

Discussed here: oracle/truffleruby#1814
@larskanis
Copy link
Contributor Author

Thank you @eregon ! I switched symbol allocation to ID2SYM in ged/ruby-pg#306 on Truffleruby and it works great. So you could drop the "priority" flag from this issue.

@eregon eregon removed the priority label Nov 19, 2019
@eregon
Copy link
Member

eregon commented Nov 19, 2019

@larskanis Thanks!
Using rb_str_intern always would work on both MRI and TruffleRuby, but that requires to allocate a temporary String so I guess that's why rb_check_symbol_cstr is used?

rb_check_symbol_cstr is mentioned in extension.rdoc and it seems useful for your case, so we'll implement it soon for compatibility.

@larskanis
Copy link
Contributor Author

requires to allocate a temporary String so I guess that's why rb_check_symbol_cstr is used?

Exactly! Most of the time the symbols are already allocated, so that we allocate strings only when necessary.

larskanis added a commit to larskanis/ruby-pg that referenced this issue Nov 19, 2019
Truffleruby doesn't support rb_check_symbol_cstr() so far, but all symbols in Truffleruby are GC'd anyway.
So we can use classic ID2SYM to allocate the Symbol objects.

Discussed here: oracle/truffleruby#1814
larskanis added a commit to larskanis/ruby-pg that referenced this issue Nov 20, 2019
Truffleruby doesn't support rb_check_symbol_cstr() so far, but all symbols in Truffleruby are GC'd anyway.
So we can use classic ID2SYM to allocate the Symbol objects.

Discussed here: oracle/truffleruby#1814
@eregon eregon added this to the 20.0.0 milestone Nov 28, 2019
@eregon
Copy link
Member

eregon commented Dec 11, 2019

I implemented rb_check_symbol_cstr in 2aafcec, it will be in the next release.

@eregon eregon closed this as completed Dec 11, 2019
@larskanis
Copy link
Contributor Author

Thank you @eregon ! Good to know it's in ruby spec now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants