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

Closed
sempervictus opened this Issue Dec 5, 2012 · 1 comment

Comments

Projects
None yet
3 participants

Several gems exist in the community allowing for fast IO operations using c bindings to kernel IO functionality. ruby_io_splice (http://bogomips.org/ruby_io_splice/), io-extra (http://rubydoc.info/gems/io-extra/1.2.6/frames), and sleepy_penguin (http://bogomips.org/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 (http://www.kernel.org/doc/man-pages/online/pages/man2/eventfd.2.html)

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

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

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 http://bogomips.org/sleepy_penguin.git/tree/ext/sleepy_penguin/eventfd.c

Owner

brixen commented Dec 28, 2015

There are a lot of possible optimizations that would be enabled by finishing the ffi-io branch work. Once that's in, we should revisit this with some very specific use cases.

brixen closed this Dec 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment