thank you for your reply.
I went to read the code of max_compaction_bytes application at other levels. Its function is - "In a compaction, if the size of the currently constructed sst and the overlap size of the grandparent's sst exceeds max_compaction_bytes, the construction of this sst will be stopped in advance". This essentially avoids a large compaction in the future.
But I think this is fundamentally different from its role in level 0. Because the compaction of level n->level n+1, even if it is large, it will not block other compactions of level n->level n+1, as long as there is no overlapping key between them. But considering that level 0 is out of order, if there is a compaction in progress at level 0, it will block all compactions of level 0->level 1.
Another point of view is that this parameter is hardly used in the compaction of level other. The application of max_compaction_bytes in other levels of compaction is as follows:
if (grandparant_file_switched &&
overlapped_bytes_ + current_output_file_size_ >
compaction_->max_compaction_bytes()) {
// Too much overlap for current output; start new output
overlapped_bytes_ = 0;
return true;
}
But before that, there is a logic
if (current_output_file_size_ >= compaction_->max_output_file_size()) {
return true;
}
When an sst is constructed, before it uses the max_compaction_bytes parameter, it is very likely to exit because the size of the sst itself exceeds the target file size.
But in level 0, this parameter is almost closely related to the progress of intra0compaction. The size of level 0 often needs to reach the size of max_compaction_bytes to avoid intra0 compaction, and then level 0->level 1 compaction can be performed. Its role at level 0 is closer to the upper limit of the file size of a level 0, which is essentially different from its role in compaction at other levels.
Maybe we can split this option into two options? For level 0 and level others, respectively.