Enhanced optimal block size copy algorithm to reduce time required to move or copy partitions
svn path=/trunk/; revision=880
This commit is contained in:
parent
0e75f133d7
commit
a2b96b0094
|
@ -1,5 +1,12 @@
|
|||
2008-08-06 Curtis Gedak <gedakc@gmail.com>
|
||||
|
||||
* src/GParted_Core.cc: Enhanced optimal block size copy algorithm.
|
||||
- Changed algorithm to try all block size possibilities instead of
|
||||
stopping as soon as next larger block size took longer to copy than
|
||||
the prior block size. Due to anomalies in benchmark times, the
|
||||
previous algorithm would favour smaller block sizes.
|
||||
- Closes GParted bugs #546423, and #438574
|
||||
|
||||
* README: Updated with new directories for GParted Manual
|
||||
|
||||
2008-08-05 Curtis Gedak <gedakc@gmail.com>
|
||||
|
|
|
@ -1723,7 +1723,8 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
|
|||
|
||||
operationdetail .add_child( OperationDetail( _("finding optimal blocksize"), STATUS_NONE ) ) ;
|
||||
|
||||
Sector optimal_blocksize = readonly ? 128 : 64, N = 32768 ;
|
||||
Sector benchmark_blocksize = readonly ? 128 : 64, N = 65536 ;
|
||||
Sector optimal_blocksize = benchmark_blocksize ;
|
||||
Sector offset_read = src_start,
|
||||
offset_write = dst_start ;
|
||||
|
||||
|
@ -1739,24 +1740,18 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
|
|||
double smallest_time = 1000000 ;
|
||||
bool succes = true ;
|
||||
|
||||
//Benchmark copy times using different block sizes to determine optimal size
|
||||
while ( succes &&
|
||||
timer .elapsed() <= smallest_time &&
|
||||
std::llabs( done ) + N <= length &&
|
||||
optimal_blocksize * 2 < N )
|
||||
benchmark_blocksize <= N )
|
||||
{
|
||||
if ( done != 0 )
|
||||
{
|
||||
smallest_time = timer .elapsed() ;
|
||||
optimal_blocksize *= 2 ;
|
||||
}
|
||||
|
||||
timer .reset() ;
|
||||
succes = copy_blocks( src_device,
|
||||
dst_device,
|
||||
offset_read + done,
|
||||
offset_write + done,
|
||||
N,
|
||||
optimal_blocksize,
|
||||
benchmark_blocksize,
|
||||
operationdetail .get_last_child(),
|
||||
readonly,
|
||||
total_done ) ;
|
||||
|
@ -1765,15 +1760,19 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
|
|||
operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail(
|
||||
String::ucompose( _("%1 seconds"), timer .elapsed() ), STATUS_NONE, FONT_ITALIC ) ) ;
|
||||
|
||||
if ( timer .elapsed() <= smallest_time )
|
||||
{
|
||||
smallest_time = timer .elapsed() ;
|
||||
optimal_blocksize = benchmark_blocksize ;
|
||||
}
|
||||
benchmark_blocksize *= 2 ;
|
||||
|
||||
if ( ( dst_start > src_start ) )
|
||||
done -= N ;
|
||||
else
|
||||
done += N ;
|
||||
}
|
||||
|
||||
if ( timer .elapsed() > smallest_time )
|
||||
optimal_blocksize /= 2 ;
|
||||
|
||||
if ( succes )
|
||||
operationdetail .get_last_child() .add_child( OperationDetail( String::ucompose( _("optimal blocksize is %1 sectors (%2)"),
|
||||
optimal_blocksize,
|
||||
|
|
Loading…
Reference in New Issue