From: mame@... Date: 2017-10-23T11:58:01+00:00 Subject: [ruby-core:83525] [Ruby trunk Feature#14042] IO#puts: use writev if available Issue #14042 has been updated by mame (Yusuke Endoh). shyouhei (Shyouhei Urabe) wrote: > nobu (Nobuyoshi Nakada) wrote: > > It breaks other tests which mock `$stdout` and `$stderr`. > > I strongly believe implementation details of IO#puts shall never be what a test should care about. I'm unsure if it is a spec or not, but at least, it is a well-known practice to assign to `$stdout` a dummy object that implements a `write` method: * https://sketchucation.com/forums/viewtopic.php?f=180&t=31160 * http://d.hatena.ne.jp/rubikitch/20080421/1208758284 Matz has also showed a code using the practice: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/42076 I think we need to care the existing programs that uses the practice. ---------------------------------------- Feature #14042: IO#puts: use writev if available https://bugs.ruby-lang.org/issues/14042#change-67550 * Author: rohitpaulk (Paul Kuruvilla) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Hi, I've attached a patch to make IO#puts use writev if available. Currently, IO#puts calls `write` twice: Once to write the string, and the second to write a newline (if the string doesn't end with one already). With this patch, those two calls are replaced with a single `writev` call. A test has been added that demonstrates the problem. For a bit of background: * A related issue: https://bugs.ruby-lang.org/issues/9420. (I couldn't figure out a way to 'attach' my patch to that issue, so I'm creating a new one) * A blog post I wrote a while back about this: https://hackernoon.com/rubys-puts-is-not-atomic-889c57fc9a28 Command I used to run the test I added: `make test-all TESTS='ruby/test_io.rb -n test_puts_parallel'` I'm a first time contributor, a bit confused as to where a changelog entry should be added. Is the `NEWS` file the right place? Regards, Paul ---Files-------------------------------- ruby-changes.patch (2.39 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: