Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Extend FFI::Platform::POSIX with faster native IO methods #2078

sempervictus opened this Issue · 0 comments

2 participants


Several gems exist in the community allowing for fast IO operations using c bindings to kernel IO functionality. ruby_io_splice (, io-extra (, and sleepy_penguin ( are good examples of this.

Placing this functionality into FFI, with analogous calls for other platforms where possible can yield considerable performance gains over current IO implementation by avoiding user space interaction where possible, and may provide a foundation for rewriting/extending ::IO further.

Example: eventfd (

module EventFd
extend FFI::Library
attach_function :eventfd, [:int, :int], :int
attach_function :close, [:int], :int

efd = EventFd.eventfd(0,0)
io =

The "io" object is now a selectable, readable, writable IO object. There are issues with how InternalBuffer keeps track of R/W position, though should suffice for PoC.

C ext implementation of eventfd (far more complete, but IMO less readable) is at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.