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

Help with magnus migration #32

Merged
merged 16 commits into from
Sep 27, 2022
Merged

Conversation

ianks
Copy link
Contributor

@ianks ianks commented Sep 22, 2022

So I had a little time and figured I'd give yrb a whirl. Great work on it! I figured I'd contribute some improvements along the way:

  1. Use the git version of magnus for full support of rb-sys. This vastly reduces the number of edge cases when linking with libruby.
  2. Add a ci.yml workflow for testing on each PR and push (uses a new GitHub action I wrote to make this easy). Everything is green, including windows!
  3. Fix for cross compiling issue with bundler on rcd. This resolves makes cross compilation work on 4 platforms ✅
  4. Integrate clippy into the workflow (no strict checks yet, but added the config for VSCode and warnings in CI)

Hopefully you find this useful!

@eliias
Copy link
Collaborator

eliias commented Sep 22, 2022

@ianks Thanks a lot for this contribution 💚.

Could you help me understand what the Send trait exactly does for us? I somewhat follow the explanation from "the book" (https://doc.rust-lang.org/nomicon/send-and-sync.html), but I wonder if this is to make the lib thread-safe from a Ruby perspective, or is this just best practice for all data structures that are eventually passed between the Ruby/Rust world?

@ianks
Copy link
Contributor Author

ianks commented Sep 22, 2022

but I wonder if this is to make the lib thread-safe from a Ruby perspective, or is this just best practice for all data structures that are eventually passed between the Ruby/Rust world?

Send is simply a marker trait, meaning we "manually" have to guarantee that the types are safe to be sent across threads. In this case, I'm operating under the assumption that yrb isn't sending this data across its own spawned Rust threads, and that all access is done when the GVL is held. I didn't dive into the implementation too much though, it might be wise to use a Mutex instead of RefCell if Rust threads are involved.

@ianks
Copy link
Contributor Author

ianks commented Sep 23, 2022

@eliias See your approval, but it won’t let me merge. I’ll let you take care of that part, but if you need anything else just let me know. Happy to help.

@eliias
Copy link
Collaborator

eliias commented Sep 23, 2022

@eliias See your approval, but it won’t let me merge. I’ll let you take care of that part, but if you need anything else just let me know. Happy to help.

Ah… my bad, I forgot about permissions. Will merge 👍, and thanks again.

@ianks
Copy link
Contributor Author

ianks commented Sep 23, 2022

FWIW, I think that windows failure is a legit bug. The tests have passed before so it may be flaky. Ideally you can merge with this failure and address it in a follow up?

@eliias
Copy link
Collaborator

eliias commented Sep 27, 2022

FWIW, I think that windows failure is a legit bug. The tests have passed before so it may be flaky. Ideally you can merge with this failure and address it in a follow up?

Yeah, I have seen similar behavior with XMLText/XMLElement previously in test runs (and not on Windows). @Horusiath could you take a look at the test output and help us assess if this is a y-rb or a y-crdt issue?

@eliias eliias merged commit 9db6605 into y-crdt:migrate-to-magnus Sep 27, 2022
@Horusiath
Copy link

I've recreated the failing scenario in Rust, and couldn't reproduce the issue. Since the code there doesn't use serialisation, I assume that problem must exists somewhere in the memory mapping between Rust and Ruby classes.

@eliias
Copy link
Collaborator

eliias commented Sep 29, 2022

I've recreated the failing scenario in Rust, and couldn't reproduce the issue. Since the code there doesn't use serialisation, I assume that problem must exists somewhere in the memory mapping between Rust and Ruby classes.

@Horusiath thanks for checking, I will try to reproduce somehow. It is a bit weird, it only happens with XML nodes, and it also fails intermittently 🤷.

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

Successfully merging this pull request may close these issues.

3 participants