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

JRuby support #21

Open
headius opened this issue Jan 26, 2022 · 2 comments
Open

JRuby support #21

headius opened this issue Jan 26, 2022 · 2 comments

Comments

@headius
Copy link

headius commented Jan 26, 2022

For performance and Java integration reasons, JRuby provides a native implementation of the set library. We would like to be able to use the gem, and our users will eventually add the gem to their bundles, so we need an answer. This will probably mean importing our extension into the gem, or we push a separate gem with our extension and load it from the pure-Ruby gem.

I will handle making the changes necessary.

@knu
Copy link
Member

knu commented Dec 7, 2023

It depends on how large part is written in Java, but I think it should be better maintained separately and there could be some tricks in loading on the pure-Ruby gem part and such a change request is welcome.

@headius
Copy link
Author

headius commented Oct 17, 2024

We could have a shared implementation entirely in Ruby but there are a number of issues with the current implementation:

  • No support for concurrency. The underlying Hash is read and written to without any locking or other concurrency controls.
  • Hash may not be the most efficient way to provide Set behaviors given that it allocates twice as much space for each set element as is needed.
  • The underlying Hash leaks out frequently through the given APIs. We have worked around this in our native implementation of Set, but ideally we could reduce the need for the internal Hash across all implementations.

Given the importance of Set for concurrent code, JRuby can't use the existing set.rb... and realistically, CRuby should not be using it either if there's any concurrent operations happening. I believe Ruby needs to have a concurrency-safe, efficient implementation of Set going forward.

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

No branches or pull requests

2 participants