@ -697,8 +697,8 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
// Check if the suceeding files need compaction.
// Check if the suceeding files need compaction.
for ( unsigned int i = loop + 1 ;
for ( unsigned int i = loop + 1 ;
candidate_count < max_files_to_compact & & i < files . size ( ) ; i + + ) {
candidate_count < max_files_to_compact & & i < files . size ( ) ; i + + ) {
FileMetaData * f = files [ i ] ;
FileMetaData * suceeding_ file = files [ i ] ;
if ( f - > being_compacted ) {
if ( suceeding_ file - > being_compacted ) {
break ;
break ;
}
}
// Pick files if the total/last candidate file size (increased by the
// Pick files if the total/last candidate file size (increased by the
@ -708,14 +708,14 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
// kCompactionStopStyleSimilarSize, it's simply the size of the last
// kCompactionStopStyleSimilarSize, it's simply the size of the last
// picked file.
// picked file.
double sz = candidate_size * ( 100.0 + ratio ) / 100.0 ;
double sz = candidate_size * ( 100.0 + ratio ) / 100.0 ;
if ( sz < static_cast < double > ( f - > fd . GetFileSize ( ) ) ) {
if ( sz < static_cast < double > ( suceeding_ file - > fd . GetFileSize ( ) ) ) {
break ;
break ;
}
}
if ( ioptions_ . compaction_options_universal . stop_style = =
if ( ioptions_ . compaction_options_universal . stop_style = =
kCompactionStopStyleSimilarSize ) {
kCompactionStopStyleSimilarSize ) {
// Similar-size stopping rule: also check the last picked file isn't
// Similar-size stopping rule: also check the last picked file isn't
// far larger than the next candidate file.
// far larger than the next candidate file.
sz = ( f - > fd . GetFileSize ( ) * ( 100.0 + ratio ) ) / 100.0 ;
sz = ( suceeding_ file - > fd . GetFileSize ( ) * ( 100.0 + ratio ) ) / 100.0 ;
if ( sz < static_cast < double > ( candidate_size ) ) {
if ( sz < static_cast < double > ( candidate_size ) ) {
// If the small file we've encountered begins a run of similar-size
// If the small file we've encountered begins a run of similar-size
// files, we'll pick them up on a future iteration of the outer
// files, we'll pick them up on a future iteration of the outer
@ -723,9 +723,9 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
// by the last-resort read amp strategy which disregards size ratios.
// by the last-resort read amp strategy which disregards size ratios.
break ;
break ;
}
}
candidate_size = f - > compensated_file_size ;
candidate_size = suceeding_ file - > compensated_file_size ;
} else { // default kCompactionStopStyleTotalSize
} else { // default kCompactionStopStyleTotalSize
candidate_size + = f - > compensated_file_size ;
candidate_size + = suceeding_ file - > compensated_file_size ;
}
}
candidate_count + + ;
candidate_count + + ;
}
}
@ -738,12 +738,14 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
} else {
} else {
for ( unsigned int i = loop ;
for ( unsigned int i = loop ;
i < loop + candidate_count & & i < files . size ( ) ; i + + ) {
i < loop + candidate_count & & i < files . size ( ) ; i + + ) {
FileMetaData * f = files [ i ] ;
FileMetaData * skipping_ file = files [ i ] ;
LogToBuffer ( log_buffer , " [%s] Universal: Skipping file % " PRIu64
LogToBuffer ( log_buffer , " [%s] Universal: Skipping file % " PRIu64
" [%d] with size % " PRIu64
" [%d] with size % " PRIu64
" (compensated size % " PRIu64 " ) %d \n " ,
" (compensated size % " PRIu64 " ) %d \n " ,
cf_name . c_str ( ) , f - > fd . GetNumber ( ) , i , f - > fd . GetFileSize ( ) ,
cf_name . c_str ( ) , f - > fd . GetNumber ( ) , i ,
f - > compensated_file_size , f - > being_compacted ) ;
skipping_file - > fd . GetFileSize ( ) ,
skipping_file - > compensated_file_size ,
skipping_file - > being_compacted ) ;
}
}
}
}
}
}
@ -782,16 +784,17 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
c - > score_ = score ;
c - > score_ = score ;
for ( unsigned int i = start_index ; i < first_index_after ; i + + ) {
for ( unsigned int i = start_index ; i < first_index_after ; i + + ) {
FileMetaData * f = files [ i ] ;
FileMetaData * picking_ file = files [ i ] ;
c - > inputs_ [ 0 ] . files . push_back ( f ) ;
c - > inputs_ [ 0 ] . files . push_back ( picking_ file ) ;
char file_num_buf [ kFormatFileNumberBufSize ] ;
char file_num_buf [ kFormatFileNumberBufSize ] ;
FormatFileNumber ( f - > fd . GetNumber ( ) , f - > fd . GetPathId ( ) , file_num_buf ,
FormatFileNumber ( picking_ file - > fd . GetNumber ( ) , picking_ file - > fd . GetPathId ( ) ,
sizeof ( file_num_buf ) ) ;
file_num_buf , sizeof ( file_num_buf ) ) ;
LogToBuffer ( log_buffer ,
LogToBuffer ( log_buffer ,
" [%s] Universal: Picking file %s[%d] "
" [%s] Universal: Picking file %s[%d] "
" with size % " PRIu64 " (compensated size % " PRIu64 " ) \n " ,
" with size % " PRIu64 " (compensated size % " PRIu64 " ) \n " ,
cf_name . c_str ( ) , file_num_buf , i , f - > fd . GetFileSize ( ) ,
cf_name . c_str ( ) , file_num_buf , i ,
f - > compensated_file_size ) ;
picking_file - > fd . GetFileSize ( ) ,
picking_file - > compensated_file_size ) ;
}
}
return c ;
return c ;
}
}
@ -850,7 +853,6 @@ Compaction* UniversalCompactionPicker::PickCompactionUniversalSizeAmp(
for ( unsigned int loop = start_index ; loop < files . size ( ) - 1 ; loop + + ) {
for ( unsigned int loop = start_index ; loop < files . size ( ) - 1 ; loop + + ) {
f = files [ loop ] ;
f = files [ loop ] ;
if ( f - > being_compacted ) {
if ( f - > being_compacted ) {
char file_num_buf [ kFormatFileNumberBufSize ] ;
FormatFileNumber ( f - > fd . GetNumber ( ) , f - > fd . GetPathId ( ) , file_num_buf ,
FormatFileNumber ( f - > fd . GetNumber ( ) , f - > fd . GetPathId ( ) , file_num_buf ,
sizeof ( file_num_buf ) ) ;
sizeof ( file_num_buf ) ) ;
LogToBuffer (
LogToBuffer (