As you might already know, messaging Objective-C objects from Ruby works by hooking the method_missing method. This has the great advantage to be completely dynamic with the bridged API, since methods can be added to an existing Objective-C at runtime when loading a new framework. But it has also the inconvenient to be very slow.
I have been experimenting an idea to improve the performances, which is to actually define the Ruby methods at demand, so that method_missing would only be called once. This is fair enough when you consider that in a realistic application, the same code is ran multiple times during the application life.
I first tried that using define_method but realized that it was also very slow. Then I decided to go with something faster, at the C level: using Libffi to create closures and injects them into the Ruby runtime.
As expected it works very well, and on average it's ~3 times faster! See this message for the crusty numbers.