-
Notifications
You must be signed in to change notification settings - Fork 341
Description
I created a library that improves FFI performance on MRI using LLVM JIT, the result has the same performance as bindings through a C native extension. It extends FFI::Library and keeps compatible interface; it supports basic types such as int, bool and string (and lets unsupported functions to be handled by FFI::Library), but I can't support things implemented in FFI, like Struct and Pointer, without support from the ffi gem or re-implementing them from scratch.
I haven't fugured out yet how exactly to integrate with these implementations, but the high level idea is to compile native parts into LLVM bitcode the same way llvm_bitcode part is compiled in my gem. Another way would be to use rb_ext_resolve_symbol (simpler, but would work only on newer Rubies, also means less type safety, but that shouldn't be a problem as the interface should be tiny). So please let me know if you'll be willing to accept (small) changes to enable such integration.
It's also possible to integrate the JIT into the ffi gem completely (and hide it under a feature flag), but it'd require to partially re-implement ruby-llvm: ffi-llvm-jit uses ruby-llvm which, in turn, uses ffi; and ruby-llvm supports multiple LLVM versions through its different versions, whih would be harder to achieve in a single gem.