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.
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.
I think this is a great idea. It avoids a ton of string issues - e.g. concatenating strings in Ruby before writing them out. It would be great if #write could take an array, and if possible, call writev.
- Target version changed from 2.2.0 to 2.5
It would be great if #write could take an array, and if possible, call writev.
That's would be nice.
File.open("test", "w") do |f|
f.write("foo", "bar", "baz") # use writev(2) if possible
- Status changed from Open to Feedback
Is there benchmark?
What the situation that writev is actually fast?
The main purpose of IO#writev is to make a chance for users to write multiple buffers atomically, not to improve performance.
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:
I vote for making
IO#write take multiple arguments, probably using
- File patch.diff patch.diff added
- Status changed from Feedback to Assigned
- Assignee set to Glass_saga (Masaki Matsushita)
This patch makes IO#write accept multiple arguments.
- Status changed from Assigned to Closed
Applied in changeset trunk|r60351.
io.c: fix local variables
- io.c (io_writev): fix local variable declarations, when
writev(2) is not available. [Feature #9323]
Also available in: Atom