Short-circuit C2 table loading at first encounter of lesser C2 entry #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short-circuits C2 table loading at the first encounter of an C2 table entry which is lesser than the previous C2 table entry.
This prevents
DiskProver
from loading dead-space into memory when reading C2.As there's no specification for the layout of tables in the plot file, but simply a table address in the plot header, plotters may place tables at addresses not immediately following the previous table.
Bladebit v1 does this since it writes with direct-io enabled and it does not make any effort to ensure the tables appear immediately after another if the previous table size is unaligned. Therefore the may be empty space between tables given the block size of the filesystem of the directory used to export the plot.
See Bladebit issue #153 and chiapos issue #13084
When said filesystem has a large block size, the empty space between tables will end up being quite large, and
DiskProver
will load the empty space following the C2 entries. This prevents that from happening.Because C2 entries are sorted in ascending order, we always expect to load a C2 entry of greater value, therefore if a lesser value is encountered it either means this is a corrupted/bad plot file or potentially there might be empty space, in which case it is safe to stop loading the table.