Issue #5562 has been updated by Hiroshi Shirosaki.

File test_result.tar.gz added
File win_io_for_r33699.patch added

I'm not sure how to do with test-all. mingw ruby seems not to pass all tests.
Anyway I tried to make test-all.
If ruby-core committers like this result, I hope this patch merged to trunk.

I have modified a patch to trunk. Previous patch conflicts with trunk. I have resolved and added minor fixes.

make test-all result become better.

- patched ruby on Windows 7 with mingw32 gcc 4.5.2. running on VirtualBox
10348 tests, 1884715 assertions, 7 failures, 5 errors, 94 skips

ruby -v: ruby 2.0.0dev (2011-11-10 trunk 33699) [i386-mingw32]

I have skipped test_https_proxy_authentication by mistake. So 1 skip is added.
Ruby on Windows XP chashes on this test, but this test are passed on Windows 7.


- trunk ruby
10348 tests, 1884718 assertions, 7 failures, 3 errors, 93 skips

ruby -v: ruby 2.0.0dev (2011-11-10 trunk 33699) [i386-mingw32]

Differences from ruby without patch are plus 2 errors. 1 failure is a different test.

patched ruby has
 98) Failure:
test_run_skip_verbose(TestMiniTestUnit) [c:/Users/hiroshi/work/ruby/test/minitest/test_minitest_unit

.rb:392]:
103) Error:
test_require_invalid_shared_object(TestRequire):
104) Error:
test_capture3_flip(TestOpen3):

However,

'make test-all TESTS="-v test_open3.rb"'
'make test-all TESTS="-v ruby/test_require.rb"'
'make test-all TESTS="-v ruby/minitest/test_minitest_unit.rb"'

are passed without failures and errors. That's strange.

trunk ruby has below failure, but ruby with this patch does't have below failure.
 99) Failure:
test_textmode(TestArgf) [c:/Users/hiroshi/work/ruby/test/ruby/test_argf.rb:657]:
[ruby-core:39234].
<"1\n2\n3\n4\n5\n6\n"> expected but was
<"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n">.


I attached a patch and test-all result.
Ruby on Windows XP has much more failure and error. Ruby on windows 7 is better.
How do you think about this result?
----------------------------------------
Feature #5562: Improvement of Windows IO performance
http://redmine.ruby-lang.org/issues/5562

Author: Hiroshi Shirosaki
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


=begin
I suggest a patch to improve Windows IO performance.

Ruby's text mode IO is much slower than binary mode.
On Windows text mode is default, so Windows IO is slow.
I assume that's mainly because of CRLF linefeed code conversion.

My idea to improve IO performance is as below.
- Change default linefeed conversion from Universal newline to CRLF newline on Windows
- Use binary mode process with OS's text mode if only CRLF conversion is needed
- Use Ruby's text mode with universal newline conversion if encoding conversion is needed

Although that causes io.c code to be more complicated, IO with CRLF conversion performance seems to be improved much.
I confirmed "make test-all TEST=ruby" have been passed. There was 3 errors, but ruby without this patch had same errors.
I think this patch doesn't affect other OS.

Line endings of "p" or "puts" writing is LF on trunk, but CRLF on 1.8.7 or 1.9.2.
This patch reverts to CRLF.


Here is #1332 benchmark test and results.

time = [Time.new]
c = ''
'aaaa'.upto('zzzz') {|e| c << e}
4.times { c << c }
time << Time.new
File.open('out.file','w') { |f| f.write(c) }
time << Time.new
c = File.open('out.file','r') { |f| f.read }
time << Time.new
0.upto(time.size - 2) {|i| p "#{i} #{time[i+1]-time[i]}" }


- Result

ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
"0 0.78125"
"1 0.6875"
"2 0.5625"

ruby 2.0.0dev (2011-11-03) [i386-mingw32]
"0 0.59375"
"1 1.09375"
"2 1.296875"

ruby 2.0.0dev (2011-11-03 trunk 33615) [i386-mingw32] with this patch
"0 0.625"
"1 0.65625"
"2 0.34375"
=end



-- 
http://redmine.ruby-lang.org