Feature #9323
closedIO#writev
Description
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.
Files
Updated by normalperson (Eric Wong) over 10 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
in ruby/intern.h
Also, it'd probably be good to dedup the fptr->wbuf initialization
code in io_binwrite*.
Otherwise, I think this is fine.
Updated by ioquatix (Samuel Williams) over 7 years ago
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.
Updated by Glass_saga (Masaki Matsushita) over 7 years ago
- File patch.diff patch.diff added
rebase to trunk
Updated by Glass_saga (Masaki Matsushita) over 7 years ago
- Target version changed from 2.2.0 to 2.5
Updated by Glass_saga (Masaki Matsushita) over 7 years ago
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
end
Updated by akr (Akira Tanaka) about 7 years ago
- Status changed from Open to Feedback
Is there benchmark?
What the situation that writev is actually fast?
Updated by Glass_saga (Masaki Matsushita) about 7 years ago
The main purpose of IO#writev is to make a chance for users to write multiple buffers atomically, not to improve performance.
Updated by normalperson (Eric Wong) about 7 years ago
glass.saga@gmail.com wrote:
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:
https://80x24.org/spew/20170926005509.GA22313@starla/raw
Updated by matz (Yukihiro Matsumoto) almost 7 years ago
I vote for making IO#write
take multiple arguments, probably using writev(2)
inside.
Matz
Updated by Glass_saga (Masaki Matsushita) almost 7 years ago
- 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.
Updated by nobu (Nobuyoshi Nakada) almost 7 years ago
- 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]
Updated by shyouhei (Shyouhei Urabe) almost 7 years ago
- Related to Feature #9420: warn and puts should be atomic added
Updated by shyouhei (Shyouhei Urabe) almost 7 years ago
- Related to Feature #14042: IO#puts: use writev if available added