bug-ddrescue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-ddrescue] another idea for ddrescue (interleaved reads for "-d" )


From: Dave Burton
Subject: [Bug-ddrescue] another idea for ddrescue (interleaved reads for "-d" )
Date: Thu, 16 Aug 2007 02:44:57 -0400 (EDT)

Wow, Antonio, ddrescue keeps getting better and better!
I really like your status line idea.


Here's another idea.  I've been mulling over the terribly
slow performace in "raw mode" ("-d") or when reading from
a raw device under Linux.  When not encountering errors,
it seems to be massively slower than buffered (normal)
reads.  That's by far the greatest disadvantage of using
raw mode.

My guess is that the cause is that after reading one sector
too much time elapses to permit reading the next one until
the disk has made a complete revolution.  At 7200 rpm,
that would limit read speed to 120 sectors per second, or
60 kb / sec.  If that is what's going on, then the solution
might be to employ the very old technique of "interleave."

Reading sequential sectors is a "read interleave of 1."

For a "read interleave of 2," ddrescue would read every
other sector.  Instead of reading sequentially sectors
0,1,2,3,4,5,6,7,8,9 etc., ddrescue could read sectors
0,2,4,6,8,... then sectors 1,3,5,7,9, etc..

For a "read interleave of 3," ddrescue would read sectors
0,3,6,... then sectors 1,4,7,... then sectors 2,5,8,...
etc..

I have not done any experiments to determine whether or
not this helps "raw" read performance in the absence of
errors, but my guess is that it might help a lot.  (The
experiments should be done before considering adding this
complexity to ddrescue, of course!)

If using interleaved reads helps raw mode performance,
then I envision a ddrescue parameter to be used along
with "-d" to make it interleave reads in the absence of
errors.

It seems likely that an interleave of 2 might always be
sufficient, so I don't know whether or not there would
be any value in making the amount of interleave configurable.
However, if it turns out that interleaves of greater than
2 are sometimes necessary, then you could get even fancier
and have ddrescue time the reads and figure out for itself
what interleave to use!

The algorithm for dynamically adjusting the read interleave
might look something like this:

-----------------------------------------------------
  Interleave = 1;  // interleave=1 means no interleave; read sequential sectors
  votes4increase = 0;
  SectorNumber = LBA of first desired sector;
  repeat
     Read sector SectorNumber, and note how long it takes.
     If read error then
        SectorNumber = first unattempted desired sector (which might be 
previous to the sector we just tried to read)
     else
        // read was successful
        if read took < 15 mSec then
            // probably not a soft error
            if read took > 4 mSec then
               // it took a long time, probably a full revolution
               votes4increase = votes4increase + 1;
            else
               // read was quick, so probably got it without a full revolution
               if votes4increase > -400 then
                  votes4increase = votes4increase - 2;
               endif
            endif
            if votes4increase > 200 then
               // most reads seem to be requiring a full revolution, so 
increase read interleave
               Interleave = Interleave + 1;
               votes4increase = -200;
            endif
        endif
     endif
     If first skipped sector was more than 1000 sectors ago then
        SectorNumber = first skipped sector
     else
        SectorNumber = SectorNumber + Interleave
     else
  until done
-----------------------------------------------------


What do you think, Antonio?


Again, I thank you for making such a wonderful tool!


Warmest regards,

-Dave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]