-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor to use ffi #4
Conversation
Right now the FFI implementation is considerably slower than the MRI C extension. Here's a benchmark for MRI:
And here's the exact same benchmark for FFI:
Should FFI really add this much overhead? I was hoping to see something within 10-20% of the MRI C extension. I'm not sure at this point if it's possible to optimize the FFI implementation or if this is more or less to be expected. One of my goals with this project is performance, so seeing this big of a difference between implementations is a bit disappointing. What do you think @tarcieri? |
FFI trampolines through How many FFI calls is that making, and how much time is spent in each of those calls from a purely C perspective? Are there FFI calls that execute very quickly in C which can be consolidated in C to reduce the total number of FFI calls? |
I refactored a bit to do more in C and improved the FFI implementation from ~104k to ~180k. Better, but still not great. 65% of the time is spent in What I'm thinking right now is to keep |
If you're willing to support both an MRI extension and FFI, that sounds great @bryanp. That's an approach I'd never considered before, but if you wrap things up in the C/Ruby code nicely enough it may not be that much of a pain to do. |
Replaced by #12. |
Replaces the MRI C extension with FFI.
This has not been tested extensively yet, and I'd like to do some benchmarking before committing to this direction.