I propose addition of IO#writev.
It enables gather output from multiple buffers.
If writev(2) is not available, IO#writev uses Array#join to emulate atomic write.
Make IO#write accept multiple arguments
io.c: make IO#write accept multiple arguments.
it uses writev(2) if possible.
io.c: fix local variables
- io.c (io_writev): fix local variable declarations, when writev(2) is not available. [Feature #9323]
io.c: no restriction
- io.c (io_write_m): remove argc restriction upto IOV_MAX-1. [Feature #9323]
io.c: fix buffered output
- io.c (io_binwritev): append to buffered data, not overwriting. [Feature #9323]
io.c: fix infinite retry
- io.c (io_binwritev): fix infinite retry when flushing buffered data. [Feature #9323]
#1 [ruby-core:60003] Updated by normalperson (Eric Wong) almost 4 years ago
Unless we have use for it, I don't think rb_io_writev should be in
the C API, and even less reason for it to be public for extensions
Also, it'd probably be good to dedup the fptr->wbuf initialization
code in io_binwrite*.
Otherwise, I think this is fine.
#8 [ruby-core:83014] Updated by normalperson (Eric Wong) 28 days ago
The main purpose of IO#writev is to make a chance for users to
write multiple buffers atomically, not to improve performance.
IO#write on Array#join result is atomic, too; but Array#join can
result in too large buffers and excessive memory use.
I wrote benchmarks for shards io-extra project on Rubyforge
years ago, but I guess that email is no longer available publically.
I've quoted and reposted the test to spew: