capnproto / node-capnp

Cap'n Proto bindings for Node.js
BSD 2-Clause "Simplified" License
258 stars 35 forks source link

Performance #8

Closed heri16 closed 9 years ago

heri16 commented 9 years ago

Is this an FFI library or an Addon? http://programminggiraffe.blogspot.com/2014/10/nodejs-ffi-vs-addon-performance.html

kentonv commented 9 years ago

It's an addon, but the v8 -> C++ calling mechanism is not the main problem here. The problem is that once we get to C++ we're calling the Cap'n Proto dynamic API, which is based on lookup tables and such and is therefore quite a bit slower than accessing a native Javascript object would be. Regular C++ code using Cap'n Proto relies on generated code for performance, but we can't generate and compile new C++ code whenever Javascript tries to import a schema.