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

Improve Rubinius support for msgpack Ruby gem #103

Merged
merged 3 commits into from
Mar 19, 2012
Merged

Improve Rubinius support for msgpack Ruby gem #103

merged 3 commits into from
Mar 19, 2012

Conversation

dbussink
Copy link
Contributor

These commits improve the support for Rubinius in the msgpack gem. It makes sure the msgpack gem doesn't use internals of MRI to handle some things, because emulating them makes it terribly slow in Rubinius. By using the functions available in MRI, this is not a problem.

It also improves how the st.h header is detected by not using the RUBY_VM define, but by letting extconf.rb detect whether it's present or not.

Using internals of MRI by using RARRAY_PTR makes it necessary for other
implementations such as Rubinius to continuously copy the structure
returned by RARRAY_PTR back and forth since in Rubinius objects are
layed out differently internally.

Extensions should not depend and use these internal MRI structures if
this is not necessary and when there are API methods that can provide
the same functionality. This makes sure other implementations can also
use the extension without any big problems.

For this reason I also removed the FIXME comment, since that change
would also heavily depend on the internal memory layout of objects on
MRI.
From what I could investigate, msgpack doesn't modify char* buffers
obtained from RSTRING_PTR. This means that on Rubinius we don't have to
copy back and forth the buffer to make sure it's also updated on the
Ruby side.

This copying of buffers is a similar problem as the RARRAY_PTR problem,
because it is not safe to expose GC'ed memory on Rubinius to extensions
since it can move due to Rubinius having a moving GC.
repeatedly added a commit that referenced this pull request Mar 19, 2012
Improve Rubinius support for msgpack Ruby gem
@repeatedly repeatedly merged commit 92975bb into msgpack:master Mar 19, 2012
@repeatedly
Copy link
Member

@dbussink : Thanks for the pull request.

It's a great patch!

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.

2 participants