Issue #6002 has been updated by Motohiro KOSAKI.

Status changed from Open to Assigned
Assignee set to Motohiro KOSAKI

OK, approved.
----------------------------------------
Feature #6002: use IO#advise in FileUtils.compare_stream
https://bugs.ruby-lang.org/issues/6002

Author: Masaki Matsushita
Status: Assigned
Priority: Normal
Assignee: Motohiro KOSAKI
Category: lib
Target version: 


=begin
I propose to call IO#advise in FileUtils.compare_stream.
It will increase performance.

I created a dummy file:
 dd if=/dev/zero of=dummy bs=1M count=100

Then, I ran the following:

 require 'benchmark'
 require 'fileutils'
 
 path = "dummy"
 
 Benchmark.bm do |x|
   x.report do
     FileUtils.compare_file(path, path)
   end
 end

I freed page cache before each test:
 sudo sysctl -w vm.drop_caches=1

results on Ubuntu 11.10(3.0.0-15-server):

r34527:

 user     system      total        real
    0.050000   0.260000   0.310000 (  0.353097)
 
        user     system      total        real
    0.030000   0.250000   0.280000 (  0.320861)
 
        user     system      total        real
    0.070000   0.250000   0.320000 (  0.391100)

proposal:

 user     system      total        real
   0.050000   0.170000   0.220000 (  0.235541)

       user     system      total        real
   0.020000   0.150000   0.170000 (  0.188613)

       user     system      total        real
   0.030000   0.170000   0.200000 (  0.201237)

It shows the patch increases performance.
=end


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