From: Jon Forums Date: 2011-11-09T01:52:25+09:00 Subject: [ruby-core:40852] [ruby-trunk - Feature #5562] Improvement of Windows IO performance Issue #5562 has been updated by Jon Forums. Still looking great! I'm working on getting you profiling info and `test all` results/diffs. Results for text line reads on 500,000 LF delimited file. Your patch is the `wio-ruby 1.9.3p0` results which beats the legacy `1.8.7p352` results :) C:\projects\measurements-git>pik run rci bench core_rd_filelines_lf jruby 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f) (Java HotSpot(TM) Client VM 1.7.0_01) [Windows 7-x86-java] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 3.120000 0.000000 3.120000 ( 3.105000) ----------------------------------------------- total: 3.120000sec user system total real core_rd_filelines_lf 3.057000 0.000000 3.057000 ( 3.057000) ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 1.747000 0.266000 2.013000 ( 2.028004) ----------------------------------------------- total: 2.013000sec user system total real core_rd_filelines_lf 1.779000 0.187000 1.966000 ( 1.965603) ruby 1.9.2p290 (2011-07-09) [i386-mingw32] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 17.128000 0.094000 17.222000 ( 17.222430) ---------------------------------------------- total: 17.222000sec user system total real core_rd_filelines_lf 16.755000 0.124000 16.879000 ( 16.894830) ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 17.799000 0.031000 17.830000 ( 17.846432) ---------------------------------------------- total: 17.830000sec user system total real core_rd_filelines_lf 18.019000 0.015000 18.034000 ( 18.049231) wio-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 1.092000 0.140000 1.232000 ( 1.232402) ----------------------------------------------- total: 1.232000sec user system total real core_rd_filelines_lf 1.076000 0.141000 1.217000 ( 1.216802) ruby 2.0.0dev (2011-11-08 trunk 33664) [i386-mingw32] Rehearsal -------------------------------------------------------- core_rd_filelines_lf 16.661000 0.032000 16.693000 ( 16.707629) ---------------------------------------------- total: 16.693000sec user system total real core_rd_filelines_lf 16.552000 0.046000 16.598000 ( 16.614029) And results when doing binary read on the same test file just to make sure binary mode didn't get broken ;) C:\projects\measurements-git>pik run rci bench core_brd_filelines_lf jruby 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f) (Java HotSpot(TM) Client VM 1.7.0_01) [Windows 7-x86-java] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 1.871000 0.000000 1.871000 ( 1.820000) ------------------------------------------------ total: 1.871000sec user system total real core_brd_filelines_lf 1.749000 0.000000 1.749000 ( 1.750000) ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 1.716000 0.218000 1.934000 ( 1.926110) ------------------------------------------------ total: 1.934000sec user system total real core_brd_filelines_lf 1.700000 0.203000 1.903000 ( 1.910110) ruby 1.9.2p290 (2011-07-09) [i386-mingw32] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 0.858000 0.125000 0.983000 ( 1.008057) ------------------------------------------------ total: 0.983000sec user system total real core_brd_filelines_lf 0.827000 0.172000 0.999000 ( 1.006058) ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 0.827000 0.156000 0.983000 ( 1.002058) ------------------------------------------------ total: 0.983000sec user system total real core_brd_filelines_lf 0.858000 0.156000 1.014000 ( 1.029059) wio-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 0.858000 0.125000 0.983000 ( 0.989057) ------------------------------------------------ total: 0.983000sec user system total real core_brd_filelines_lf 0.796000 0.172000 0.968000 ( 0.966055) ruby 2.0.0dev (2011-11-08 trunk 33664) [i386-mingw32] Rehearsal --------------------------------------------------------- core_brd_filelines_lf 0.826000 0.188000 1.014000 ( 1.022058) ------------------------------------------------ total: 1.014000sec user system total real core_brd_filelines_lf 0.827000 0.202000 1.029000 ( 1.020059) ---------------------------------------- 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